grub-devel
[Top][All Lists]
Advanced

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

Re: Future of installing GRUB to LVM volumes (and loop devices)


From: Andrei Borzenkov
Subject: Re: Future of installing GRUB to LVM volumes (and loop devices)
Date: Tue, 5 May 2015 20:38:36 +0300

В Tue, 05 May 2015 18:54:03 +0200
Sebastian Pipping <address@hidden> пишет:

> Hello!
> 
> 
> I noticed that GRUB stopped supporting installation to LVM volumes and
> that installing to loop devices also started failing unless --force is
> given.  The Release of Debian jessie made me realize that GRUB
> 2.02~beta2 stopped doing what 1.99 did without complaining.  So I did
> some debugging.
> 
> A word on what this is needed for:
> I have a case where grub-install is asked to install to an LVM volume
> [1] that is later passed to Xen to boot a Xen guest.  Inside the Xen
> guest the LVM volume is seen as a regular hard disk.  So I can no longer
> use grml-debootstrap/grub-install to install to LVM volumes without
> patching at least one of those.
> 
> To reproduce it:
> 
>   # touch /var/tmp/disk2
>   # truncate --size=$((100*1024**2)) /var/tmp/disk2
>   # loop_device_2="$(losetup --show -f /var/tmp/disk2)"
>   # vgcreate vg "${loop_device_2}"
>   # lvcreate --name lv -l 100%free vg
>   # parted /dev/vg/lv mklabel msdos
>   # parted /dev/vg/lv mkpart primary ext4 4m 100%
>   # mkfs.ext4 /dev/mapper/vg-lvp1
>   # mkdir /mnt/lv-root
>   # mount /dev/mapper/vg-lvp1 /mnt/lv-root
>   # mkdir /mnt/lv-root/boot
>   # grub-install --boot-directory=/mnt/lv-root/boot /dev/mapper/vg-lv
>   Installing for i386-pc platform.
>   grub-install: error: disk
> `lvmid/GrSIBA-3EPT-TxGE-cnSa-glgA-pXpy-Kw8cOg/PD3WT8-956c-CEJ8-yPJE-ttGy-yACP-ffwTac'
> not found.
> 
> When I add a device map containing that drive ..
> 
>   # echo -e
> '(lvmid/GrSIBA-3EPT-TxGE-cnSa-glgA-pXpy-Kw8cOg/PD3WT8-956c-CEJ8-yPJE-ttGy-yACP-ffwTac)\t/dev/mapper/vg-lv'
> > /mnt/lv-root/boot/grub/device.map
> 
> .. grub-install replaces the "lvmid/*" drive to
> "hostdisk//dev/mapper/vg-lv" saying
> 
>   grub-install: warning: the drive name
> `lvmid/GrSIBA-3EPT-TxGE-cnSa-glgA-pXpy-Kw8cOg/PD3WT8-956c-CEJ8-yPJE-ttGy-yACP-ffwTac'
> in device.map is incorrect. Using hostdisk//dev/mapper/vg-lv instead.
> Please use the form [hfc]d[0-9]* (E.g. `hd0' or `cd').
> 
> and remains complaining "disk `lvmid/...' not found.
> Since the docs at "13.1 How to specify devices" (docs/grub.info)
> advertise "lvmid/" in Git for valid drive syntax, that came unexpected
> to me.
> Inspecting the code of read_device_map shows that only
> 
>   (fd0) ...
>   (hd0) ...
>   (cd) ...
> 
> of the documented syntax are actually registering the drive as-is (which
> does match the warning), everything else (including "(lvmid/*)") ends up
> being re-written to "(hostdisk/<file>)".  So it does not allow me
> helping GRUB in finding the disk.
> 

address@hidden:~/build/grub> cat boot/grub/device.map 
(hd0) /dev/system/docker
address@hidden:~/build/grub> sudo pkgdatadir=$PWD ./grub-install -d grub-core 
--boot-directory $PWD/boot --grub-mkdevicemap /tmp/device.map '(hd0)'
Installing for i386-pc platform.
Installation finished. No error reported.

Yes, device.map is *still* useful :)

> 
> I did manage convincing grub-install to accept lvmid device map entries
> using the patch attached but I would also like to see something that
> works out of the box again (including loop devices), of course.
> 
> 
> Now that you know about the scenario and problem I would like to ask:
> 
>  * How you would like to see this addressed in GRUB code?
> 
>  * What replacements to "grub-install --boot-directory=<X> <Y>" can
>    you think of for a temporary workaround?
>    How would use existing GRUB commands to dump future MBR bytes needed
>    to some regular file to apply that to any device using dd after or
>    something like that?
> 
> 
> Many thanks in advance,
> 
> 
> 
> Sebastian
> 
> 
> [1] from inside a tool called grmldeboostrap [2], a wrapper around
>     deboostrap installing Debian to a given block device
> [2] https://github.com/grml/grml-debootstrap




reply via email to

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