Tips and Instructional topics. Not for support questions.
Post a reply
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Boot Refracta (or other Debian-Live) ISO from grub2 menu

Fri Jan 24, 2014 3:10 pm

It is very useful to boot a debian-live image from fixed disk and have an entry in the normal grub menu, rather than having to write it to cd or usb just to test. This was quite simple with grub-legacy although it was necessary to extract the iso contents first.
With grub2 it is possible to boot the iso direct. This is not so well documented, and a lot of what you read just doesn't work. This does, I'm writing now from a live session booted from a grub2 menu.
Add this to /censored/grub.d/40_custom (censored=etc):

Code:
  `menuentry "Live ISO Boot" {
  insmod part_msdos
  insmod ext2
  set isofile='(hd0,msdos11)/path/to/whatever.iso'
  loopback loop $isofile
  linux (loop)/live/vmlinuz boot=live findiso=/path/to/whatever.iso config locales=en_GB.UTF-8 noeject
  initrd (loop)/live/initrd.img
  }`

Adjust your menu entry text, kernel line (after findiso= .. e.g. with what is in /isolinux/live.cfg) and partition reference to suit. Remember grub2 counts disks from 0 and partitions from 1 (e.g. sda11 = hd0,msdos11). Then do update-grub. It should be in the menu for next boot.
I never got it to work without "findiso".
Previously I found grub2 generally an annoyance. Lack of good documentation was the main problem. Now I even got custom themes working which look better than the old Suze-style grub-gfx-boot.
thwak

- thwak
- Posts: 174
- Joined: Tue Nov 20, 2012 3:58 am

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Fri Jan 24, 2014 11:11 pm

> I'm writing now from a live session booted from a grub2 menu

During your session, what are the conditions of the environment?
The (same) swap partition specified in the iso is present, so the swap partition is recognized during your session?
The loop-mounted rootfs is read-only and all rootfs write operations during the session are routed to tmpfs, per the overlays created by the iso-resident init?
If so, sounds like this would achieve a Tails -like "safe" session.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Fri Jan 24, 2014 11:51 pm

I had some trouble getting this to work. The iso file is in /sid14, which is in the root of the usb drive. There's no /live in the root or inside the sid14 directory, so I guess it's looking for /live inside the iso. I got rid of 'config' because i'm using refracta with its preconfigured user. This is what worked:

Code:
  `menuentry "Live ISO Boot" {
  insmod part_msdos
  insmod ext2
  set isofile='(hd4,msdos1)/sid14/snapshot_sid_140102.iso'
  loopback loop $isofile
  linux (loop)/live/vmlinuz boot=live findiso=/sid14/snapshot_sid_140102.iso
  initrd (loop)/live/initrd.img
  `

dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 1:01 am

This might answer thwak's questions:

Code:
  `[email protected]
  :~$ cat /proc/mounts
  rootfs / rootfs rw,size=1027932k,nr_inodes=217629 0 0
  sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
  proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
  udev /dev devtmpfs rw,relatime,size=10240k,nr_inodes=217634,mode=755 0 0
  devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
  tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=207236k,mode=755 0 0
  /dev/sda11 /lib/live/mount/findiso ext4 ro,noatime,data=ordered 0 0
  /dev/loop0 /lib/live/mount/medium iso9660 ro,noatime 0 0
  /dev/loop1 /lib/live/mount/rootfs/filesystem.squashfs squashfs ro,noatime 0 0
  tmpfs /lib/live/mount/overlay tmpfs rw,relatime 0 0
  tmpfs /lib/live/mount/overlay tmpfs rw,noatime,mode=755 0 0
  aufs / aufs rw,relatime,si=1cceec3e,noxino 0 0
  tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
  pstore /sys/fs/pstore pstore rw,relatime 0 0
  tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=414460k 0 0
  fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
  [email protected]
  :~$`

The only device mount is /dev/sda11 which is RO (that's the one with the iso). There is no swap configured, you do that optionally from cmdline in a live session
If the iso is on an otherwise clean partition, in your live-build sudo is disabled and a strong root password set, that should make an excellent safe environment.
@fsr: I can't see much difference with your menu entry to mine, except maybe I didn't make it clear enough..
I'm running a Refracta/sid rebuild iso this time and found a problem to do with newer udev. It won't boot from fixed disk without a minor initrd hack to /lib/live/boot/9990-misc-helpers.sh .. i used a custom initrd like refracta2usb does to modify (to be sure of a newer live-boot version). This is not necessary for wheezy. I can post details later if anyone wants to know.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 1:29 am

Yeah, I guess it does look a lot like your boot entry, and I guess I should have mentioned that it doesn't look like I'd expect. Here's the syslinux boot entry for the same iso. There's no live folder anywhere except inside the iso.

Code:
  `label sid14
  menu label sid14
  kernel /sid14/vmlinuz quiet
  append initrd=/sid14/initrd.img boot=live ip=frommedia union=aufs findiso=/sid14/snapshot_sid_140102.iso`

Yes, please post the initrd details. I think I couldn't boot with initrd.custom.img. Not sure if it was the initrd or cmdline.
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 2:15 am

You don't need a /live directory .. findiso loopmounts the actual iso and does everything else. If you look at my "cat /proc/mounts" snip you can see it's on /dev/loop1 ..
Use refracta2usb to make a custom initrd (it uses newer live-boot) The extracted and patched directory will remain in ~/patch-initrd/extracted .. Delete the rebuilt initrd.custom.img.
In (~/patch-initrd/extracted) /lib/live/boot/9990-misc-helpers.sh find and change this line:

Code:
  `if /sbin/udevadm test-builtin path_id "${sysfs_path}" | egrep -q "ID_PATH=(usb|pci-[^-]*-(ide|sas|scsi|usb|virtio)|platform-sata_mv|platform-orion-ehci|platform-mmc|platform-mxsdhci)"`

to this:

Code:
  `if /sbin/udevadm info --query=all --path="${sysfs_path}" | egrep -q "DEVTYPE=disk"`

and this line

Code:
  `echo "/dev/$($udevinfo -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})"`

to this:

Code:
  `echo "/dev/$($udevadm info -q name -p ${sysdev} 2>/dev/null|| echo ${sysdev##*/})"`

Then:

Code:
  `cd ~/patch-initrd/extracted
  fakeroot find . -print0 | cpio -0 -H newc -o | gzip -c > ../initrd.custom.img`

Use the new /initrd.custom.img. If you don't want to rebuild the iso you could place it with the iso and point the grub initrd line to that instead of "initrd (loop)/live/initrd.img" .. e.g.

Code:
  `initrd (hd0,msdos11)/path/to/initrd.custom.img`

This patch should probably go into refracta2usb (patch_initrd) as soon as it's tested some more.
This is actually fixed in latest live-boot (in experimental) but I'm not using it yet because I don't want to break the RW live-media-partition mount patches.
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 10:20 am

In the past i tried this:
grml-rescueboot - Integrates Grml ISO booting into GRUB
and it worked (but, if i recall correct, i only tried it with the distro grml, not with others).
The Web knows more. http://michael-prokop.at/blog/2011/01/0 ... hin-grub2/
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 12:22 pm

Sure you don't mean grub-imageboot (which also, I think, originates from grml but is now in Debian)? http://michael-prokop.at/blog/2011/01/0 ... hin-grub2/
Anyway, I tried that here but my sid images still won't boot from HD with the original initrd.
EDIT: Posted here is an updated (and untested!) "patch-live-intrd" script for sid/jessie with this fix included.
http://exegnulinux.net/refracta/experim ... sid.tar.gz ..
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 3:59 pm

> dzz wrote:Sure you don't mean grub-imageboot (which also, I think, originates from grml but is now in Debian)? http://michael-prokop.at/blog/2011/01/0 ... hin-grub2/
> Anyway, I tried that here but my sid images still won't boot from HD with the original initrd.

I think i meant the one i mentioned: grml-rescueboot.
It is in the repos too.
But yes, you may well be right that it (or both) don't work that well with _any iso (which is probably what one will want, or at least that is what i would want).
dzz

- dzz
- Posts: 647
- Joined: Wed Apr 27, 2011 11:53 am
- Location: Devon, England

## Re: Boot Refracta (or other Debian-Live) ISO from grub2 menu

Sat Jan 25, 2014 4:58 pm

Yes, maybe both can do that.. grml stuff is really good, a lot of it does get into Debian (eventually) and the main man is also a Debian dev.. grub-imageboot, I think, transfers to syslinux which can do things grub can't. It acually chainloads the original menu on the iso but was a bit slow getting there.
New discovery: I can boot iso's from (relative) symlinks !
Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.