Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How can I boot a squashfs image on my hard drive?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 460
Location: Canberra Australia

PostPosted: Wed Jul 25, 2012 1:12 pm    Post subject: How can I boot a squashfs image on my hard drive? Reply with quote

I have followed the instructions on http://en.gentoo-wiki.com/wiki/Build_Your_Own_LiveCD_or_LiveDVD and have managed to make a working live CD. I would like to be able to run this from my hard drive so that I can use it as a rescue option at bootup. I have tried variants of the following but it always tries to mount a physical CD-ROM at startup.

Code:
title=LiveCD
        kernel /boot/kernel-genkernel-x86_64-3.3.8 real_root=/dev/loop0 looptype=squashfs loop=/livecd.squashfs vga=ask initrd udev nodevfs cdroot dodmraid
        initrd /boot/initramfs-genkernel-x86_64-3.3.8


I have had a cursory look at the /init script - I assume that it is somehow possible to do this by sending the correct kernel paramaters.

Does anyone know how to do this?
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 918
Location: Switzerland

PostPosted: Thu Jul 26, 2012 7:47 am    Post subject: Reply with quote

Hi,

i'ts a long time since i've done that the last time... (Look at grub2 and the option to boot isofiles from disk, if you don't need special customization! :wink: )

The init script that does to magic is /usr/share/genkernel/defaults/linuxrc.
You will need to place a file called /livecd on the root of the device with the squashfs on it. (It was the case the every blockdevice gets mountet and it simply searched for that file! But honestly I down't know if this is still the case!?)
Your boot params look good, but just to get sure...The squash should be /livecd.squashfs on the device, with the exact same name/path!

HTH, cheers
_________________
Power to the people!
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 460
Location: Canberra Australia

PostPosted: Thu Jul 26, 2012 12:52 pm    Post subject: Reply with quote

Hi (from a fellow "Swiss" living in Australia).

When I boot using this I get:

Quote:
Looking for the cdrom
Attempting to mount media:- /dev/sr0
Attempting to mount media:- /dev/sda1
Attempting to mount media:- /dev/sda2
<etc>
determining root device...
Determining looptype ...
!! Invalid loop location: /boot/livecd.squashfs
!! Please export LOOP with a valid location, or reboot and pass a proper loop=...
!! kernel command line

I can confirm that /boot/livecd.squashfs DOES exist (its not in the root directory as I've indicated in my original post).

I think the init script expects the squashfs to be on a cdrom, not a hard drive.
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Jul 26, 2012 5:50 pm    Post subject: Reply with quote

Robert ...

From the instructions given on the wiki it seems to me that grub is used as a replacement for isolinux, so the grub setup provided is within the iso, not the method for booting the iso from disk. This being the case I imagine that you need to configure the bootloader to boot the iso image.

I've only done this with isolinux, so I can't state for sure this will work, but I imagine grub will work similarly. Here is an example of booting an iso from grub2:

Code:
menuentry "SystemRescueCD-x86 2.4.1" {
 search --no-floppy --set -f /systemrescuecd-x86-2.4.1.iso
 loopback loop /systemrescuecd-x86-2.4.1.iso
 linux (loop)/isolinux/rescuecd docache setkmap=us isoloop=systemrescuecd-x86-2.4.1.iso --
 initrd (loop)/isolinux/initram.igz
}

This boots the iso directly skipping isolinux (the parameters to isolinux are passed in 'linux'). In your case its a little more complex and I really can't say if the following will work in its current state ... but it may give you something to go on.

Code:
menuentry "liveCD" {
 search --no-floppy --set -f /liveCD.iso
 loopback loop /LiveCD.iso
 linux (loop)/boot/kernel-genkernel-x86_64-3.3.8 real_root=/dev/loop0 looptype=squashfs loop=/livecd.squashfs vga=ask initrd udev nodevfs cdroot dodmraid isoloop=liveCD.iso --
 initrd (loop)/boot/initramfs-genkernel-x86_64-3.3.8
}

HTH & best ... khay
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 918
Location: Switzerland

PostPosted: Fri Jul 27, 2012 5:48 am    Post subject: Reply with quote

I just wanted to point out that these are completely different scenarios... khayyam's method is by far easier (at least in the long run, update wise, as you can just download newer isos), but it relies completely on grub2. (I wrote that linuxrc-trick a few years ago, see https://bugs.gentoo.org/show_bug.cgi?id=294268)


RobertS's method of booting the squashfs directly is also possible, but a bit more complex...
As you can see, it tries all partitions on /dev/sr0 as well as /dev/sda... so its not a problem if its not a cdrom actually. :wink:
But it will search for the file /livecd on the partitions!
You should not set real_root as boot parameter, but you should set root=/dev/ram0!
Something like this should do it
Code:
title=LiveCD
kernel /boot/yourkernel root=/dev/ram0 looptype=squashfs loop=/boot/livecd.squashfs udev cdroot
initrd /boot/yourinitramfs

_________________
Power to the people!
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 460
Location: Canberra Australia

PostPosted: Fri Jul 27, 2012 12:06 pm    Post subject: Reply with quote

Brilliant!!

I used your GRUB paramaters - didn't boot but I created an empty file called livecd on the root directory of /dev/sda1 and it recognised this as a boot device.

There are a few issues now I have this working:

1. I have had to make a directory called /run in the filesystem for certain services to run on the livecd (eg. sshd)cat /pr - otherwise the /var/run and /var/lock symlinks don't point to anything. Maybe this should be included in the init script.

2. /proc/mounts reports that /dev/sda1 is mounted on /mnt/cdrom, while /etc/mtab does not. There is no directory called /mnt/cdrom in the "livecd" directory structure that this boots into.

None of these problems seem insurmountable . . .
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 918
Location: Switzerland

PostPosted: Fri Jul 27, 2012 1:01 pm    Post subject: Reply with quote

cool :P

The first issue comes from systemd and the compatibility to it i suppose...
The second issue is quite funny... The directory has to exist within the initramfs and/but pivot_root does not check for it while switching the root...

In both cases I would just add these directories and recreate the squashfs.

btw, if you've got /mnt/cdrom, you can just do the following to get write access to /dev/sda1:
Code:

mount -o remount,rw /mnt/cdrom

_________________
Power to the people!
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 460
Location: Canberra Australia

PostPosted: Fri Jul 27, 2012 1:34 pm    Post subject: Reply with quote

Hi.

I have added /mnt/cdrom to the squashfs. It appears in /mnt/livecd/mnt in the running system, but it does not appear in /mnt. I suspect that /mnt (but not /mnt/cdrom) are created by the init script in the running system - they don't get copied from the squashfs.

The remount script does not work:
Quote:

MiniGentoo ~ # mkdir /mnt/cdrom

MiniGentoo ~ # mount -o remount,rw /mnt/cdrom

mount: /mnt/cdrom not mounted or bad option

MiniGentoo ~ # mount |grep cdrom

/dev/sda1 on /mnt/cdrom type ext4 (ro,relatime,user_xattr,acl,barrier=1,data=ordered)
Back to top
View user's profile Send private message
nativemad
Developer
Developer


Joined: 30 Aug 2004
Posts: 918
Location: Switzerland

PostPosted: Fri Jul 27, 2012 4:02 pm    Post subject: Reply with quote

That is strange... It really looks like a little a bug with recent genkernels!?
I remember that I have it at work like this (ok, squashfs via pxe/nfs, but /mnt/cdrom is the nfs share!) with an older kernel/genkernel.
But i just tested it with a recent minimal livecd and also there, /mnt/cdrom isn't available!
What worked for me is this:
Code:
mkdir /mnt/cdrom
mount /dev/whatever /mnt/cdrom
Now i've got two entries for /mnt/cdrom in /proc/mounts........
I don't know if this is worth digging deeper and doing a bugreport, as there is an easy work around!?
_________________
Power to the people!
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 460
Location: Canberra Australia

PostPosted: Fri Jul 27, 2012 10:37 pm    Post subject: How can I boot a squashfs image on my hard drive? [SOLVED] Reply with quote

That seems to only work when you mount /mnt/cdrom read-only.
Quote:
MiniGentoo ~ # mount /dev/sda1 /mnt/cdrom
mount: /dev/sda1 already mounted or /mnt/cdrom busy
mount: according to mtab, /dev/sda1 is already mounted on /mnt/cdrom
MiniGentoo ~ # mount /dev/sda1 /mnt/cdrom -o ro
MiniGentoo ~ # ls /mnt/cdrom/
bin core etc lib lib64 lost+found opt root sbin tmp var
boot dev home lib32 livecd mnt proc run sys usr

It is however possible to remount it read-write:
Quote:
MiniGentoo ~ # mount /dev/sda1 /mnt/cdrom -o remount,rw
MiniGentoo ~ # mount |grep cdrom
/dev/sda1 on /mnt/cdrom type ext4 (ro,relatime,user_xattr,acl,barrier=1,data=ord ered)
/dev/sda1 on /mnt/cdrom type ext4 (rw)
MiniGentoo ~ # touch /mnt/cdrom/foo
MiniGentoo ~ # ls /mnt/cdrom/
bin core etc home lib32 livecd mnt proc run sys usr
boot dev lib lib64 lost+found opt root sbin tmp var

As there's a simple workaround for this its hardly worth submitting a bug report for these issues.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum