Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other
Wikipedia has an article on:



If you are using a reiser4 partition and having troubles emerging some packages then hopefully this will help you.

This tip is based upon the solution presented by dvang and Spart on the Gentoo Forums. All credit goes to them.

Known packages that have issues with reiser4

The problems with openoffice-ximian should now be resolved. If you use an older version of OO-ximian, read on. Version 1.3.6 seems to compile OK.

The Problem

For some reason when portage is working with files in PORTAGE_TMPDIR reiser4 has the tendency to freeze. For specific details you will have to ask the folks over at namesys. Keep in mind however that reiser4 is still not considered stable so don't complain too much.

Note: now at v 1.0.4 (March 2005) namesys clearly mark this as stable.

Solution 1 (New Partition)

The first solution to the problem is perhaps a more permanant fix. In order to use this however you will need to have some extra unpartitioned space laying around. If you are like me then this doesn't apply to you. You will need to create a new ext2 or ext3 partition to use for your PORTAGE_TMPDIR directory. So go ahead and make a new partition using fdisk:

Code: Making a new partition
 fdisk /dev/hd(x) 

Assuming we have our new partition (for demonstration purposes we will assume that /dev/hda4 was created) create a new filesystem on it. You can choose any filesystem (other than reiser4 of course). However, ext2 or ext3 will most likely be the fool proof method.

Code: Creating the filesystem
 mkfs.ext2 /dev/hda4

All that is left now is to mount the new partition to your PORTAGE_TMPDIR directory. Go ahead and add the following line to /etc/fstab (replacing /dev/hda4 to reflect your actual system)

File: modifying /etc/fstab
 <fs>                 <mountpoint>            <filesystem>         <options>    <dump/pass>
 /dev/hda4            /var/tmp/portage        ext2                 defaults      0    0      

And now mount the new partition

Code: mount partition
 mount /var/tmp/portage

Solution 2 (Using swap space)

If you don't have any empty un-partitioned space laying around (as most of us probably don't) then you can use this solution. However, please keep in mind that this is not the preferred method and can be dangerous. Here we will drop our swap space and use it as a temporary ext2 / ext3 partition to use for PORTAGE_TMPDIR . First let's backup /var/tmp/portage (just in case):

Code: Backing up /var/tmp/portage
 tar -cvf ~/vtport-backup.tar /var/tmp/portage
 gzip ~/vtport-backup.tar

Now turn off swap and unmount the swap partition:

Code: killing your swap space
 umount /dev/swap_partition

Now we need to format our swap partition to a new filesystem. This is going to require some modification. First we will need to fire up fdisk and change the type of partition.

Code: Changing the partition type
 fdisk /dev/hda
 select t (type)
 select appropriate partition
 select type 83 (Linux)
 select w (write partition table)

Now let's create a new filesystem. (change /dev/hda2 to reflect your actual system)

Code: Creating the new filesystem
 mkfs.ext3 /dev/hda2

Now we need to mount the partition (there is no need to add this to /etc/fstab .. its just a temporary fix)

Code: Mounting the new partition
 mount /dev/hda2 /var/tmp/portage

Next go ahead and emerge whatever package was giving you trouble.

Code: emerge the package
 emerge php

Done! Yeah right... Now we need to reverse the process. So go ahead and fire up fdisk again and change the partition type back to Linux Swap (82):

Code: Back to the future
 fdisk /dev/hda
 select t (type)
 select appropriate partition
 select type 82 (Linux Swap)
 select w (write partition table)

Let's make the partition a swap filesystem now:

Code: Making it swap again
 mkswap /dev/hda2
 swapon /dev/hda2

and go ahead and restore /var/tmp/portage:

Code: restoring /var/tmp/portage
 mv ~/vtport-backup.tar /var/tmp/portage
 cd /var/tmp/portage
 tar -xvfz vtport-backup.tar
 rm vtport-backup.tar

Solution 3 (Using a loopback device)

If you can't make a new permanant partition for PORTAGE_TMPDIR (Which, IMHO is the preferred solution untill the issues with reiser4 are resolved) then this is the next best thing. Moving around your swap partition is dangerous and could result in some system damage. What we will do here is create a temporary loopback device and mount this as our PORTAGE_TMPDIR. You will need to make sure that you have loopback device enabled in your kernel.

You can enable this either as a module or built-in. Just make sure that it's loaded before your continue.

Code: Enabling loopback device support (If you have not already done so
 cd /usr/src/linux
 make menuconfig
 Device Drivers --->
   Block Devices --->
      <*/M> Loopback device support

Now we need to make a file large enough to support the package we are trying to emerge. (we will use PHP as an example)

Code: Making a partition file 128MB
 dd if=/dev/zero of=/root/portage.ext2 bs=1M count=128

Now we will format this file to a partition. When doing this mkfs will compain this it isn't a block device. Tell it to continue anyway:

Code: Formating our partition file
 mkfs.ext2 /root/portage.ext2

Now we can mount our new partition using the loopback device:

Code: Mount the partition
 mount -t ext2 -o loop /root/portage.ext2 /var/tmp/portage

Go ahead and emerge whichever package you need:

Code: emerge package
 emerge php

Now all that you need to do is unmount the partition. And (optionally) delete the file.

Code: unmount
 umount /var/tmp/portage
 rm /root/portage.ext2

Solution 4 (Using tmpfs)

If you have tmpfs support in your kernel you can bind /dev/shm (mounted as tmpfs) to PORTAGE_TMPDIR:

 mount /dev/shm /var/tmp/portage -o bind

Solution 5 (mount bind to directory in acceptable file system)

If you have a filesystem that will work with some free space on (for example an ext3 home partition), you can bind a temporary directory to /var/tmp/portage:

 mount /home/meh/tmp /var/tmp/portage -o bind

Where /home/meh/tmp is name of a directory with some space on.


Hopefully this will help you solve some reiser4 issues with emerging packages. If you find any other packages that choke while emerging on a reiser4 partition please add them.

Questions / Comments

Concerns or Compliments? Please use the Discussion section.

Retrieved from ""

Last modified: Wed, 26 Dec 2007 15:19:00 +0000 Hits: 22,468