Freeing up space on hda1

Background
If you are running out of hard drive space on hda1 (the location of the OS, and the default location of installed programs), you can free up space by moving some of the files to hda3 (the large partition containing the network shares). You can then create symbolic links in the original locations, and should in that way be able to access your files as if nothing happened (for the most part). You could well run into problems if you do this with OpenLink. There are known issues related to how BusyBox uses symbolic links, and other issues might arise. Some issues are reported below. Proceed at your own risk.

/home
Moving the /home directory should be safe, but it will not save you much space unless you are going to store a lot of data in the home directory of users. This can be done as follows: DIR="$(mount | grep hda3 | awk '{print $3}')" cp -Rdp /home ${DIR} rm -R  /home ln -s ${DIR}/home /home

/usr/local
Moving the /usr/local directory should also be safe. This directory contains additionally installed software, and moving it should not disrupt any mission critical applications. This can be done as follows: DIR="$(mount | grep hda3 | awk '{print $3}')" mkdir  ${DIR}/usr cp -Rdp /usr/local ${DIR}/usr rm -R  /usr/local ln -s ${DIR}/usr/local /usr/local

First method
This script makes the needed changes to all the busybox symlink, changing them from ../../bin/busybox links to /bin/busybox. Run it with the AWK program.


 * 1) !/bin/awk -f

BEGIN { FS=" " while ("ls -al /usr/bin | grep ../../bin/busybox" | getline) { system("rm /usr/bin/"$9) system("ln -s /bin/busybox /usr/bin/"$9) } while ("ls -al /usr/sbin | grep ../../bin/busybox" | getline) { system("rm /usr/sbin/"$9) system("ln -s /bin/busybox /usr/sbin/"$9) } }

Alternative method
The following has also been suggested as a fix to the symlink problem. It is a bit more work than the above method, but might be able to resolve non-busybox-related symlink problems as well.

If you follow the FAQ to move /usr to say, /mnt/hda/moved_folder/usr and symbolic-link it back, some relative links won't work. For example, /usr/bin/wget has the symbolic link ../../bin/busybox</tt>, and that would get resolved to /mnt/hda/moved_folder/bin/busybox</tt>, which does not exist. Therefore, you can link all unmoved directory under root back to this /mnt/hda/moved_folder</tt>:

DIR="$(mount | grep hda3 | awk '{print $3}')" ln -s /bin /mnt/hda/moved_folder ln -s /mnt/hda/moved_folder ln -s /etc /mnt/hda/moved_folder ln -s /lib /mnt/hda/moved_folder ln -s /lost+found /mnt/hda/moved_folder ln -s /mnt /mnt/hda/moved_folder ln -s /proc /mnt/hda/moved_folder ln -s /root /mnt/hda/moved_folder ln -s /sbin /mnt/hda/moved_folder ln -s /sys /mnt/hda/moved_folder ln -s /tmp /mnt/hda/moved_folder ln -s /www /mnt/hda/moved_folder

/home
Moving the /home</tt> directory should be safe, but it will not save you much space unless you are going to store a lot of data in the home directory of users. This can be done as follows: DIR="$(mount | grep hda3 | awk '{print $3}')" cp -Rdp /home ${DIR} rm -R  /home ln -s ${DIR}/home /home

/usr
If you need more space than would be freed up by moving /usr/local</tt>, you can move the entire /usr</tt> directory instead. Since Debian(FreeLink) installs into /usr/bin</tt> and does not typically use busybox there should be no problems. If you are using busybox(OpenLink) but still want to move /usr</tt>, you must fix the busybox symlinks.

You can move the /usr</tt> with the following commands: DIR="$(mount | grep hda3 | awk '{print $3}')" cp -Rdp /usr ${DIR} rm -R  /usr ln -s ${DIR}/usr /usr

/var
Moving /var</tt> with OpenLink is strongly recommended against, as OpenLink runs it as a ramdisk, so it will be lost and recreated on each reboot. As far as is known, FreeLink does not use this ramdisk, but moving var could also be dangerous since if something goes wrong your LS may very well fail to boot as it cannot access /var</tt> for creating the pidfiles.

However, Debian does use quite a lot of space on /var</tt>, notably in /var/lib</tt> and /var/cache</tt>. Therefore, if you are running FreeLink and are installing a lot of additional software, you may need to move /var</tt> as well. This has been confirmed to work well for several FreeLink users.

If you choose to do so, these are the commands needed to move /var</tt>: DIR="$(mount | grep hda3 | awk '{print $3}')" cp -Rdp /var ${DIR} rm -R  /var ln -s ${DIR}/var /var

You could also choose to move only <tt>/var/lib</tt> and <tt>/var/cache</tt>. You would of course need to modify the commands accordingly. -

another possibility
Bind-mount /usr and /home to /dev/hda3! (done with freelink, there might be problems with openlink, compare to the above) # /etc/fstab: static file system information. # #                      /dev/hda1       /               ext3    defaults,noatime,errors=remount-ro      0 0 proc           /proc           proc    defaults                        0 0 /dev/hda2      swap            swap    defaults                        0 0 /dev/hda3      /mnt/hda        ext3    defaults,noatime                0 0 /mnt/hda/home  /home           none    bind /mnt/hda/usr   /usr            none    bind
 * 1) Create appropriate directories on the hda3 (eg /mnt/hda/home and /mnt/hda/usr)
 * 2) Copy your files from the old location to the new ones. Be sure to preserve permissions. I did this with tar (c|x)pf.
 * 3) bind-mount the new directories in your /etc/fstab:

if that worked as whished you should somehow delete the original files on (dev/hda1)/usr and (/dev/hda1)/home to free space on that small partition: mount -t ext3 /dev/hda1 ~/some/where cd ~/some/where/usr rm -r * for home vice versa, be sure to have still an empty folder home and usr on /dev/hda1!