Article 6PJP9 Boot from an .img device (a copy of the physical device)

Boot from an .img device (a copy of the physical device)

by
alexanderzhirov
from LinuxQuestions.org on (#6PJP9)
There is a copy of the disk in IMG format:
Code:root@linux /mnt # fdisk -l /mnt/output.img
Disk /mnt/output.img: 3 GiB, 3221225472 bytes, 6291456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 3EEB19F8-AB57-47B4-A7E7-F2A0BDE6C2B1

Device Start End Sectors Size Type
/mnt/output.img1 2048 4095 2048 1M BIOS boot
/mnt/output.img2 4096 6289407 6285312 3G Linux LVMlvdisplay provides the following information about the disk:

Code:lvm> lvdisplay
--- Logical volume ---
LV Path /dev/connect/root
LV Name root
VG Name connect
LV UUID KXxms1-2d0j-C8Ps-6azt-3U0z-PpOO-K9mS0B
LV Write Access read/write
LV Creation host, time client-dev-building-02, 2024-07-25 13:36:12 +0300
LV Status NOT available
LV Size 2,00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto

--- Logical volume ---
LV Path /dev/connect/boot
LV Name boot
VG Name connect
LV UUID OKFDNN-IUDQ-a0Ol-6Dqg-lDKu-GIWK-4A8faP
LV Write Access read/write
LV Creation host, time client-dev-building-02, 2024-07-25 13:36:14 +0300
LV Status NOT available
LV Size 512,00 MiB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto

--- Logical volume ---
LV Path /dev/connect/home
LV Name home
VG Name connect
LV UUID Uls6Oa-fQ64-Qrpd-mVXr-kYxo-PZmO-uxXx4Z
LV Write Access read/write
LV Creation host, time client-dev-building-02, 2024-07-25 13:36:14 +0300
LV Status NOT available
LV Size 508,00 MiB
Current LE 127
Segments 1
Allocation inherit
Read ahead sectors autoI created a USB stick with GRUB download. I copied the file output.img there. My configuration looks like this:

Code:menuentry "output" {
insmod lvm
set isofile="output.img"
loopback loop (hd0,2)/${isofile}
linux (lvm/connect-boot)/vmlinuz root=/dev/connect/root ro
initrd (lvm/connect-boot)/initrd.img
}The kernel is loaded, but when loading initramfs it is not possible to mount the root directory, it gives an error:

Code:Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... Volume group "connect" not found
Cannot process volume group connect
done.I mean, initramfs lacks LVM boot support.

Is there any way to mount the root directory, or load to GRUB, which is available on output.img?

My attempts to boot directly from the LVM device gives the error unknown file system type LVM2_member: grub pic

It is necessary to load it in this form, without writing IMG directly to USB. The output.img file is always different, so i need to make different boot options from different disks in this format.
Attached Thumbnailsattachment.php?attachmentid=43399&stc=1&
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments