LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Use squashfs as / ? (https://www.linuxquestions.org/questions/linux-general-1/use-squashfs-as-647320/)

SnowSurfAir 06-05-2008 08:46 PM

Use squashfs as / ?
 
Hello all,

I have been just experimenting on my computer to test out some stuff for a planned system that I have. Anyway, I have a kernel that supports squashfs, it can mount squash file(like something.sqsh) as well as squash hard drives.

This is my drive setup:
Code:

/dev/sdb1: /boot
/dev/sdb2: swap
/dev/sdb3: /
/dev/sdb5: /home
/dev/sdb6: squashed /

so what I did was this:

Code:

mksquashfs / /home/root.sqsh
cd /home
dd if=root.sqsh of=/dev/sdb6

sdb6 mounts and everything just fine, but now I am trying to get it to boot from that partition with grub, i.e. use that as the / filesystem readonly.

This is my menu.lst

Code:

# general configuration:
timeout  5
default  0
color light-blue/black light-cyan/blue

# boot sections follow
# each is implicitly numbered from 0 in the order of appearance below
#
# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
#
#-*

# (0) Arch Linux
title  Arch Linux
root  (hd0,0)
kernel /vmlinuz26 root=/dev/disk/by-uuid/b3ca895f-ad9e-43d1-ac6b-1c2f117cea32 ro vga=773
initrd /kernel26.img

title Squashfs
root  (hd0,0)
kernel /vmlinuz26 root=/dev/disk/by-uuid/b788e27a-3f47-4e6e-96ae-f4a08a1bc0f9 ro rootfstype=squashfs
initrd /kernel26.img

# (1) Arch Linux
title  Arch Linux Fallback
root  (hd0,0)
kernel /vmlinuz26 root=/dev/disk/by-uuid/b3ca895f-ad9e-43d1-ac6b-1c2f117cea32 ro
initrd /kernel26-fallback.img

So when I select Squashfs grub says: cannot mount selected partition. So I dont know if I am doing this right or if I am just making a rather large hole in the wall with my head, but if you could tell me what I am doing wrong or were I can find a guide for this kindof thing, that would be much appreciated. Thank you, Levi

datopdog 06-06-2008 07:29 AM

grub cannot load a kernel and initrd stored on a squashfs partition, you need to create a separate /boot partition then the rest can be in squashfs

SnowSurfAir 06-06-2008 01:06 PM

Quote:

Originally Posted by datopdog (Post 3176604)
grub cannot load a kernel and initrd stored on a squashfs partition, you need to create a separate /boot partition then the rest can be in squashfs

Yeah that is how I have it. There is a /boot partition at /dev/sdb1 and then the squashed / partition is at /dev/sdb6. I dont know if I have the right options loaded for it to boot or what but it says it cant mount the partition.

edit: wait, does that mean that I have to change the root option to be (hd0,0)?

edit edit: Ok, now i gots it booting, but I get a kernel panic, it says:
Code:

kinit: cannot open root device sdb6(8,22)
kinit: init not found
Kernel panic - attempting to kill init.

Or something like that for the kernel panic part...Any suggestions.

IsaacKuo 06-06-2008 01:31 PM

Quote:

Originally Posted by SnowSurfAir (Post 3176862)
edit: wait, does that mean that I have to change the root option to be (hd0,0)?

It looks like the root option (for grub) is already (hd0,0), as it should be. That's fine. That tells grub where to find /vmlinuz26and /kernel26.img. Clearly, those two files are in the proper place on (hd0,0), since the first boot option works.

However, I'm guessing that squashfs support is not built into kernel26.img. Certainly, squashfs support is available in the "main" OS. However, that's only available AFTER booting into the "main" OS. Grub doesn't know how to mount squashfs and even if it did it wouldn't directly help the initial ramdisk boot up.

Basically, here's the boot sequence:

1) Minimal GRUB loads from main boot record, looks for "big" GRUB on (hd0,0). It loads up "big" GRUB (stage 1.5).

2) "big" GRUB loads up with the menu and stuff. It loads up the kernel and initial ram file system.

3) Initrd.img. This is a lightweight linux OS running entirely in RAM from a tmpfs ramdisk. It gets hardware up and running, binds them up into the "main" OS, and then hands everything over to the "main" OS.

4) The "main" OS takes over with its "init" script. Among other things, it will now look at /etc/fstab and mount file systems other than root and the device file systems already brought up by initrd.img.

The point where it's breaking down, I suspect, is within the inital ramdisk bootup. I think that the kernel26.img you've built does NOT have squashfs built into it.

I'm not familiar with rebuilding the initrd.img in Arch, but I expect that's where you'll need to go to fix this.

SnowSurfAir 06-06-2008 01:41 PM

Quote:

Originally Posted by IsaacKuo (Post 3176877)
The point where it's breaking down, I suspect, is within the inital ramdisk bootup. I think that the kernel26.img you've built does NOT have squashfs built into it.

I'm not familiar with rebuilding the initrd.img in Arch, but I expect that's where you'll need to go to fix this.

Yeah that is what I was a thinking. I will browse the arch forums and try to figure out it. Do I need the squashfs support built into the kernel as well? Right now I have it built as a module because the option is not like available in a kernel rebuild. Thank you for all the information, Levi.

SnowSurfAir 06-06-2008 02:41 PM

Got it working. Just had to rebuild my initrd.img to include squashfs. Took me like 3 seconds. Just in case someone is searching for this: you can find out how to do this for archlinux at:

http://wiki.archlinux.org/index.php/...ing_mkinitcpio

Thank you again for all of you helping me. Now I get to tinker around with it! yay.


All times are GMT -5. The time now is 10:30 PM.