Moving all of /usr to SD

If you want to recover as much of your flash space as possible, you can move the entire /usr directory to your SD card. This is the trickiest move, due to the numerous symlinks associated with the busybox command, but it's still doable.

Warning

The danger associated with copying the entire /usr directory is that it's required by the boot process. If, for any reason, your SD card fails to mount during the boot process, you won't get a clean boot. (Actually, the same is true of the /opt directory, which is required to run Opie, so you should be sure that your SD card will mount properly at boot time before moving either of these directories to your SD card.)

First, recall that most of the commands in both /bin and /usr/bin were just symlinks to the /bin/busybox executable. The first thing you need to do is create a few additional symlinks in /bin for commands that appear to be in /usr/bin and that will vanish as soon as you move /usr to the SD card:

# for cmd in [ tail cut test dc ; do
> ln -s /bin/busybox /bin/$cmd
> done
   

Next, there are numerous commands in both the /usr/bin and /usr/sbin directories that are symlinks to the busybox command, but that use relative and not absolute names; these files must have their links updated to refer to an absolute pathname:

# for cmd in /usr/bin/* /usr/sbin/* ; do
> [ /bin/busybox -ef $cmd ] && ln -sf /bin/busybox $cmd
> done
   

Finally, you can copy the entire /usr directory to the SD card, remove the original, and symlink from the original location:

# cp -a /usr /mnt/card/usr
# rm -rf /usr
# ln -s /mnt/card/usr /usr
   

At this point, you're free to restart Opie and get back to work.

Important

Before you start installing software under this new directory layout, make sure you understand that you don't need to specify that you're installing to the SD card anymore.

Because of the symlinks, all of these directories, while they exist physically on the SD card, will appear to be in the root directory as they were before, so you would just be installing to "root".

You might want to read on to the chapter on "Software Administration" to make sure you understand this.