compress /usr using squashfs

Hi everyone,

                                   I have built an image using SUSE STUDIO with all the applications that I need and everything is working fine.The size of the OS after installing is 2.5 GB but I want to still decrease the size as I have only 4 GB of flash. When I was going through some thin client OS articles it was written that squashfs has been used as the file system which compresses the files and also makes it read-only.So I want to know is it possible to compress /usr with squashfs.

I have tried the following article.

SquashFS HOWTO. and did the following steps.

#mksquashfs /usr /usr.sqsh
#mv /usr /usr.bak
#mkdir /usr
Then mount the /usr in fstab with the following entry.

/usr.sqsh /usr squashfs ro,defaults 0 0

After restarting the system doesn’t boot.

OpenSUSE 12.3 with XFCE DE.

Thanks in Advance.

A pure guess.

Try adding “squashfs” to the list of modules for the “initrd”. That’s in a line near the top of “/etc/sysconfig/kernel”.

Then run “mkinitrd”.

And then see if you can get it to work.

Could you be more clear,please?

The kernel cannot read and mount a squashfs file system until the “squashfs” module is loaded. Since “/usr” is mounted early during boot, that probably requires that the kernel module be part of the “initrd” file that is loaded early in booting.

You can edit the file “/etc/sysconfig/kernel” using the Yast “/etc/sysconfig” editor. The hints that Yast gives should help you find what you need. There’s a list of kernel modules to include. It might be the empty list. Try adding “squashfs” to that list.

I am not certain that will solve your problem. But it should be the first step.

After editing, it is necessary to then run “mkinitrd”. If you use Yast for the editing, I’m pretty sure that it automatically runs “mkinitrd” for you.

Best would be to put the system back as it was before you started. Make the suggested changes, then try again with using squashfs.

When you boot a live KDE or similar system, it does use “squashfs”. However, it also creates a ramdisk with an overlay. That way, you can make changes – write to the file system, and the changes go to the ramdisk. I don’t know whether you will also need that.

If you are just looking for a bootable USB with XFCE, then try the “Rescue” image for 12.3. It might be a lot easier than rolling your own.

This is the error that I get " run-init : /sbin/init no such file or directory

Even though If I add squashfs to the file it is not booting up.When I compress /usr/share directory and mount it,the system is booting up.Any guesses on the problem.

Not really.

Once upon a time, many years ago, everything needed for booting was in “/bin”, “/lib” and “/etc”. Hard drive capacity was small, so it was expected that “/usr” would have to be mounted as a separate file system.

Over the years, as disks have become larger, there has been a move to do away with a separate “/bin”. And, when that is complete, you won’t be able to have “/usr” as a separate file system. We are part way through those changes. Solaris did away with “/bin” several decades ago – on solaris, “/bin” is a symlink to “/usr/bin”.

You are fighting against the way that linux is evolving.

The distributed live systems (KDE, Gnome, Rescue) do use mostly squashfs. But they use a specially designed “initrd” that has all commands needed to get things going and to mount the squashfs file system. You could perhaps unpack the “initrd” from one of those, to get an idea as to what is needed.

Personally, I don’t think it worth the effort. If I want a small portable linux-on-a-usb, I’ll use an existing live system, or perhaps use the UBCD (Ultimate Boot CD).