help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Booting an ISO file from GRUB


From: Glenn Washburn
Subject: Re: Booting an ISO file from GRUB
Date: Wed, 3 Apr 2024 20:16:12 -0500

On Wed, 14 Feb 2024 10:26:28 +0200
Marko Toivanen <sc.marko.toivanen@gmail.com> wrote:

> I have been trying to find information related to the following problem:
> 
> I'm trying to start a Lubuntu 22.04 installation from an older Lubuntu 
> 14.04 installation by booting the ISO file from grub menu.
> 
> Booting the ISO file works by adding the following menu configuration to 
> file /etc/grub.d/40_custom:
> 
> menuentry "Linux ISO to RAM" {
>      insmod lvm
>      insmod ext2
>      set root="lvm/lubuntu--vg-root"
>      set isofile="/home/user/lubuntu-22.04.3-desktop-amd64.iso"
>      loopback loop $isofile
>      linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile 
> toram
>      initrd (loop)/casper/initrd
> }
> 
> The problem is when Lubuntu 22.04 starts this way, there is a device 
> "/dev/lubuntu-vg" showing up in Linux (what I didn't expect) and because 
> of that, I can't make a clean install of Lubuntu 22.04 on the hard drive 
> when Lubuntu was started from the ISO file (which is located on the hard 
> drive).
> 
> My initial thought was that using "toram" option would completely load 
> the ISO to RAM, so I could then be able to repartition the hard drive 
> without having to start Lubuntu 22.04 installation from an USB stick.
> 
> When I try to repartition /dev/sda (where this lubuntu-vg is located) 
> with gparted, I get the following error message:
> 
> "we have been unable to inform the kernel of the change, probably 
> because if/they are in use"
> 
> So, is it possible to boot an ISO file so the problem described wouldn't 
> happen?

Yes, it is possible.

As noted by Andrei, this is an issue with ubuntu not grub. Its been
known about for some time, and I've created a merge request for the
casper package that was meant to address this[1]. However, I hadn't
considered the ISO being on LVM or MD, so it may not work
automatically in your case. The core issue is that the initrd mounts the
filesystem containing the ISO to /isodevice in the initrd, but does not
make that mount available when switching to the rootfs. So there's no
way to unmount that filesystem which is needed to disable the various
block layers.

In your grub menu entry above, you can append an initrd that you create
that patches the necessary init scripts to allow unmounting of
/isodevice and then deactivating the VG so that the block device is not
in use. I'm disappointed that my changes have not gotten merged into the
latest 24.04 iso since I made the merge request months before the
release. I think this reflects poorly on that Ubuntu team that this has
been an issue for so long and the fix has been known for a long time
too.

Glenn

[1] https://code.launchpad.net/~crass/casper/+git/casper/+merge/453084



reply via email to

[Prev in Thread] Current Thread [Next in Thread]