Here is a short howto compress the /usr directory in order to save space on your EEE SSD. The /usr directory is the bigest directory. You can save more than 1GB out of the 4GB available.
Introduction
Here is a short howto to compress your /usr directory in order to save more than 1Gb. On my EEE, my /usr folder was 2.3Gb and it’s now compressed to 900Mb leaving 2Gb free on the SSD. I made this tutorial especially for the EEE but it should work with any PC running mandriva 2008.1.
I assume that you already have a running and stable mandriva 2008.1 with mksquashfs tools installed and all the software you need on your EEE.
The compressed /usr is made of two elements : a compressed read only directory with squashfs combined with a writable unionfs. Any change to the /usr will be stored uncompressed in the unionfs filesystem.
You need a USB hard-drive to compress the /usr.
Log in as the super user et mount your USB disk on /mnt
Save/restore your SSD
Before going any further, you should make a full backup of the whole SSD.
This command can do the job :
# dd if=/dev/sda of=/mnt/sav_eee bs=64k
If anything goes wrong, you can restore your previous state with the following command :
# dd if=/mnt/sav_eee of=/dev/sda bs=64k
Create the compressed /usr
Compress the /usr with mksquashfs :
# cd /usr
# mksquashfs * /mnt/usr.sqfs
Create the following mount points :
Here is a short howto to compress your /usr directory in order to save more than 1Gb. On my EEE, my /usr folder was 2.3Gb and it’s now compressed to 900Mb leaving 2Gb free on the SSD.
I assume that you already have a running mandriva 2008.1 with mksquashfs tools installed.
You need a USB hard-drive to compress the /usr.
Log in as the super user et mount your USB disk on /mnt
Compress the /usr with mksquashfs :
# cd /usr
# mksquashfs * /mnt/usr.sqfs
Create the following mount points :
# mkdir /usr.sq /usr.un
Download this tgz and extract it at the root of the filesystem :
# cd /
# tar xvfz scripts_compressed_usr_2008.1.tgz
This tgz contains these system files : functions, halt and rc.sysinit modified in order to handle the compressed /usr.
Time now to remove the /usr…
# init 1
# rm -rf /usr
# mkdir /usr
Finally copy the compressed usr.sqfs at the root of the filesystem :
# cp /mnt/usr.sqfs /
In order to be sure that it’s ok, try the following commands :
# modprobe loop
# modprobe squashfs
# modprobe unionfs
# mount -o loop -t squashfs /usr.sqfs /usr.sq
# mount -o dirs=/usr.un=rw:/usr.sq=ro -t unionfs unionfs /usr
You should have your files in the /usr… Overwise, something went wrong.
BEWARE : Some system updates can crunch the “functions, halt and rc.sysinit” files. You should keep a copy of these files and check them after any upgrade.
Maintaining the compressed /usr
If your /usr.un directory is full of new files, you can move them to a new compressed /usr.
Create the /mnt/usr.sqfs with the earlier commands:
# cd /usr
# mksquashfs * /mnt/usr.sqfs
Switch to runlevel 1 and unmount the /usr :
# init 1
# umount /usr
# umount /usr.sq
Remove any files in the /usr.un directory :
# cd /usr
# rm -rf *
Replace the /usr.sqfs file with the newly created one.
# cp /mnt/usr.sqfs /
Mount the compressed /usr :
# mount -o loop -t squashfs /usr.sqfs /usr.sq
# mount -o dirs=/usr.un=rw:/usr.sq=ro -t unionfs unionfs /usr
Switch to runlevel 5
# init 5
How this affects performance? Will my little eee became slow with this? Or it’s a win-win relation?
Thanks for the tip!
I use it on my EEE 701 since I bought it in january 2008. I didn’t notice major performance drawback.
I’m about to install mandriva 2009 on my EEE-PC a will re-apply this mod.
Hmm, seems interesting! I will try it when I manage to install Mandriva One 2009…