Blog Forum Wiki Links Contact Us NetbookUser
RunCore Pro IV SSD Transforms your ASUS EEE PC by increasing 
performance 5-40X. Your satistfaction guaranteed RunCore Pro 70mm SATA Mini PCI-e SSD
RunCore Pro IV 70mm SATA II Mini PCI-e SSD
RunCore Pro IV 2.5 Inch SATA II SSD

You are not logged in.

#1 2007-12-31 11:17:03 am

threedaymonk
Member
From: London
Registered: 2007-12-28
Posts: 35
Website

Shrinking the installation with squashfs and unionfs

I've managed to shave the installed size of eeeXubuntu down to under 1 GiB on my Eee by removing some unwanted packages (unnecessary X11 graphics drivers, OpenOffice, etc.) and compressing down my /usr directory.

I used squashfs to shrink the /usr partition, then added a writeable overlay using unionfs. It seems to work fine, and I've written a blog post about it if anyone's brave enough to try!

Offline

 

#2 2007-12-31 11:28:22 am

kevwalker
Senior Member
Registered: 2007-12-04
Posts: 123
Website

Re: Shrinking the installation with squashfs and unionfs

This sounds like something that will work on all flavors of Ubuntu. Should I worry if I'd like to "squash" my Gutsy install using this technique?

Offline

 

#3 2007-12-31 11:37:01 am

threedaymonk
Member
From: London
Registered: 2007-12-28
Posts: 35
Website

Re: Shrinking the installation with squashfs and unionfs

kevwalker wrote:

This sounds like something that will work on all flavors of Ubuntu. Should I worry if I'd like to "squash" my Gutsy install using this technique?

It should work exactly the same on any of the Ubuntu Gutsy variants.

It will work on other distributions, too, provided that they have the necessary modules, but some details will be different.

Offline

 

#4 2008-01-06 1:09:54 pm

virtual
Member
From: Toronto, Canada
Registered: 2007-08-24
Posts: 22

Re: Shrinking the installation with squashfs and unionfs

I tried this with kubuntu and it works great,
even with a kubuntu install that includes openoffice and a lot more big stuff, I still have 2.4 GiB of free space on my SSD, that is better then with the default xandros install.

Offline

 

#5 2008-01-06 5:09:45 pm

Epo
Member
Registered: 2007-12-12
Posts: 35

Re: Shrinking the installation with squashfs and unionfs

I'm trying it now. Having installed eeeXubuntu to an SDHC, writing the little endian 3 filesystem takes quite a while. I'll report back if it works.

Wow, just amazing! I did everything according to the blogpost, backing up my /usr dir to /dir.old on a bootable disc.

When I returned to eeeXubuntu, I did an df -h:

epo@eeepo:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             3.2G  2.0G  1.1G  66% /
varrun                248M   84K  248M   1% /var/run
varlock               248M     0  248M   0% /var/lock
udev                  248M   84K  248M   1% /dev
devshm                248M     0  248M   0% /dev/shm
/.filesystems/usr/usr.sqfs
                      3.6G  2.4G  1.1G  70% /usr
unionfs               3.6G  2.4G  1.1G  70% /usr

As you can see, my / is about 66%. That's the way it used to be. Because everything seems to work, I got rid of the /usr.old directory:

epo@eeepo:~$ sudo rm -rf /usr.old/

Then did another df -h:

epo@eeepo:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             3.2G  812M  2.2G  27% /
varrun                248M   84K  248M   1% /var/run
varlock               248M     0  248M   0% /var/lock
udev                  248M   84K  248M   1% /dev
devshm                248M     0  248M   0% /dev/shm
/.filesystems/usr/usr.sqfs
                      3.6G  1.2G  2.2G  36% /usr
unionfs               3.6G  1.2G  2.2G  36% /usr

Sweet! I now have 2,2GB free instead of 1,1GB!

threedaymonk: Are there things we should know?

Last edited by Epo (2008-01-06 6:06:22 pm)

Offline

 

#6 2008-01-06 6:11:47 pm

threedaymonk
Member
From: London
Registered: 2007-12-28
Posts: 35
Website

Re: Shrinking the installation with squashfs and unionfs

Epo wrote:

threedaymonk: Are there things we should know?

It's been working perfectly for me for the past week, so I've nothing to warn about.

Offline

 

#7 2008-01-07 3:15:53 am

tristan
Member
From: Brisbane, Australia
Registered: 2007-12-05
Posts: 99

Re: Shrinking the installation with squashfs and unionfs

Seems very interesting. One question I have - what if I want to remove a package which resides in /usr?

I tend to do a lot of testing and dumping of packages, and would hate to think I'm stuck with something.

Offline

 

#8 2008-01-07 8:57:42 am

threedaymonk
Member
From: London
Registered: 2007-12-28
Posts: 35
Website

Re: Shrinking the installation with squashfs and unionfs

tristan wrote:

Seems very interesting. One question I have - what if I want to remove a package which resides in /usr?

I tend to do a lot of testing and dumping of packages, and would hate to think I'm stuck with something.

You can still add and remove packages as usual. The difference is that you can't immediately reclaim the space used by packages that are in the compressed part of /usr, that is, those that were installed before squashing.

However, it is still possible to reclaim their space by recompressing the squashed partition. To do this, you'd need to repeat the mksquashfs phase and replace the existing overlay directory with a new one.

Offline

 

#9 2008-01-07 4:34:50 pm

tristan
Member
From: Brisbane, Australia
Registered: 2007-12-05
Posts: 99

Re: Shrinking the installation with squashfs and unionfs

Thanks for the info! I tried it and it didn't work though. Manually modprobing squashfs and unionfs doesn't work, I get an error that these modules don't exist. Is there something I should be installing for these modules?

Offline

 

#10 2008-01-07 8:09:08 pm

MastroOmbroj
New member
From: Minsk, Belarus
Registered: 2007-12-18
Posts: 8

Re: Shrinking the installation with squashfs and unionfs

I do almost the same thing: Ubuntu Gutsy aufs + squashfs. /usr became 770Mb down from 1.8Gb. Unfortunatly there is no mainstream r/w compressing for Linux yet.

Here is my post (on russian).

$df | grep usr-ro; du /usr-ro | tail -n 1
/usr.sqfs               767744    767744         0 100% /usr-ro
1834825 /usr-ro

You can save even more space by using squashfs-lzma. Hovewer compressing time will be much lnoger, and decompressing also slightly longer.

Last edited by MastroOmbroj (2008-01-07 8:13:13 pm)


Pearl White 4Gb. No mods yet.

Offline

 

#11 2008-01-25 12:09:48 am

enystrom
Member
Registered: 2007-12-09
Posts: 27

Re: Shrinking the installation with squashfs and unionfs

I ran into a problem where my squashed eeeXubuntu was not booting right.  Eventually I managed to figure it out, but it was really frustrating, so I'm posting my experience here with the hopes that I might save someone else the same anguish.

I shrank my /usr with squashfs and unionfs as described above several weeks ago.  It ran fine for a while, but then for some reason, possibly related to a security upgrade, it started to hang on the boot, with the progress bar stalled underneath the "b" in xubuntu.  It took me a while to figure out the problem, since it was okay if I booted into recovery mode from Grub.  I temporarily disabled the splash screen following instructions here: http://www.foogazi.com/2007/10/27/remov … sh-screen/ and eventually discovered that the culprit was likely "readahead," which it turns out has some issues with the old version of unionfs shipped in Ubuntu Gutsy, detailed here: http://thread.gmane.org/gmane.comp.file … focus=2704 

So therefore I decided to disable readahead.  I tried doing an apt-get remove of it (using the -s switch to simulate it first) but it wanted to remove the xubuntu-desktop as well, since it apparently is listed as a dependency.  So I instead renamed the scripts in /etc/rc.d then removed the symlinks using the "update-rc.d" command.  The simple thing (combining both steps) would have been to do

Code:

update-rc.d -f readahead remove
update-rc.d -f readahead-desktop remove
update-rc.d -f stop-readahead remove

These would need to be done as the superuser, of course, which is automatic if you are in recovery mode.  After that, I rebooted and everything has been fine since.  The purpose of "readahead" is to speed up the boot time, but I haven't noticed much, if any slowdown in the boot time. Even if there was, though, I'd happily live with it in order to have squashfs saving me all that space.

Offline

 

#12 2008-01-25 4:34:50 pm

threedaymonk
Member
From: London
Registered: 2007-12-28
Posts: 35
Website

Re: Shrinking the installation with squashfs and unionfs

Good catch there, enystrom. I've pre-emptively disabled readahead on my system as a precaution.

I assume that the point of readahead is to reduce the latency of making many small reads from disk. On an SSD, that shouldn't matter: there's no hardware to move around.

Offline

 

#13 2008-01-26 1:50:06 am

tristan
Member
From: Brisbane, Australia
Registered: 2007-12-05
Posts: 99

Re: Shrinking the installation with squashfs and unionfs

Thanks for that one enystrom . I applied it to my squashfs xubuntu install, which wasn't actually crashing just pausing for a long time at about 5%. This immediately fixed it and shaved ~15 seconds off the boot.

Offline

 

#14 2008-01-26 2:00:46 am

Krellan
Member
Registered: 2007-11-11
Posts: 38

Re: Shrinking the installation with squashfs and unionfs

That's great.  I started a thread earlier about doing exactly this to the default Asus install.

http://forum.eeeuser.com/viewtopic.php?id=5630

I'm guessing about 1GB of savings could be realized on the default Asus install as well.  That would increase the free space on the 4GB "disk" from 1.5GB to 2.5GB, not bad!

Offline

 

#15 2008-03-14 7:26:08 pm

MrMage
Member
Registered: 2008-01-31
Posts: 92

Re: Shrinking the installation with squashfs and unionfs

Could you tell me how fast the squashed system (xandros as well as ubuntu is) regarding boot time and general fluentness (e.g. starting firefox etc.).

Offline

 

#16 2008-03-17 1:12:44 pm

enystrom
Member
Registered: 2007-12-09
Posts: 27

Re: Shrinking the installation with squashfs and unionfs

It seems as fast as it was before.  I notice no delay in using the system.

Offline

 

#17 2008-03-18 5:50:03 am

sid77
Member
Registered: 2008-02-18
Posts: 85
Website

Re: Shrinking the installation with squashfs and unionfs

Great tutorial, I read this one some time ago and I was thinking about something similar before installing slackware. I just didn't do that because I think the writes would be overkill for the SSD.
I mean: squashfs is a readonly filesystem, how do you keep persistent changes after an update? you'd end booting up the system unionfs mounting usr.squashfs, apply changes and writing back a newer usr.squashfs. If this is done at every shutdown you kill your SSD very swiftly. On the other hand, if you could selectively do it whenever you change something to /usr but it seems a little unfeasible to me, in any case the amount of data written (a compressed usr) doesn't compare too well to the changes you'd end up mading (maybe just a small binary).

Or am I totally wrong and you can get both the squashed mount point and the changes you made without a total rewrite?


Slackintosh Linux Project Developer: http://workaround.ch/
Linux-live for powerpc: http://workaround.ch/pub/rsync/mb/linux-live/
My GnuPG key id: 0x86A91047

Offline

 

#18 2008-03-18 10:03:25 am

SeeSharp
New member
From: France
Registered: 2008-02-04
Posts: 5

Re: Shrinking the installation with squashfs and unionfs

sid77> If you do a lot of changes in /usr (ie a lot of software updates) there will be some overhead due to the data not being removed from the read-only (squashed) branch while the read/write branch continues to grow, as you suggested. The idea is to update the compressed filesystem from time to time and empty the rw /usr.

Offline

 

#19 2008-03-19 4:22:37 am

sid77
Member
Registered: 2008-02-18
Posts: 85
Website

Re: Shrinking the installation with squashfs and unionfs

ok, now it looks better smile
sounds very interesting... maybe the "resquashing" can be done at major system upgrade or via a monthly anacron job.


Slackintosh Linux Project Developer: http://workaround.ch/
Linux-live for powerpc: http://workaround.ch/pub/rsync/mb/linux-live/
My GnuPG key id: 0x86A91047

Offline

 

#20 2008-03-19 11:30:58 am

SeeSharp
New member
From: France
Registered: 2008-02-04
Posts: 5

Re: Shrinking the installation with squashfs and unionfs

Also unionfs writes special hidden 0-sized files in the rw branch, so be sure to remove them after the resquashing and before the new mount

Offline

 

#21 2008-03-21 1:58:44 pm

MrMage
Member
Registered: 2008-01-31
Posts: 92

Re: Shrinking the installation with squashfs and unionfs

SeeSharp wrote:

Also unionfs writes special hidden 0-sized files in the rw branch, so be sure to remove them after the resquashing and before the new mount

Shouldn't those not appear at all since we do a mksquashfs on the /usr directory after unionfs is already mounted on top of it?

And what is better and easier to use? Unionfs or aufs?

I am very interested in this topic and I will certainly try it out when I get my SDHC back which was bricked by the EEE.

Last edited by MrMage (2008-03-21 1:59:50 pm)

Offline

 

#22 2008-03-29 10:36:11 am

MrMage
Member
Registered: 2008-01-31
Posts: 92

Re: Shrinking the installation with squashfs and unionfs

I have tried it out now on Hardy. Its really great! I have saved 1.2 gigs of space and boot has become a bit quicker! But when using squashfs 3.3, you should add a -no-sparse option to mksquashfs, because mksquashfs in version 3.3 is said to be buggy otherwise. I have forgotten that and didn't experience problems, but you might just want to be safe.

Offline

 

#23 2008-04-08 7:42:25 am

markp1989
Senior Member
Registered: 2007-12-19
Posts: 490

Re: Shrinking the installation with squashfs and unionfs

enystrom wrote:

I ran into a problem where my squashed eeeXubuntu was not booting right.  Eventually I managed to figure it out, but it was really frustrating, so I'm posting my experience here with the hopes that I might save someone else the same anguish.

I shrank my /usr with squashfs and unionfs as described above several weeks ago.  It ran fine for a while, but then for some reason, possibly related to a security upgrade, it started to hang on the boot, with the progress bar stalled underneath the "b" in xubuntu.  It took me a while to figure out the problem, since it was okay if I booted into recovery mode from Grub.  I temporarily disabled the splash screen following instructions here: http://www.foogazi.com/2007/10/27/remov … sh-screen/ and eventually discovered that the culprit was likely "readahead," which it turns out has some issues with the old version of unionfs shipped in Ubuntu Gutsy, detailed here: http://thread.gmane.org/gmane.comp.file … focus=2704 

So therefore I decided to disable readahead.  I tried doing an apt-get remove of it (using the -s switch to simulate it first) but it wanted to remove the xubuntu-desktop as well, since it apparently is listed as a dependency.  So I instead renamed the scripts in /etc/rc.d then removed the symlinks using the "update-rc.d" command.  The simple thing (combining both steps) would have been to do

Code:

update-rc.d -f readahead remove
update-rc.d -f readahead-desktop remove
update-rc.d -f stop-readahead remove

These would need to be done as the superuser, of course, which is automatic if you are in recovery mode.  After that, I rebooted and everything has been fine since.  The purpose of "readahead" is to speed up the boot time, but I haven't noticed much, if any slowdown in the boot time. Even if there was, though, I'd happily live with it in order to have squashfs saving me all that space.

i had a similar problem . readahead was copying the entire squashfs to ram on boot,

to solve this i did  sudo mousepad /etc/readahead/boot and removed the line pointing to the squashfs

doing this on Icebuntu has made the install size under 500mb (was 700/800mb to begin with), and made boot tome 4 seconds faster!


mark@eeepc:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             3.5G  459M  2.9G  14% /
varrun                248M   60K  248M   1% /var/run
varlock               248M     0  248M   0% /var/lock
udev                  248M   76K  248M   1% /dev
devshm                248M     0  248M   0% /dev/shm
lrm                   248M   34M  215M  14% /lib/modules/2.6.22-14-generic/volatile
/tmp                  2.0M  292K  1.8M  15% /tmp
vartmp                1.0M     0  1.0M   0% /var/tmp
varlog                8.0M  656K  7.4M   9% /var/log
/.filesystems/usr/usr.sqfs
                      3.7G  646M  2.9G  18% /usr
unionfs               3.7G  646M  2.9G  18% /usr
/dev/sdb1             1.9G  486M  1.4G  26% /media/disk
mark@eeepc:~$

Are there any other folders that can be moved to squashfs to save more space?

Edit: i have also done this with /var

mark@eeepc:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             3.5G  382M  3.0G  12% /
varrun                248M   40K  248M   1% /var/run
varlock               248M     0  248M   0% /var/lock
udev                  248M   76K  248M   1% /dev
devshm                248M     0  248M   0% /dev/shm
lrm                   248M   34M  215M  14% /lib/modules/2.6.22-14-generic/volatile
/.filesystems/usr/usr.sqfs
                      3.7G  569M  3.0G  16% /usr
unionfs               3.7G  569M  3.0G  16% /usr
/.filesystems/var/var.sqfs
                      3.6G  410M  3.0G  12% /var
unionfs               3.6G  410M  3.0G  12% /var
varlog                8.0M  500K  7.6M   7% /var/log
vartmp                1.0M     0  1.0M   0% /var/tmp
/tmp                  2.0M  524K  1.5M  26% /tmp
/dev/sdb1             1.9G  2.9M  1.8G   1% /media/disk
mark@eeepc:~$

your tutorial has made a huge difference, it has almost halfed my install size, thankyou!!

not sure how well this will work with var in the long run

Last edited by markp1989 (2008-04-08 1:18:24 pm)


White 4g 701, 2gb RAM. 16gb sdhc ,Touch Screen, draft-n , tablet mod (topic=66842) eeectl 360-900mhz
Black 12g 900. Stock , running Arch, custom rc.sysinit , openbox: power button to desktop <12 sec
Desktop: E8400@4ghz (still aiming higher big_smile ) - 4gb ram - 30gb OCZ Vertex -  GeForce 8400
HTPC: E5200 @  3ghz - 4gb ram - 2 * 1.5tb hd - Geforce 7300

Offline

 

#24 2008-04-08 6:07:57 pm

markp1989
Senior Member
Registered: 2007-12-19
Posts: 490

Re: Shrinking the installation with squashfs and unionfs

would it be posible to do this to the entire file system, similar to how a live cd does with persistant mode?


White 4g 701, 2gb RAM. 16gb sdhc ,Touch Screen, draft-n , tablet mod (topic=66842) eeectl 360-900mhz
Black 12g 900. Stock , running Arch, custom rc.sysinit , openbox: power button to desktop <12 sec
Desktop: E8400@4ghz (still aiming higher big_smile ) - 4gb ram - 30gb OCZ Vertex -  GeForce 8400
HTPC: E5200 @  3ghz - 4gb ram - 2 * 1.5tb hd - Geforce 7300

Offline

 

#25 2008-04-13 7:59:55 pm

dd99
Senior Member
Registered: 2008-03-26
Posts: 665
Website

Re: Shrinking the installation with squashfs and unionfs

kevwalker wrote:

This sounds like something that will work on all flavors of Ubuntu. Should I worry if I'd like to "squash" my Gutsy install using this technique?

Hi,
It will actually work on any distribution with a Linux kernel that has the squashfs and unionfs modules available.
I did the same on Mandriva 2008.1 on an SDHC card.


dd99
Mandriva and Ubuntu pre-installed SDHC cards for the eeePC - eeePCLinux.com
"Because Linux means Freedom of Choice"

Offline

 

Board footer

Powered by PunBB 1.2.15
© Copyright 2002–2005 Rickard Andersson