Linux liposuction, or: Xubuntu in under a gig on the Eee PC

If you upgrade to kernel 2.6.29, your compressed partition won’t work. Read Squashing /usr and the 2.6.29 kernel for a guide to upgrading.

I got an Asus Eee PC for Christmas. It’s a black model with 4 GB (i.e. 3.7 GiB) of solid-state disk and 512 MiB of RAM. The specs aren’t particularly high end, obviously, but it’s cheap, small, light, and robust.

For around £200, you get a little computer with WiFi, a proper (if diminutive) keyboard, and the ability to be stuck in a bag and taken almost anywhere. It’s smaller and lighter than a hardback novel:

Asus Eee PC and a hardback novel

Plus, it comes running Linux out of the box! What’s not to like?

To be honest, I looked at the supplied distribution (Xandros) for about five minutes before wiping it and installing my preferred Linux, Ubuntu (in its XFCE variant) on there. I’ve spent the last few days tweaking it to work according to my preferences and optimally within the constraints of the hardware. There’s more to do, but I’m making progress.

As I mentioned, the internal storage is only 3.7 GiB. By default, Ubuntu takes a lot of that for itself, but it can be slimmed down quite drastically. Some of it I freed by removing unneeded packages, like the X11 drivers for graphics cards that I don’t have. Some was released by removing heavyweight software such as OpenOffice.org (I consider word processors actively harmful, but that’s a discussion for another day). Beyond that, though, I’ve delved a little deeper and given the operating system itself a bit of liposuction to take it down to under 1 GiB.

Here’s how.

I ran xdiskusage to find out where the disk space was being used most, and discovered, to my not very great surprise, that most of it (1.5 GiB) was taken up by the /usr directory. The obvious solution was to compress it, using a combination of squashfs and unionfs.

squashfs lets you compress a filesystem, but it’s read-only. unionfs, meanwhile, allows you to overlay a writeable filesystem on top to allow changes to the data. Obviously, the more you change the data, the more disk space is used, but it’s always possible to recompress and recover the space later on.

All the commands I’m going to give here need to be run as root, and I’m going to assume basic Linux competence. If it doesn’t make sense to you, you probably shouldn’t try it!

The first step is to install a couple of packages:

apt-get install squashfs-tools unionfs-tools

Then make a space for your compressed filesystem and overlay:

mkdir -p /.filesystems/usr/overlay

And compress your filesystem:

mksquashfs /usr /.filesystems/usr/usr.sqfs

Add these lines to /etc/modules:

unionfs
squashfs
loop

... and these lines to /etc/fstab:

/.filesystems/usr/usr.sqfs /usr squashfs ro,loop,nodev 0 0
unionfs /usr unionfs nodev,noatime,dirs=/.filesystems/usr/overlay=rw:/usr=ro 0 0

Next, reboot from a live distribution on a USB stick, CD, or SD card, mount the internal root partition, and move aside the old /usr directory:

mkdir /mnt/sda1
mount /dev/sda1 /mnt/sda1
mv /mnt/sda1/usr /mnt/sda1/usr.old
mkdir /mnt/sda1/usr

Reboot from the internal disk. Did it work? Then you can remove the /usr.old directory to reclaim the space.

After all that, my operating system takes only 832 MiB on disk, saving me about a gigabyte. That’s a significant improvement when there’s only 3.7 GiB to start with!

Have a look at Passerby’s comment below for a way to do it without rebooting.

Comments

  1. kota

    Wrote at 2007-12-31 20:10 UTC using Firefox 2.0.0.4 on Linux:

    As an everyday user of Xubuntu + OpenOffice, I’d like to know more about your opinion on word processors :)

    Where did you get the Eee that cheap? I thought it was around $1000.

    Cheers!
  2. Russ Stewart

    Wrote at 2008-01-02 03:52 UTC using Firefox 2.0.0.11 on Linux:

    Thanks for the info! I’m squashing as I type this. Has this bogged your system down noticeably?
  3. Paul Battley

    Wrote at 2008-01-02 18:52 UTC using Firefox 2.0.0.11 on Linux:

    Russ, I haven’t noticed any significant effects, but I didn’t time things before and afterwards, so I can’t give any numbers.
  4. Epo

    Wrote at 2008-01-06 23:08 UTC using Firefox 2.0.0.11 on Linux:

    Here’s my experience with eeeXubuntu: http://forum.eeeuser.com/viewtopic.php?pid=81110#p81110
  5. Barry

    Wrote at 2008-01-12 17:26 UTC using Firefox 2.0.0.11 on Linux:

    Paul,

    Thanks for the info, I have just squashed my /usr directory on my 2Gb eeepc and now have a reported 1.1 Gb available. As you suggested I created the compressed file on a memory stick and then having made a backup copy of the live /usr directory wrote the compressed file back to the SSD. Works a treat.

    The only thing that is worth saying is that people should make sure that they have a large enough memory stick to copy the live /usr directory out to. Mine consumed 1.2 Mb of the stick’s memory.

    Also I have not noticed any decrease in performance or increase in boot time.

    May I ask how you would suggest that I go about recompressing the /usr directory in time. I have just carried out another update and used another 18Mb from the SSD.

    Thanks again, Barry
  6. Paul Battley

    Wrote at 2008-01-13 12:10 UTC using Firefox 2.0.0.11 on Linux:

    To recompress, the most straightforward way would be to repeat the mksquashfs step to a second file, then boot from a USB drive and copy the new squashed file over the old one. Remove and recreate the overlay directory and reboot from the internal disk.
  7. stanbogdan

    Wrote at 2008-02-06 09:13 UTC using Firefox 2.0.0.11 on Linux:

    I came up with the same idea independently and as i read this post I wanted to make a comment about the speed of the system after you squash /usr : It actually increased significantly! Reasons (short version): decompressing data is faster than reading it from the hard drive, in most current computers, especially when you have multiple programs reading from the disk, causing thrashing, and/or when the data on the disk is fragmented. You can read more details about what i did and the results i had on http://forums.gentoo.org/viewtopic-p-4732709.html#4732709
  8. Jim - 406 NotAcceptable

    Wrote at 2008-03-31 13:35 UTC using Firefox 2.0.0.6 on Linux:

    I am quite shocked as to this being faster than running a non-compressed drive. Yo would expect a compressed drive to be slower, as it has to be decompressed by the processor—and the Eee doesn’t have the fastest of processors. Whilst degragmentation isn’t that much of an issue with a solid state drive, as the access times are negible.
  9. mark

    Wrote at 2008-04-08 10:33 UTC using Unknown browser on Linux:

    thanks for the how to, im in the process of doing it on my icebuntu install…installed size is about 800mb, and /usr is currently over 500mb of that, so it will be interesting to see how much it helps, are there any other directorys that i can do this to?
  10. mark

    Wrote at 2008-04-08 11:06 UTC using Unknown browser on Linux:

    after doing this to Icebuntu my install size is 500mb!! i wonder if it is possible to do this to any other folders to save even more space
  11. Dan Fekete

    Wrote at 2008-05-17 05:41 UTC using Firefox 2.0.0.14 on Linux:

    Has anyone tried this with the squashfs-LZMA patch? If so, what was the resulting compression ratio?

    PS – thanks for the great howto, I’m about to try it…
  12. Passerby

    Wrote at 2008-05-22 21:26 UTC using Firefox 3.0 on Windows XP:

    To make things a little easier, you can get rid of the rebooting stuff by switching to runlevel 1 on your running system and doing the work there.

    Just replace the following section

    Next, reboot from a live distribution on a USB stick, CD, or SD card, mount the internal root partition, and move aside the old /usr directory:

    mkdir /mnt/sda1
    mount /dev/sda1 /mnt/sda1
    mv /mnt/sda1/usr /mnt/sda1/usr.old
    mkdir /mnt/sda1/usr

    with the following:

    Switch to runlevel 1:
    init 1
    (Ubuntu will prompt you what to do—choose opening a root shell)

    Move aside the old /usr directory:
    mv /usr /usr.old

    Test whether you previously edited fstab successfully by typing:
    mount -a

    If you get error messages or your /usr directory shows up empty, either fix your fstab or undo the changes before rebooting.

    Instead of the final reboot, you could also just return to runlevel 3 via:
    init 3

    Thanks for the tutorial; it helped me shrink /usr from 1,9 GB to 0,8GB and /var from 180MB to 50MB.
  13. Zerjillo

    Wrote at 2008-07-09 08:04 UTC using Firefox 3.0 on Linux:

    Thanks for all the info, including the comments. I think you should improve the post with his suggestions. Much more efficient to switch to runlevel 1 to make the directory change.

    From a 1.98GB usr directory I finally came up with a 668 MB compressed filesystem (almost 66% reduction!).

    Greetings

    Zerjillo
  14. sig

    Wrote at 2008-08-10 15:35 UTC using Firefox 2.0.0.4 on Linux:

    This worked for me on Xubuntu, but now I cannot configure my VPN through network manager. I cannot even get the VPN to start. I errors out.

    Anyone else have effects around compressing and then trying features with network manager? I suspect it is NM and not network-manager-openvpn

    Cheers
  15. Martin

    Wrote at 2008-09-05 13:51 UTC using Firefox 3.0.1 on Mac OS X:

    Worked nicely for me following Passerby’s hints on doing it without a reboot. More than doubled my free space…

    One very minor and obvious thing to add to his instructions – after moving the old /usr out of the way you need to ‘mkdir /usr’ to allow the mount to work, otherwise you get an error saying the mount point doesn’t exist.
  16. Christian

    Wrote at 2008-09-12 14:21 UTC using Firefox 3.0.1 on Linux:

    Hi

    I have a 701 4gb running Ubuntu eee HH. I followed the instructions above and all was going well until I ran the compression command. I have posted the output below, but suffice to say it said that I did not have enough free space. Any ideas? Thanks!

    christian@christian-laptop:~$ sudo mkdir -p /.filesystems/usr/overlay
    christian@christian-laptop:~$ sudo mksquashfs /usr /.filesystems/usr/usr.sqfs
    Parallel mksquashfs: Using 1 processor
    Creating little endian 3.1 filesystem on /.filesystems/usr/usr.sqfs, block size 131072.
    [====== ] 11611/108808 10%[====== ] 11612/108808 10%[==================================== ] 68409/108808 62%Write on destination failed: No space left on device
    [==================================== ] 69343/108808 63%christian@christian-laptop:~$ ssudo mv -v array.list /etc/apt/sources.list.d/[sudo] password for christian:
    mv: cannot stat `array.list’: No such file or directory
  17. Paul Battley

    Wrote at 2008-09-13 14:58 UTC using Firefox 3.0.1 on Linux:

    Christian, it’s possible, but a bit hairy. I’ve done it before.

    You’ll have to put the output of mksquashfs on an external storage medium (e.g. an SD card), change to runlevel 1 (see Passerby’s comment above), and juggle the old and new .sqfs files.
  18. christian

    Wrote at 2008-09-14 18:04 UTC using Firefox 3.0.1 on Mac OS X:

    Thanks Paul. I will try and play around with a memory card and see what I can do. A user on eeeuser suggested “e.g. mksquashfs /usr /media/disk/usr.sqfs then mv /media/disk/usr.sqfs /”

    I was under the impression that this would work on the eee pc. i suppose that I simply did not have enough space, but then i have added virtually nothing to my system. Did you run the above on a totally fresh install? Could I re-install Ubuntu eee and do it from that point and achieve your results above? I suppose I confused as to why it did not work. I’m really a noobie, but am enjoying learning how to do all of this so thanks for the help and patience.

    Best
  19. Shawn Reist

    Wrote at 2008-09-14 21:00 UTC using Firefox 3.0.1 on Linux:

    Hello,

    I am reliably new to Linux but have been playing with it for a year and I purchased a EeePC and love it.. used Zandros for last 5 months.. handy-caped and fed up I installed Ubuntu 8.04 and am in the process of tweaking.

    Performed the above routine squashed /usr and unionfs;
    managed to make .sqfs file had 90 MB free
    rebooted … things worked and then I did a second reboot played some and then decided to delete /usr.old

    My system still says I have 90 MB free even though I can determine that I have 40,163 items, totalling 2.1 GB on the physical HD

    Have I done something wrong?
  20. Paul Battley

    Wrote at 2008-09-14 23:04 UTC using Firefox 3.0.1 on Linux:

    Christian: I did it on a fresh install of Xubuntu. Significantly, that takes a lot less space than regular Ubuntu (no OpenOffice by default, for example), so I had enough room on the disk to juggle it.

    Shawn: that’s a bit odd. It sounds like /usr.old hasn’t been reclaimed. What do the outputs of mount and df -h say?
  21. Shawn Reist

    Wrote at 2008-09-15 00:41 UTC using Firefox 3.0.1 on Linux:

    Here is the information from mount and df -h. Hope this helps I am looking at this .gvfs and scratching my head.

    shawn@EeePC:~$ mount
    proc on /proc type proc (rw,noexec,nosuid,nodev)
    /sys on /sys type sysfs (rw,noexec,nosuid,nodev)
    varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
    varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
    udev on /dev type tmpfs (rw,mode=0755)
    devshm on /dev/shm type tmpfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    /.filesystems/usr/usr.sqfs on /usr type squashfs (ro,nodev,loop=/dev/loop0)
    securityfs on /sys/kernel/security type securityfs (rw)
    gvfs-fuse-daemon on /home/shawn/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=shawn)

    shawn@EeePC:~$ df -h
    Filesystem Size Used Avail Use% Mounted on
    varrun 1010M 212K 1010M 1% /var/run
    varlock 1010M 0 1010M 0% /var/lock
    udev 1010M 36K 1010M 1% /dev
    devshm 1010M 12K 1010M 1% /dev/shm
    /.filesystems/usr/usr.sqfs
    666M 666M 0 100% /usr
    gvfs-fuse-daemon 3.7G 3.4G 100M 98% /home/shawn/.gvfs
    shawn@EeePC:~$
  22. Shawn Reist

    Wrote at 2008-09-15 02:20 UTC using Firefox 3.0.1 on Linux:

    not sure but I shall post the contents of the */etc/modules* and */etc/fstab* files.

    and on the off chance how to I reverse this since I deleted the /usr.old directory

    I do have 2 GB of Ram.

    Modules
    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with ”#” are ignored.

    unionfs
    squashfs
    loop
    fuse
    lp
    pciehp pciehp_debug=1 pciehp_force=1

    fstab
    #
    proc /proc proc defaults 0 0
    # /dev/sda1
    UUID=57480a3f-e7db-4a5e-9fca-7df45f5a7d9d / ext2 defaults,noatime,errors=remount-ro 0 1
    # UUID=bdd81984-3f98-4e3a-81fe-1b9cd53862d4 / ext2 relatime,errors=remount-ro 0 1
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
    /.filesystems/usr/usr.sqfs /usr squashfs ro,loop,nodev 0 0
    unionfs /usr unionfs nodev,noatime,dirs=/.filesystems/usr/overlay=rw:/usr=ro 0 0

    # swapfile
    # /swapfile /dev/sdb1swap defaults00
  23. Mordechai Vanunu

    Wrote at 2008-09-28 12:03 UTC using Firefox 3.0.3 on Linux:

    Hi.

    I just tried to do this on my 4gsurf, but mksquashfs carries the compression through to 71% and just hangs there, no output whatsoever. What could be wrong?
  24. Mordechai Vanunu

    Wrote at 2008-10-05 03:16 UTC using Firefox 3.0.3 on Linux:

    I found out what was going wrong. This is a bug which is only hit when dealing with sparse files. To avoid the hang specify -no-sparse on the mksquashfs command line, and mksquashfs will not detect any sparse files, therefore avoiding the problem.
  25. Danielle Smith

    Wrote at 2008-10-31 10:18 UTC using Firefox 3.0.3 on Linux:

    I have the same problem as Shawn – my /usr.old is not being reclaimed. 701 4G here.
  26. Portablejim

    Wrote at 2008-11-10 05:08 UTC using Firefox 3.0.3 on Linux:

    Why the reboot, or go down or runlevel 1? I got root terminal and and moved it over in root terminal. I just had to be careful while /usr was not there not to run any programs.

    What I did to move over (as root):
    mv /usr /usr.old
    mkdir /usr
    mount -a
  27. Nicholas Polydor

    Wrote at 2008-11-20 01:37 UTC using Firefox 3.0.4 on Windows XP:

    Yep, I have the same problem as Shawn and Danielle. Running Ubuntu 8.10 Intrepid on an eeePC 901, with the 4GB SSD (sda1) set as bootable and with the mount-point as / , and the 16GB SSD (sda2) with the mount-point as /home . Both are using ext3.

    I also tried Passerby’s suggestion several times but Ubuntu hung during the runlevel switching.
  28. Shawn Reist

    Wrote at 2008-11-26 05:35 UTC using Firefox 3.0.4 on Linux:

    Ok … I figured out how and why the space was not being reclaimed.

    I had to log in as root and then I could access the trash bin and empty it… for some reason even if I did a sudo bash and did a shift-delete, the files ended up in the trash bin and not gone from the system.

    total free space was 2.1 gig.

    I just finished installing Ubuntu 8.10 and found it did not recognize the 16gig SDHC card I have and reinstalled 8.04 and will be crunching the system once I have tweaked everything.
  29. Devin Younge

    Wrote at 2008-11-29 01:08 UTC using Firefox 3.0.4 on Windows XP:

    Great fix, man. Freed up about 1.2 Gb on my 4G eee. Wasn’t sure about doing this, since i’m a linux newbie, but it worked perfectly. It boots a bit slower now, over a minute, but i think i can get that fixed.
  30. Chris

    Wrote at 2008-12-12 13:39 UTC using Firefox 3.0.4 on Windows XP:

    Hi,
    Thanks for the guide, it works great but I’ve tried this method twice and both times have been successful at getting ubuntu-eee installed with it into the 2gb flash drive on the eee, but unionfs seems to conflict with my ext3 journal. If I make any changes to the drive, it corrupts the filesystem horribly. My second install is dying fast, window contents do not show up, wifi and wired networking are broken, I’ve hit busybox and the fsck error screen on boot many times. After using the machine for an hour or so, my ssd mysteriously switches into read-only mode and applications start crashing.
    Has anyone else run into this problem?
    Should I be using ext2 instead of ext3?
    I had to install ubuntu to the 4gb flash card then copy the partition over to the ssd once I had compressed it, then modify fstab to get it bootable. Could this have caused the problem?
    Should I try a full featured kernel like ubuntu 8.10 instead of ubuntu-eee?

    Any feedback would be greatly appreciated. Thanks.

    (btw if you do get stuck at the hit ctrl-D to reboot screen, edit your grub boot line to include init=/bin/bash then run fsck /dev/sda1 from the terminal that comes up)
  31. henny_316

    Wrote at 2009-01-01 10:00 UTC using Firefox 3.0.5 on Linux:

    I made it to the init 1 step, the first time I didn’t have the missing “mkdir /usr” step. I used init 3 to come back into the desktop, found the missing step and went back into init 1. Now when I try the mv /usr /usr.old I get an “in use” error. Help please?
  32. henny_316

    Wrote at 2009-01-01 10:23 UTC using Firefox 3.0.5 on Linux:

    Sorry, it’s a “device busy” not the ‘in use’ I originally typed.
  33. Macchi

    Wrote at 2009-01-03 13:16 UTC using Firefox 2.0.0.20 on Windows XP:

    Thanks a lot for the guide, it saved saved me time and space, besides refreshing several braincells after several lazy days around xmas. It is a good example of the power of these systems we are playing with.

    I simply booted the EEE 701 into single user mode, (the recovery alternative on GRUB at Ubuntu) and could perform changes, compress /usr and test that the compression and unionfs worked fine. Later I rebooted and verified that this solution saved 1.1GB storage on a 4GB drive! Now I have 2.3 GB free space despite an almost full Ubuntu 8.10 desktop. Now I have to solve software glitches of the built in microphone.


    /M
  34. Eimermann

    Wrote at 2009-01-09 10:06 UTC using Firefox 3.0.5 on Linux:

    Thanks for the great instruction, Paul. It freed about 1,5 gigs of space on my eeepc 4g.
    But now I have problems installing updates to Ubuntu. I’m running Ubuntu 8.04 and on installing updates everything works fine until the very last step:
    “Processing triggers for libc6 …
    ldconfig deferred processing now taking place”
    My eee has been running at a 100% cpu usage for 12+ hrs and it’s still not done.
    What could be the problem?
    Thanks.
  35. Ovoid

    Wrote at 2009-01-12 02:06 UTC using Firefox 3.0.5 on Linux:

    Well… I have tryed on 701 with 8.10, but it seems that the big problem is on fstab.
    I don’t know how to fix this, but simply does not mount the new ./filesystems… as /usr. I check the spell and stuff, but on boot, the message is the same: missing file that should be in /usr. Fortunatly, I did not delete usr.old so I get every thing back easy. But I still want to try this! Any sugestion?
  36. DaVince

    Wrote at 2009-01-22 15:41 UTC using Firefox 3.0.5 on Linux:

    Unbelievable! It squashed my 1700 MB into 600 MB! Time to get this squashed FS recognized and running. :)
  37. ordamon

    Wrote at 2009-02-02 19:03 UTC using Firefox 3.0.5 on Windows XP:

    got the same problem as henny_316
    any ideas ?
  38. Nigel Healy

    Wrote at 2009-02-02 23:34 UTC using Firefox 3.0.5 on Linux:

    Worked for me with Ubuntu 8.10 on an Asus EEE 901, but the init 1 never got to shell, and booting off LiveCD requires to make temporary mount points. So simplest method is to reboot to recovery mode root to move the /usr.
    In my case the /usr shrunk from 1660MB to 590MB so a 2.8x reduction of 1070MB. Given the precise syntax of the /etc/fstab, my full method with least steps/typing below.

    open shell

    become root by command sudo -i

    apt-get install squashfs-tools unionfs-tools

    add following lines to /etc/modules, noting loop may already be there
    squashfs
    unionfs
    loop

    mkdir -p /.filesystems/usr/overlay

    echo /mksquashfs /usr /.filesystems/usr/usr.sqfs >/mysquash

    add following lines (commented out) to end of fstab
    #/.filesystems/usr/usr.sqfs /usr squashfs ro,loop,nodev 0 0
    #unionfs /usr unionfs nodev,noatime,dirs=/.filesystems/usr/overlay=rw:/usr=ro 0 0

    exit being root, reboot into recovery-mode, be root in shell
    type as root, this command will take some minutes and show % progress, check it doesn’t complain or bomb
    sh /mysquash
    mv /usr /usr.old
    mkdir /usr

    remove the comments (the #) in /etc/fstab for the two lines added above, use vi or nano editor (nano will work, vi may not)

    type as root
    mount -a
    check no errors with above
    reboot and run as normally, check it all works out

    If does not work then reboot into recovery mode type
    mv /usr /usr.bad
    mv /usr.old /usr
    and reboot back to normal and figure it out
    Once satisfied is working, then as root, delete the /usr.old , e.g. via command
    sudo rm -rf /usr.old

    Enjoy the reduced disk usage! and the improved performance!
  39. Steve Hanov

    Wrote at 2009-02-09 14:01 UTC using Firefox 3.0.6 on Windows XP:

    Okay, after a month of updates and installing programs I am now wasting hundreds of megabytes of space again. Can someone post some commands for updating the squashed filesystem?
  40. Nigel Healy

    Wrote at 2009-02-15 23:42 UTC using Firefox 3.0.6 on Linux:

    Steve once the filesystem is mounted, you can make a fresh squashed copy of it and move to that?

    I’ve not followed this (yet) but something like this:
    – boot as normal, so your /etc/fstab is being used and your presented /usr is your unionfs ontop of the squashfs with all your updated changed to /usr – as root type mksquashfs /usr /.filesystems/usr/usr.sqfs.new – reboot into recovery kernel, root, type these commands, hopefully they make sense if you’ve followed the above instructions.
    mv /.filesystems/usr/usr.sqfs /.filesystems/usr/usr.sqfs.old
    mv /.filesystems/usr/usr.sqfs.new /.filesystems/usr/usr.sqfs
    mv /.filesystems/usr/overlay /.filesystems/usr/overlay.old
    mkdir -p /.filesystems/usr/overlay
    mount -a
    – then see if all works, exit boot as normal, let it run for a while, and when you’re sure, then as root
    rm /.filesystems/usr/usr.sqfs.old
    rm /.filesystems/usr/overlay.old
    – then you’ve should realise the disk savings.

    I’m wondering though if the above is that good an idea on a small disk environment, because you always have to keep sufficient free disk space of the size of your compress /usr to be able to make a new squashed copy. Is there a method which just pushes the overlayed /usr files into the squashed /usr, i.e. apply the unionfs changes? That would then require less free disk space. Alternatively you can make the new files on an external disk, copy the existing to the external disk and then move the external to the original place. Itself not that slick….
  41. Jay Adkisson

    Wrote at 2009-03-05 16:26 UTC using Firefox 3.0.6 on Linux:

    Hey all,

    I used this method to squash /var, and I thought it worked beautifully, until…

    When I boot normally, several boot processes complain about not being able to delete files in /var (like `lock’, for example). Then it just sort of stops and doesn’t even give me a terminal. I have to hard reset.

    But when I boot into recovery mode, everything mounts fine, and some files even appear in /.filesystems/var/overlay. And the weirdest part is, when I finally select `Resume’ to boot normally, it boots fine!

    I tried changing ownership of /.fileystem and subdirectories to root, but that didn’t change anything.

    Ideas?
  42. Paul Battley

    Wrote at 2009-03-05 17:03 UTC using Firefox 3.0.6 on Linux:

    I’ve not tried compressing /var, nor would I, to be honest. Compressing /usr is safe because it’s not needed to boot, unlike /var. Furthermore, the contents of /var are by their nature variable, so you won’t gain much improvement by compressing it.
  43. Jay Adkisson

    Wrote at 2009-03-05 19:32 UTC using Firefox 3.0.6 on Linux:

    OK, thanks – I unsquashed /var, and squashed /usr, and it’s working great so far. Thanks for the guide!
    —Jay
  44. Jay Adkisson

    Wrote at 2009-03-06 00:29 UTC using Firefox 3.0.6 on Linux:

    Apologies for the double post, but I also found a slight but with an easy fix:

    I bought seventhstring’s Transcribe! not too long ago, which is proprietary software distributed with only a binary. For that reason, I prefer to keep the binary in my home folder so it gets backed up with all the rest of my data – but put a hardlink in /usr/bin so it’s easy to run. The command “sudo ln transcribe /usr/bin/transcribe” returns an error, since this would be a “cross-device link” (since the squashfs business is considered a different “device”).

    The solution: just put the link in the overlay instead at /.filesystems/usr/overlay/bin (and obviously create that directory if it doesn’t exist). Then the command should work when run from the terminal.

    In essence: if for some reason you can’t write something to /usr, it works if you put it in the overlay instead.
  45. Paul Battley

    Wrote at 2009-03-06 00:37 UTC using Firefox 3.0.6 on Linux:

    Jay, you could just use ln -s to make a symbolic link: those work across devices.

    Even better, put the executable in ~/bin and add that to your path.
  46. JessT

    Wrote at 2009-03-29 03:41 UTC using Firefox 3.0.7 on Windows XP:

    G’day,

    This is a great, straight-forward guide, thank you very much!

    A note for anyone who wants to update their kernel to the latest 2.6.29 stable, your squashfs filesystem will NOT be compatible, and thus, unreadable.

    Notes on why are here (http://linux.derkeiler.com/Mailing-Lists/Kernel/2009-01/msg05708.html)

    To get it to work, you’ll have to un-squash it with unsquashfs, then re-squash it with the latest (4.0) version (ie, the version of squashfs in 2.6.29).

    Notes on where to get this are here (http://www.gossamer-threads.com/lists/linux/kernel/1018951)

    I haven’t done this myself yet (just posting this before I forget), but, I believe that with the new 4.0 version, the process will be exactly the same as this article states.

    Good luck, and enjoy!
  47. Mike Brown

    Wrote at 2009-04-29 01:23 UTC using Firefox 3.0.9 on Linux:

    FYI, the unionfs-tools package is not part of Ubuntu Jaunty 9.04 (including Xubuntu).

    It looks like the the unionfs part of it may have been moved into the kernel. Whatever, I was able to follow the tutorial using Xubuntu Jaunty without having to install unionfs-tools first (because I couldn’t!!!) and it still worked just fine.

    Cheers,
    – Mike
  48. Martin

    Wrote at 2009-07-20 12:34 UTC using Opera 9.27 on Mac OS X:

    It worked for me and saved about 1.5GB. The only thing is, I was so short on space I had to save the usr.sqfs onto the second memory card sdb1 (i.e. has to be mounted to appear on /).

    It works, but wouldn’t my setup be safer if I moved the .sqfs file back onto sda1 instead of sdb1? Should be fairly straightforward if I just do a mv and the change the paths in /etc/fstab… I hope…
  49. asyik

    Wrote at 2009-09-02 15:28 UTC using Firefox 3.0.8 on Linux:

    it works in my eee pc 701 running jaunty. thanks

    BUT how to install printer driver after squashing? Normally ubuntu will autodetect if usb cable from the printer connected to ubuntu machine and download the appropriate drivers. I know i can copy the files/ drivers needed into the overlay. But i do not know which files to copy. Can somebody show me how pelase.
  50. Portablejim

    Wrote at 2010-02-06 01:21 UTC using Firefox 3.5.7 on Linux:

    Thanks for the title as it makes finding this a bliss (i.e. google ‘linux liposuction’).

    I use this page as a reference on how to use Squash/Unionfs.
  51. Brahma Bhat

    Wrote at 2010-11-07 18:23 UTC using Chrome 7.0.517.44 on Windows 7:

    I had tried it on 8.04. It works great

    I have now moved to karmic and there is no Unionfs support in karmic.

    It would be great if you could write instructions to use squashfs with aufs on Karmic