Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

How can I boot a squashfs image on my hard drive?

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
10 posts • Page 1 of 1
Author
Message
Robert S
Guru
Guru
User avatar
Posts: 463
Joined: Sun Aug 15, 2004 11:30 am
Location: Canberra Australia

How can I boot a squashfs image on my hard drive?

  • Quote

Post by Robert S » Wed Jul 25, 2012 1:12 pm

I have followed the instructions on http://en.gentoo-wiki.com/wiki/Build_Yo ... 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: Select all

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?
Top
nativemad
Retired Dev
Retired Dev
User avatar
Posts: 918
Joined: Mon Aug 30, 2004 5:23 pm
Location: Switzerland

  • Quote

Post by nativemad » Thu Jul 26, 2012 7:47 am

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!
Top
Robert S
Guru
Guru
User avatar
Posts: 463
Joined: Sun Aug 15, 2004 11:30 am
Location: Canberra Australia

  • Quote

Post by Robert S » Thu Jul 26, 2012 12:52 pm

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

When I boot using this I get:
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.
Top
khayyam
Watchman
Watchman
User avatar
Posts: 6227
Joined: Thu Jun 07, 2012 2:45 am
Location: Room 101

  • Quote

Post by khayyam » Thu Jul 26, 2012 5:50 pm

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: Select all

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: Select all

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
Top
nativemad
Retired Dev
Retired Dev
User avatar
Posts: 918
Joined: Mon Aug 30, 2004 5:23 pm
Location: Switzerland

  • Quote

Post by nativemad » Fri Jul 27, 2012 5:48 am

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: Select all

title=LiveCD 
kernel /boot/yourkernel root=/dev/ram0 looptype=squashfs loop=/boot/livecd.squashfs udev cdroot
initrd /boot/yourinitramfs
Power to the people!
Top
Robert S
Guru
Guru
User avatar
Posts: 463
Joined: Sun Aug 15, 2004 11:30 am
Location: Canberra Australia

  • Quote

Post by Robert S » Fri Jul 27, 2012 12:06 pm

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 . . .
Top
nativemad
Retired Dev
Retired Dev
User avatar
Posts: 918
Joined: Mon Aug 30, 2004 5:23 pm
Location: Switzerland

  • Quote

Post by nativemad » Fri Jul 27, 2012 1:01 pm

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: Select all

mount -o remount,rw /mnt/cdrom
Power to the people!
Top
Robert S
Guru
Guru
User avatar
Posts: 463
Joined: Sun Aug 15, 2004 11:30 am
Location: Canberra Australia

  • Quote

Post by Robert S » Fri Jul 27, 2012 1:34 pm

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:
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)
Top
nativemad
Retired Dev
Retired Dev
User avatar
Posts: 918
Joined: Mon Aug 30, 2004 5:23 pm
Location: Switzerland

  • Quote

Post by nativemad » Fri Jul 27, 2012 4:02 pm

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: Select all

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!
Top
Robert S
Guru
Guru
User avatar
Posts: 463
Joined: Sun Aug 15, 2004 11:30 am
Location: Canberra Australia

How can I boot a squashfs image on my hard drive? [SOLVED]

  • Quote

Post by Robert S » Fri Jul 27, 2012 10:37 pm

That seems to only work when you mount /mnt/cdrom read-only.
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:
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.
Top
Post Reply

10 posts • Page 1 of 1

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Authors
Gentoo is a trademark of the Gentoo Foundation, Inc. and of Förderverein Gentoo e.V.
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-4.0 license.
The Gentoo Name and Logo Usage Guidelines apply.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy