Skip to contentSkip to conversation

Fix probing for root on i386-pc where grub files are on same file system as root filesystem

PATCH Superseded Jerone Young 2 participants 4 messages Feb 12, 2007 – Feb 18, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix probing for root on i386-pc where grub files are on same file system as root filesystem

This patch fixes the situation with i386-pc where grub-probe & grube-setup are searching for the root fs for grub files and they happen to be on the same file system as the root ("/") filesystem. If this is the case if when probing /dev , if the partition is a sd* it will not find it because it will find /dev/root first (this is a mistake).

util/i386/pc/getroot.c +7 -0
diff -r cca565f3c398 util/i386/pc/getroot.c
@@ -192,6 +192,13 @@ find_root_device (const char *dir, dev_t
 	  strip_extra_slashes (res);
 	  free (cwd);
 
+	  /* /dev/root is not a real block device keep looking, takes care
+	     of situation where root filesystem is on the same partition as
+	     grub files */
+
+	  if (strcmp(res, "/dev/root") == 0)
+		continue;
+
 	  if (chdir (saved_cwd) < 0)
 	    grub_util_error ("Cannot restore the original directory");
 
#1 lore raw
Quoted 6 lines · Jerone Young

This patch fixes the situation with i386-pc where grub-probe & grube-setup are searching for the root fs for grub files and they happen to be on the same file system as the root ("/") filesystem. If this is the case if when probing /dev , if the partition is a sd* it will not find it because it will find /dev/root first (this is a mistake).

I don't understand. In my system, /dev/root is a symlink, and find_root_device skips symlinks. Why does any problem happen?

Thanks,
Okuji

#2 lore raw

Interesting. I will try this again. I was working with I believe fedora core 6. I noticed this was happening. It is not a symlink on fedora core 6. This may have something to do with udev.

Quoted 20 lines · Yoshinori K. Okuji
Quoted 6 lines · Jerone Young

This patch fixes the situation with i386-pc where grub-probe & grube-setup are searching for the root fs for grub files and they happen to be on the same file system as the root ("/") filesystem. If this is the case if when probing /dev , if the partition is a sd* it will not find it because it will find /dev/root first (this is a mistake).

I don't understand. In my system, /dev/root is a symlink, and find_root_device skips symlinks. Why does any problem happen?

Thanks,
Okuji

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw

So on Fedora and other Redhat systems /dev/root is an actual device node (in this case my root partition is sda1):

[root@localhost grub2]# ls -l /dev/root brw------- 1 root root 8, 1 Feb 17 13:11 /dev/root [root@localhost grub2]# ls -l /dev/sda1 brw-r----- 1 root disk 8, 1 Feb 17 13:12 /dev/sda1

The problem here is once grub sees this it has no idea what /dev/root is so it cannot properly resolve it to /dev/sda1. So the best thing to do is if you see /dev/root to just move on until you find the device node with the real name.

Attached is the patch..along with a change log.

Quoted 4 lines · Jerone Young

Interesting. I will try this again. I was working with I believe fedora core 6. I noticed this was happening. It is not a symlink on fedora core 6. This may have something to do with udev.

Quoted 22 lines
Quoted 20 lines · Yoshinori K. Okuji
Quoted 6 lines · Jerone Young

This patch fixes the situation with i386-pc where grub-probe & grube-setup are searching for the root fs for grub files and they happen to be on the same file system as the root ("/") filesystem. If this is the case if when probing /dev , if the partition is a sd* it will not find it because it will find /dev/root first (this is a mistake).

I don't understand. In my system, /dev/root is a symlink, and find_root_device skips symlinks. Why does any problem happen?

Thanks,
Okuji

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

util/i386/pc/getroot.c +7 -0
diff -r cca565f3c398 util/i386/pc/getroot.c
@@ -192,6 +192,13 @@ find_root_device (const char *dir, dev_t
 	  strip_extra_slashes (res);
 	  free (cwd);
 
+	  /* /dev/root is not a real block device keep looking, takes care
+	     of situation where root filesystem is on the same partition as
+	     grub files */
+
+	  if (strcmp(res, "/dev/root") == 0)
+		continue;
+
 	  if (chdir (saved_cwd) < 0)
 	    grub_util_error ("Cannot restore the original directory");
 
ChangeLog +4 -0
diff -r e6e15bb2da5c ChangeLog
@@ -1,3 +1,7 @@ 2007-02-12  Hollis Blanchard  <hollis@pe
+2007-02-17  Jerone Young <[email protected]>
+	* util/i386/pc/getroot.c: Update so that if root device is /dev/root
+	  continue on and look for device node with real device name.
+
 2007-02-12  Hollis Blanchard  <[email protected]>
 
 	* include/grub/ieee1275/ieee1275.h: Update copyright.