Bug#540786: [grub-common] update-grub/grub-mkconfig doesnt work with btrfs as rootfs

2010-01-29 Thread Vladimir Stavrinov

As for me, in chrooted environment, as I wrote above, this problem gone
away for me now and 

grub-probe /

return

ext2

-- 

*
   Vladimir Stavrinov  **
***   v...@inist.ru   *
*




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#540786: [grub-common] update-grub/grub-mkconfig doesnt work with btrfs as rootfs

2010-01-29 Thread Robert Millan
On Thu, Jan 28, 2010 at 10:23:11PM -0500, Joey Hess wrote:
 r...@gnu:/home/joeygrub-probe --target=device / # btrfs
 grub-probe: error: cannot find a device for / (is /dev mounted?).

Ok.  Problem here is not related to lack of btrfs support in GRUB, but to
Linux not providing a match between st_rdev and st_dev (even though a
theoretical match exists).

We're working on that.

 r...@gnu:/home/joeygrub-probe --device /dev/hda2 --target=fs_uuid
 grub-probe: error: unknown filesystem.

UUID fetching itself doesn't sound too much work.  I'll probably implement
this as well.

 I had meant to send the attached patch to #540786 yesterday
 (it's the patch that the patch I sent to #567077 depends on).
 This makes it fall back to the old method of parsing
 the fstab to find the info when grub-probe fails.

Sorry but I want a proper fix.  fstab parsing had its own set of problems
and it was (rightfully, IMO) abandoned.

-- 
Robert Millan

  Be the change you want to see in the world -- Gandhi



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#540786: [grub-common] update-grub/grub-mkconfig doesnt work with btrfs as rootfs

2010-01-28 Thread Robert Millan
tags 540786 - patch
tags 540786 moreinfo
forcemerge 540786 567077
thanks

On Mon, Aug 10, 2009 at 12:56:56PM +0200, Robert Wohlrab wrote:
 The problem is now that grub-probe now tests st_dev of / against st_rdev of 
 the block devices in util/getroot.c find_root_device(..).
  if (S_ISBLK (st.st_mode)  st.st_rdev == dev)
 
 Here the complete struct stat of /dev/sda3
 1: st = {
  [...]
  st_rdev = 2051,
 and of /
 1: st = {
  st_dev = 16,
  [...]

We need some way to match up the files with the device that contains them.
If that's not possible, we won't be able to support /boot in btrfs.

But if you just want grub-mkconfig not to break with btrfs in /, we need more
information on what calls are failing.  There's a gazillon invocations of
grub-probe in there, I can't do anything without knowing which one is causing
the script to fail.

-- 
Robert Millan

  Be the change you want to see in the world -- Gandhi



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#540786: [grub-common] update-grub/grub-mkconfig doesnt work with btrfs as rootfs

2010-01-28 Thread Joey Hess
Robert Millan wrote:
 But if you just want grub-mkconfig not to break with btrfs in /, we need more
 information on what calls are failing.  There's a gazillon invocations of
 grub-probe in there, I can't do anything without knowing which one is causing
 the script to fail.

r...@gnu:/home/joeygrub-probe --target=device /boot # ext3
/dev/hda1
r...@gnu:/home/joeygrub-probe --target=device / # btrfs
grub-probe: error: cannot find a device for / (is /dev mounted?).
r...@gnu:/home/joeygrub-probe --device /dev/hda1 --target=fs_uuid
a2c9d183-7f03-4451-b781-3e8fcd72c095
r...@gnu:/home/joeygrub-probe --device /dev/hda2 --target=fs_uuid
grub-probe: error: unknown filesystem.

I had meant to send the attached patch to #540786 yesterday
(it's the patch that the patch I sent to #567077 depends on).
This makes it fall back to the old method of parsing
the fstab to find the info when grub-probe fails.

See also: https://bugs.launchpad.net/debian/+source/grub2/+bug/450260

-- 
see shy jo
diff -ur old/grub2-1.98~20100126/util/grub-mkconfig.in grub2-1.98~20100126/util/grub-mkconfig.in
--- old/grub2-1.98~20100126/util/grub-mkconfig.in	2010-01-26 13:24:18.0 -0500
+++ grub2-1.98~20100126/util/grub-mkconfig.in	2010-01-26 22:58:03.291261320 -0500
@@ -119,8 +119,9 @@
 fi
 
 # Device containing our userland.  Typically used for root= parameter.
-GRUB_DEVICE=`${grub_probe} --target=device /`
-GRUB_DEVICE_UUID=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2 /dev/null` || true
+GRUB_DEVICE=`${grub_probe} --target=device /` || GRUB_DEVICE=`legacy_find_root_device`
+GRUB_DEVICE_UUID=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2 /dev/null` || \
+GRUB_DEVICE_UUID=`legacy_convert_to_uuid ${GRUB_DEVICE}`
 
 # Device containing our /boot partition.  Usually the same as GRUB_DEVICE.
 GRUB_DEVICE_BOOT=`${grub_probe} --target=device /boot`
diff -ur old/grub2-1.98~20100126/util/grub-mkconfig_lib.in grub2-1.98~20100126/util/grub-mkconfig_lib.in
--- old/grub2-1.98~20100126/util/grub-mkconfig_lib.in	2010-01-26 13:24:18.0 -0500
+++ grub2-1.98~20100126/util/grub-mkconfig_lib.in	2010-01-26 22:58:03.291261320 -0500
@@ -188,3 +188,79 @@
   done
   echo $a
 }
+
+legacy_find_device ()
+{
+mount_point=$1
+
+# Autodetect current root device
+device=
+if [ -f /etc/fstab ] ; then
+device=`awk '$1!~/^#/{
+  if ($2 ~ ^/+$) { $2 = /; } else { sub(/*$, , $2); }
+  if ($2 == '$mount_point'){
+  print $1;
+  }
+  }' /etc/fstab | tail -n 1`
+fi
+
+if [ -n $device ] ; then
+case $device in
+LABEL=* | UUID=*)
+device=`findfs $device`
+device=`readlink -f $device`
+;;
+*)
+device=`readlink -f $device`
+;;
+esac
+fi
+
+echo $device
+}
+
+legacy_find_root_device ()
+{
+echo Cannot determine root device.  Trying legacy probe method 2
+device=`legacy_find_device /`
+
+if [ -z $device ]; then
+echo Cannot determine root device.  Assuming /dev/sda1 2
+echo This error is probably caused by an invalid /etc/fstab 2
+device=/dev/sda1
+fi
+
+echo $device
+}
+
+legacy_convert_to_uuid()
+{
+echo Cannot determine uuid of root device.  Trying legacy probe method 2
+local dev; dev=$1
+
+convert=false
+case $dev in
+/dev/disk/*)
+  ;;
+/dev/mapper/*)
+  ;;
+/dev/evms/[hs]d[a-z][0-9]*)
+convert=:
+  ;;
+/dev/evms/*)
+  ;;
+/dev/md[0-9]*)
+  ;;
+/dev/*)
+convert=:
+  ;;
+esac
+if $convert; then
+if [ -b $dev ]; then
+uuid=`blkid -o value -s UUID $dev || true`
+fi
+fi
+
+echo $uuid
+}
+


signature.asc
Description: Digital signature


Bug#540786: [grub-common] update-grub/grub-mkconfig doesnt work with btrfs as rootfs

2009-08-10 Thread Robert Wohlrab
Package: grub-common
Version: 1.96+20090725-1
Severity: normal

I have following test machine setup:
linux-2.6.31-rc5
/dev/sda2 - ext2 for /boot
/dev/sda3 - btrfs for /
/dev/sda4 - extended
/dev/sda5 - ext4 for /home
/dev/sda6 - swap

The system is booted (added a own block at /boot/grub/grub.cfg). When I run 
`update-grub` or `grub-mkconfig -o /boot/grub/grub.cfg` it just prints
 grub-probe: error: cannot find a device for /.

The problem seems to be that / is different then /dev/sda3

root.st_dev == 16
sda3.st_rdev == 2051

root.st_dev != sda2.st_rdev

If I look at /boot it looks like:
boot.st_dev == 2050
sda2.st_rdev == 2050

Maybe it has something to do with btrfs's subvolume support.

The problem is now that grub-probe now tests st_dev of / against st_rdev of 
the block devices in util/getroot.c find_root_device(..).
 if (S_ISBLK (st.st_mode)  st.st_rdev == dev)

Here the complete struct stat of /dev/sda3
1: st = {
 st_dev = 13,
 st_ino = 3243,
 st_nlink = 1,
 st_mode = 25008,
 st_uid = 0,
 st_gid = 6,
 __pad0 = 0,
 st_rdev = 2051,
 st_size = 0,
 st_blksize = 4096,
 st_blocks = 0,
 st_atim = {tv_sec = 1249898809, tv_nsec = 773817591},
 st_mtim = {tv_sec = 1249898809, tv_nsec = 753815550},
 st_ctim = {tv_sec = 1249891613, tv_nsec = 405308420},
 __unused = {0, 0, 0}}

and of /
1: st = {
 st_dev = 16,
 st_ino = 256,
 st_nlink = 1,
 st_mode = 16877,
 st_uid = 0,
 st_gid = 0,
 __pad0 = 0,
 st_rdev = 0,
 st_size = 286,
 st_blksize = 4096,
 st_blocks = 8,
 st_atim = {tv_sec = 1249891701, tv_nsec = 425313494},
 st_mtim = {tv_sec = 1249891699, tv_nsec = 353312069},
 st_ctim = {tv_sec = 1249891699, tv_nsec = 353312069},
 __unused = {0, 0, 0}}

--- System information. ---
Architecture: amd64
Kernel:   Linux 2.6.31-rc5

Debian Release: squeeze/sid
  500 unstableftp.debian.org 
1 experimentalftp.debian.org 

--- Package information. ---
Depends(Version) | Installed
-+-
libc6   (= 2.3) | 2.9-23
libfreetype6  (= 2.2.1) | 2.3.9-5
libncurses5  (= 5.6+20071006-3) | 5.7+20090803-1
zlib1g  (= 1:1.1.4) | 1:1.2.3.3.dfsg-15
base-files   (= 4.0.1~) | 5.0.0


Package's Recommends field is empty.

Suggests   (Version) | Installed
-+-===
multiboot-doc| 





-- 
Robert Wohlrab



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org