Before You Start[]

Other Techniques To Add Space[]

There are other methods available to add space to your Gentoo image. These are useful to know in any event and may be simpler for you than the process descibed here.

Adding More Space[]

_Note: If you want a minimal install to start with, I suggest you use the i686 image instead of the "deluxe" i586 image; however, the i686 image does not come with an X server or any X applications pre-installed._

You will run out of disk space with the default images sooner than later. This is especially true if you are using the i686 image. For this reason, I suggest splitting /var, /usr and /home into their own images.

Micro Intro To The Linux Filesystem[]

If you are not familiar with the Linux filesystem, you will eventually want to read: Filesystem Hierarchy Standard (FHS) 2.3 but in the meantime you should be aware of a few aspects of Linux that are pertinent at this point.

First of all, in Linux, the kernel exposes everything via files in a filesystem hierarchy -- specifically, in the root hierarchy (/) under which everything else resides. You can _mount_ a _block device_ to an arbitrary position under the root. Read the FHS linked above when you are ready to learn the standards for directory placements.

coLinux's XML configuration file allows you to specify special file-based block devices which are made available to Linux/ These are located in /dev/cobd*n*, where *n* is 0-7 (cobd stands for coLinux Block Device). We can mount these block devices as file systems located at an arbitrary place in the filesystem. Normally, the root (/) filesystem is mounted from /dev/cobd0.

A point to keep in mind is that when you mount a filesystem to a directory location, any operation on that directory location affects the underlying block device. So even though everything appears to be under a single root (/), the underlying storage can be distributed amoung several block devices (as well as other types of devices).

Create New Block Devices[]

You should plan to at least create room for /var and /usr. These directories tend to require a lot of space, particularly if you emerge a lot of programs.

Use the TopoEnlarge tools which you can find via the Colinux Image Tools page along with some instructions. For myself, aside from swap (see: AddSwapPartition if you haven't already), I created:

  • 4gb ext3 for /usr
  • 2gb ext3 for /opt
  • 4gb ext3 for /var
  • 4gb ext3 for /home

Of course, you will be limited by your available disk space, but don't forget that these files needn't (and probably shouldn't) all be on the same physical disk drive or partition. To make things easier for myself, in each of my physical drives mounted in Windows, I created a directory stucture like so:


I drop the block device files like _usr_ and _var_ into the appropriate /fs/ext3 directory. If I have a swap file on that disk, I put it in the swap dir and I name it something like 768 (for 768mb) or 1024 (for 1GB). This way, I can use the Cygwin shell to easily find all of my installed devices on my machine:

ls /cygdrive/~*/fs/~*/~*

Add the neccessary references for the file block devices you created in your default.colinux.xml for each new block device. Mine looks like this (note that I spread the files over several drives and controllers):

<?xml version="1.0" encoding="UTF-8"?>
    <block_device index="0" path="\[[DosDevices]]\h:\fs\ext3\root\gentoo-i686" enabled="true" />
    <block_device index="1" path="\[[DosDevices]]\h:\fs\ext3\home"  enabled="true" />
    <block_device index="2" path="\[[DosDevices]]\g:\fs\ext3\usr"   enabled="true" />
    <block_device index="3" path="\[[DosDevices]]\h:\fs\ext3\opt"   enabled="true" />
    <block_device index="4" path="\[[DosDevices]]\h:\fs\ext3\var"   enabled="true" />
    <block_device index="7" path="\[[DosDevices]]\c:\fs\swap\768"   enabled="true" />
    <image path="vmlinux" />
    <memory size="384" />
    <network index="0" type="bridged" name="VIA" />

Copy Files To Newly Created Block Devices[]

Now, make sure you aren't running your i686 image in coLinux--in fact, shut down coLinux for now. Make a copy of your i686 image and rename the copy to gentoo-i686-base. We are going to modify the copy and leave your original alone so we will temporarily modify the above xml to add the gentoo-i686-base image as a new device:

    <block_device index="6" path="\[[DosDevices]]\h:\fs\ext3\root\gentoo-i686-base" enabled="true" />

When you boot into coLinux with the above settings (modified for your system, of course), you are still booting with your original i686 image and you should end-up with a bunch of extra devices that can now be mounted. First, login as root. Then create a work directory somewhere convenient:

# mkdir /root/work

The following shows the steps to copy an old directory into a new mount.

First, create a temporary spot to mount the volume you are going to copy to. For example, to create a temporary mount point for /usr in our newly created work directory:

# mkdir /root/work/usr

You can now mount a volume to that directory. In the above example, the new (empty) usr volume is loaded at index "2", thus to mount that block device in the new directory we just created:

# mount -t ext3 /dev/cobd2 /root/work/usr

Now everything that you save into /root/work/usr will be saved not in the gentoo-i686 image file, but instead in the new usr file block device which you created earlier.

We now want to copy all of the existing /usr files from the gentoo-i686 image (which you will remember is where you booted from) into the new temp location. We will use _rsync_ to do this. Note that the slashes here are very important -- do a *man rsync* to find out more. In the meantime, type the following, being careful to make sure you get all the slashes correct:

# rsync -avg /usr/ /root/work/usr

This transfers all of the files from your root /usr into the our empty device mounted at /root/work/usr while preserving file permissions, symlinks, attributes, devices, etc. It also uses a compression algorithm which helps keep things moving.

Repeat the above steps for each of the directories that you intend to move into new volumes. The following completes the required steps for my setup:

# mkdir /root/work/home
# mount -t ext3 /dev/cobd1 /root/work/home
# rsync -avg /home/ /root/work/home

# mkdir /root/work/opt
# mount -t ext3 /dev/cobd3 /root/work/opt
# rsync -avg /opt/ /root/work/opt

# mkdir /root/work/var
# mount -t ext3 /dev/cobd4 /root/work/var
# rsync -avg /var/ /root/work/var

Configure The New gentoo-i686-base Image[]

When you are done moving everything, it is time to setup the gentoo-i686-base which we have available at /dev/cobd6 (in the above example). Create a new temporary spot for it in /root/work and then mount it:

# mkdir /root/work/gentoo-i686-base
# mount -t ext3 /dev/cobd1 /root/work/gentoo-i686-base

When you mount it in this way, it is not the "active" root volume -- it is merely an attatched filesystem. This is the fun part: for each of the directories you are replacing with a dedicated block device, you can now blow out the contents of those directories in the gentoo-i686-base image since we have already copied them to their new locations.


  • *rm -Rf* Triangle/Facility/4118/misc/rm.html is a very dangerous command when used incorrectly -- don't use it lightly :)
  • *rm -Rf* removes all files from the indicated location including all subdirectories--without prompting.
  • Make sure that you created and mounted /root/work/gentoo-i686-base/ before doing this operation!
  • You needn't remove these directories at this time if you don't want to, so you can also skip this step._

For the above example, use the following or modify to suit your selections:

# rm -Rf /root/work/gentoo-i686-base/usr/*
# rm -Rf /root/work/gentoo-i686-base/var/*
# rm -Rf /root/work/gentoo-i686-base/home/*
# rm -Rf /root/work/gentoo-i686-base/opt/*

The gentoo-i686-base image should now be a lot thinner! To get some volume usage info:

# df

We now have to modify the gentoo-i686-base image's fstab file so that it is aware of the new devices that we created and setup.

# vi /root/work/gentoo-i686-base/etc/fstab

If you don't want to use vi, try the slightly simpler nano editor instead:

# nano /root/work/gentoo-i686-base/etc/fstab

The /etc/fstab file is used by Linux to mount volumes, including boot time mounting. To learn more about fstab, read Configuring your System or type *man fstab*. You will need to add lines for each of the devices you created. For example, this is the line to enter for your new /usr device (as per the xml above):

/dev/cobd2 /usr ext3 noatime 0 0

Add lines for each of the volumes you created and moved over from the gentoo image. The following are required to complete the above example:

/dev/cobd1 /home ext3 noatime 0 0
/dev/cobd3 /opt ext3 noatime 0 0
/dev/cobd4 /var ext3 noatime 0 0


We want to keep the i686 image we booted from in a pristine state, so we now remove all the work files. To do that, we first unmount _all_ of the extra block devices we created and then cleanup the /work directory:

# umount /dev/cobd1
# umount /dev/cobd2
# umount /dev/cobd3
# umount /dev/cobd4
# umount /dev/cobd6

Don't umount /dev/cobd0 (/) or /dev/cobd7 (swap)

Ensure that everything got unmounted:

# df

Then and only then:

# rm -Rf /root/work/*

Restart coLinux[]

At this point, you should shut down coLinux. Modify your _default.colinux.xml file_, removing the temporary device line we added earlier for block_devce index="6" and change the existing index="0" so that it points to your newly touched up gentoo-i686-base image.

Additionally, you may want to make a backup copy of your gentoo-i686-base image so you have a fresh copy to start from should you need it.

When you restart coLinux using this xml file, you should now boot into a much roomier Gentoo system.

_*Good Luck and Have Fun!*_


MassTranslated on 25 Dec 2004.

MassTranslated on Sun Apr 23 17:36:13 UTC 2006