Novell Home

HowTo: Install the squashfs file system on SUSE 9.2

Novell Cool Solutions: Feature
By Stomfi

Digg This - Slashdot This

Posted: 10 May 2005
 

StomfiLearning to use Linux at Home and Work
Welcome to my ongoing series of HowTo articles designed to help Linux newbies get comfortable with Linux. Before trying any of these HowTos, take a few minutes to study the prerequisites so you can hit the ground running.
--Stomfi

There has been a lot of talk about the squashfs file system in the Linux magazines of late, and how it will probably find a place into the kernel. At the moment it is not there, and to get it you have to install it yourself.

What is squashfs?, asks my mate Paul. To quote the blurb at http://squashfs.sourceforge.net/ "Squashfs is a compressed read-only filesystem for Linux. Squashfs is intended for general read-only filesystem use, for archival use (i.e. in cases where a .tar.gz file may be used), and in constrained block device/memory systems (e.g. embedded systems) where low overhead is needed."

Squashfs was written by Phillip Lougher, email plougher@users.sourceforge.net, in Chepstow, Wales, UK. He says in the documentation, "If you like the program, or have any problems, then please email me, as it's nice to get feedback!"

If you read the article on modifying the Dyne:Bolic distro for the 'SCOOL project, you will have noticed that this distro uses squashfs to compress the /usr file tree. The PCLinux distro uses it to compress the whole distro.

It is also useful for compressing your own file trees to save them on a CD as its compressed file size is possibly the best there is.

The big pleasure of doing this install for the newbie is that adding squashfs lets you to patch, recompile, test and install a new kernel, something usually only done by tech heads and Linux gurus.

This howto takes you through all the steps needed for a successful install.

The first step is to make sure that you have the kernel development tools and the kernel installed on your system. Use YaST – Install/Remove packages to check this out, installing from your CDs or DVD where necessary. You'll find the kernel sources get installed into /usr/src/linux and there will hundreds of files in this folder. You can check there first if you like, to see if you have to install anything.

The next step is to download squashfs from http://sourceforge.net/. Just search for squashfs.

The version I am using is squashfs2.1-r2

Log into a terminal console as root and copy the tar file from where you down loaded it to your favourite source folder. I down load it to my home/webstuff folder and invariably copy it to /usr/local/src.

Untar with the command "tar xzvf squashfs2.1-r2.tar.gz. You end up with a new folder called, would you believe, squashfs2.1-r2. Enter this folder and you will see a lot of folders starting with the word "linux". For SUSE 9.2, enter the one called "linux-2.6.9". If you read the install document, you will find that this is the one nearest the SUSE 9.2 kernel number. (2.6.8-24.14). In the folder is a file called squashfs2.1-patch.

You are going to use this file to patch your kernel, so remember or write down the full path where it can be found.

Change to the Linux source folder.

cd /usr/src/linux

Apply the patch like this:


Don't forget the "<" which tell the patch command to take its input from the squashfs patch file.

You should see these statements:


You will find that in SUSE the console is "detached" from X windows, and trying to run windowing software from the console brings up an error. To avoid this problem, select an RXVT terminal form the main menu under System – Terminal and type these commands:

sux

give root's password.
(Sux is Super User with X)

cd /usr/src/linux

make xconfig

A huge kernel configuration menu will appear. Don't worry, we are only going to change 3 things. Here is the menu. I've scrolled down to the bits we are interested in.


SUSE 9.2 uses subfs to mount removable media like CDs. It doesn't have anything to do with squashfs, but it needs to be turned on. The dot in the square means compile it as a module.

Next select "Miscellaneous filesystems" from the left hand menu and turn on squashfs in the same way.


The last thing to do is to give our new kernel a distinct name. This will ensure that it builds its modules in a distinct folder in /lib/modules, and doesn't overwrite or change the ones already there for the default kernel.

If you are using an older 2.4 kernel, you may not have this option on your menu, so you will have to move your default modules to a different folder to avoid any conflicts. For example, put "old" in front of the name. Then you can always restore them to the original name if your new kernel doesn't work. You will probably have to boot using a live CD like Knoppix or Dyne:Bolic to be able to do this. It is a really good idea to have one of these CDs in your tool kit.

Scroll down to the end of the menu and find this:


Double click on the Configuration name item in the top right panel. The name bar at the bottom of this panel will appear. backspace over what is there, and put in your own name.

Save your new kernel configuration by clicking the disk icon in the top bar, and choosing File – Save.

The window will close and you can return to your super user terminal for the rest of the commands.

The command to compile source code is "make". Enter this at your terminal while it is in the /usr/src/linux folder.


The computer will begin compiling all the kernel code and modules.

If you are using an older 2.4 or lower kernel, you will have to type: "make dep" then "make" and then "make modules".


Here is a picture of the compile in progress where it has done the squashfs module.

When the compile has finished and you've finished you special hacker's coffee, you can install the new kernel with the command:

make install

This is what you should see when this is finished:


I've typed in the next command to install the modules:

make modules_install

When you have reached this stage, you have successfully recompiled a SUSE 9.2 kernel. Pretty good for a newbie.

We have to make some changes to the "grub" booting configuration to ensure that we can still boot into the original working kernel, just in case Murphy paid us a visit. The Make Install phase, changes the default links in the /boot folder to point to our new kernel. We are going to change these back to the originals, and create a new entry in the grub menu so we can select the new kernel on reboot, or if it didn't work, use the original to try again.

This is a picture of Midnight Commander in root mode. You can start this up by selecting the relevant item from the console Session menu, or by typing "mc" in a root terminal console.


I've set the left panel to /lib/modules so you can see that I have a new folder for these modules. The right panel is where we are going to change the links. The vmlinuz symbolic link is pointing to my new kernel. It needs to be changed to point to the original kernel which is the one ending with the name "default". I have been doing some other compiles here as you can see by the one ending with "toms". The other link is the one for initrd which you should make sure points to "default".

Place the highlight over @vmlinuz and click the File menu in the top blue bar.

Click "edit sYmlink" and the edit window will pop up. Change the link to point to "vmlinuz-2.6.8-24.14-default".

Here is picture of me changing the initrd link. You may not have to change this link if it already points to "default" as my "stomfi" compile did not produce a new initrd file, so yours may not either. My "toms" one did so I changed mine from that, just to show you. I should build a "clean" unchanged system to see, but changing things is so much fun, I'll probably never get round to it.


That was simple wasn't it. You will be able to see if you have made a mistake in your typing as the "@" sign in front of the link name will change to a "!" sign, which denotes a broken or non existing link.

It's time to enter the grub folder and add our new kernel to the menu with a bit of copying and pasting, and a few word changes.


What I have done here, is to yank the first 5 lines with the vi editor command 5yy while the cursor is on the first of the lines I want to copy. Then I have gone to the end of the file and pressed the p key, which pasted them at the end. I changed the comment, by pressing C, changing the words and pressing the Esc key. I moved with the arrow keys to the "z" at the end of vmlinuz. I pressed the "a" key and appended "-2.6.8-24.14-stomfi" and pressed the Esc key again. I moved the cursor to the "d" at the end of initrd and pressed the full stop key. This repeats whatever you did last, between entering edit mode and pressing Esc. I changed "stomfi" to "default" by putting the cursor on the "s" of stomfi" and pressing the "cw" keys and changing the word. I pressed the Esc key. I read over what I had done, and pressed Shift ZZ to save and quit. If you don't like vi do the same with your favourite text editor.

Now reboot your machine, and select your new kernel from the menu.

Well, mine works just fine.

I did these processes 3 times over just to make sure that there is a better than even chance they will work for you.

The fact that it works means that I could go and change those links back to point to my new kernel, but I would rather change the grub menu to boot from my new entry as the default. Thus:


This line originally said "default 0" which is the first entry. Grub starts all its counting from zero. The last or fifth entry (my new entry) is number 4.

Now that we have successfully got the new kernel with squashfs in it we can go and compile the squashfs tools.

Using your root Midnight Commander go to the /usr/local/src/squashfs2.1-r2/ folder and enter the squashfs-tools folder. Here you will find some source code and a Makefile.

Type the command:

make

This is what you will now see:


Copy the file "mksquashfs" to "/usr/local/bin/mksquashfs". I do this by using the TAB key to move to the other mc window pane, going to the /usr/local/bin folder, pressing TAB again to return to the squashfs folder, highlighting mksquashfs by using the arrow keys, and pressing the F5 key or clicking the mouse on the Copy item at the bottom of the mc window. Press enter or click OK to perform the copy.

For security reasons, I usually leave /usr/local/bin out of my path, but programs looking for mksquashfs won't be able to find it, so I create a symbolic link from /usr/local/bin/mksquashfs to /usr/bin/mksquashfs.

You can do this in mc by opening the /usr/bin folder in one pane, and highlighting /usr/local/bin/mksquashfs in the other. Click File – SymLink and press enter to accept the default name. Or you can do it from the command line with the command:

ln -s /usr/local/bin/mksquashfs /usr/bin/mksquashfs

This is all done. If you have a copy of Dyne:Bolic, you can check that it all works by exploding the dynebolic system onto your hard drive. Here is a picture of it happening. The first errors are because I copied the files off the CD into the /usr/local/dyne folder.

Like it says the /usr squash file takes a long time to uncompress.


In another one of these articles I am going to show you how to install "qemu" and get it going with the Dyne:Bolic CD, which I am using for the 'SCOOL project. Just as squashfs is handy for this project, qemu is handy as you can make qemu run straight from the iso without having to burn a CD, and right there in a window on your development machine. You can do lots of other things with squashfs and qemu, but I'll leave it to you to read all about their wonderful features in their documentation.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell