My *nix world

Generalization for "Speed-up system by SquashFs"

In the previous post I wrote about how to speed-up your (Gentoo) system by using the SquashFS filesystem.

I had described shortly an experiment of compressing the /usr folder into a SquashFS image (which will become smaller and will boost your system) and using that image instead of the /usr original folder.

The steps I had used for /usr example can be generalized into a more abstract version which in turn can be used for almost any /folder you want to squash.

Basically to speed-up system by SquashFs or any arbitrary folder you must do the following steps:

  • create a "repository" where you will save all your SquashFS images (ex: /squashed/{usr,sbin,opt} etc)
  • optional : create manually the SquashFS images for all your folders you want to squash (ex: /usr , /sbin, /opt, etc)
  • we will have a generic runscript /etc/init.d/squashd that will help us to mount/unmount the SquashFS images at boot/shutdown time
  • for every / we want to squash and mount/unmount its image at boot/shutdown time:
    • we'll have a dedicated symlink in /etc/init.d/ that will point to the /etc/init.d/squashd generic runscript;
    • for those dedicated symlinks we must to have a corresponding /etc/conf.d/squash- configuration files which will help us to specify how the generic squashd script should work for our particular .
    • we'll have to create a corresponding service with the help of rc-update

So, what are the steps?

Step 1: create a /squashed folder in your root.

Step 2: for every you want to squash create a corresponding subdirectory in /squashed folder

ex: /squashed/{usr,sbin,opt} etc

Step 3A: create the generic /etc/init.d/squashd runscript as following:


Step 3B: for every you want to squash create a symlink from /etc/init.d/squashd to /etc/init.d/squash-

ex: ln -s /etc/init.d/squashd /etc/init.d/squash-

Step 4: for every you want to squash create a /etc/conf.d/squash- configuration file having the following content:

Note: in the above configuration file replace the appearance of with the full path of your particular folder.

Step 5: for all SquashFS images of you want to be automatically mounted/unmounted at boot/shutdown time create a service with the default/boot runlevel as following:

For exemple, I had created squash-usr service with the boot runlevel, squash-opt respectively squash-sbin with the default runlevel.

Note: when starting the services they will check if the SquashFS image of is already created and if not then it will take care by itself on that, so it will be not necessary to do it manually by yourself (unless you want that for particular reasons).

Warning: before doing anything backup your data ;o)

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

 
The following two tabs change content below.
Generalization for "Speed-up system by SquashFs"

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Generalization for "Speed-up system by SquashFs"

Latest posts by Eugen Mihailescu (see all)

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: