1
Description: Handle filesystems loop-mounted on file images
2
Improve prepare_grub_to_access_device to emit appropriate commands for such
3
filesystems, and ignore them in Linux grub.d scripts.
5
This is needed for Ubuntu's Wubi installation method.
7
This patch isn't inherently Debian/Ubuntu-specific. losetup and
8
/proc/mounts are Linux-specific, though, so we might need to refine this
9
before sending it upstream. The changes to the Linux grub.d scripts might
10
be better handled by integrating 10_lupin properly instead.
12
Index: b/util/grub-mkconfig_lib.in
13
===================================================================
14
--- a/util/grub-mkconfig_lib.in
15
+++ b/util/grub-mkconfig_lib.in
22
+ /dev/loop/*|/dev/loop[0-9])
23
+ loop_file=`losetup "${device}" | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
27
+ loop_device="${device}"
28
+ device=`"${grub_probe}" --target=device "${loop_file}"`
34
if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then
36
"$device is a crypto device, which GRUB cannot read directly. Some" \
38
if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
39
echo "search --no-floppy --fs-uuid --set=root ${fs_uuid}"
42
+ if [ "x${loop_file}" != x ]; then
43
+ loop_mountpoint="$(awk '"'${loop_file}'" ~ "^"$2 && $2 != "/" { print $2 }' /proc/mounts | tail -n1)"
44
+ if [ "x${loop_mountpoint}" != x ]; then
45
+ echo "loopback loop0 ${loop_file#$loop_mountpoint}"
46
+ echo "set root=(loop0)"
51
grub_file_is_not_garbage ()
52
Index: b/util/grub.d/10_linux.in
53
===================================================================
54
--- a/util/grub.d/10_linux.in
55
+++ b/util/grub.d/10_linux.in
57
case ${GRUB_DEVICE} in
58
/dev/loop/*|/dev/loop[0-9])
59
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
60
+ # We can't cope with devices loop-mounted from files here.
61
+ case ${GRUB_DEVICE} in
68
Index: b/util/grub.d/20_linux_xen.in
69
===================================================================
70
--- a/util/grub.d/20_linux_xen.in
71
+++ b/util/grub.d/20_linux_xen.in
73
case ${GRUB_DEVICE} in
74
/dev/loop/*|/dev/loop[0-9])
75
GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
76
+ # We can't cope with devices loop-mounted from files here.
77
+ case ${GRUB_DEVICE} in