Skip to contentSkip to conversation

grub2: fix a few minor issues in help text

PATCH New Thomas Petazzoni 2 participants 3 messages Jul 1, 2014 – Jul 2, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 grub2: fix a few minor issues in help text

The help text of grub2 explains the detailed steps to create a disk image with grub2 installed on it. However, the steps for the BIOS-based systems have a few minor issues fixed by this patch:

- When calling partx to get the partitions detected, we should do it on the /dev/loop0 block device, and not on the underlying disk.img image file.
- The grub-bios-setup utility must be called as root to work properly on /dev/loop0.
- The steps to cleanup the partx and loop device were missing.

---
 boot/grub2/Config.in | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
boot/grub2/Config.in +6 -3
index b37e024..c6c47b7 100644
@@ -24,17 +24,20 @@ config BR2_TARGET_GRUB2
 		store Grub2. Leaving 1 MB of free space is safe.
 	  3. Setup loop device and loop partitions
 	     sudo losetup -f disk.img
-	     sudo partx -a disk.img
+	     sudo partx -a /dev/loop0
 	  4. Prepare the root partition
 	     sudo mkfs.ext3 -L root /dev/loop0p1
 	     sudo mount /dev/loop0p1 /mnt
 	     sudo tar -C /mnt -xf output/images/rootfs.tar
 	     sudo umount /mnt
 	  5. Install Grub2
-	     ./output/host/usr/sbin/grub-bios-setup \
+	     sudo ./output/host/usr/sbin/grub-bios-setup \
 			-b ./output/host/usr/lib/grub/i386-pc/boot.img \
 			-c ./output/images/grub.img -d . /dev/loop0
-	  6. Your disk.img is ready!
+	  6. Cleanup loop device
+	     sudo partx -d /dev/loop0
+	     sudo losetup -d /dev/loop0
+	  7. Your disk.img is ready!
 
 	  To test your BIOS image in Qemu:
 
Signature · 1 line
2.0.0
#1 lore raw

PATCH 1/1 grub2: fix a few minor issues in help text

Quoted 33 lines · On Tuesday 01 July 2014 19:39:16 Thomas Petazzoni wrote:

The help text of grub2 explains the detailed steps to create a disk image with grub2 installed on it. However, the steps for the BIOS-based systems have a few minor issues fixed by this patch:

- When calling partx to get the partitions detected, we should do it on the /dev/loop0 block device, and not on the underlying disk.img image file.
- The grub-bios-setup utility must be called as root to work properly on /dev/loop0.
- The steps to cleanup the partx and loop device were missing.

---
 boot/grub2/Config.in | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
boot/grub2/Config.in +1 -2
index b37e024..c6c47b7 100644
@@ -24,17 +24,20 @@ config BR2_TARGET_GRUB2
 		store Grub2. Leaving 1 MB of free space is safe.
 	  3. Setup loop device and loop partitions
 	     sudo losetup -f disk.img
-	     sudo partx -a disk.img
+	     sudo partx -a /dev/loop0
 	  4. Prepare the root partition
 	     sudo mkfs.ext3 -L root /dev/loop0p1
 	     sudo mount /dev/loop0p1 /mnt
 	     sudo tar -C /mnt -xf output/images/rootfs.tar
 	     sudo umount /mnt
 	  5. Install Grub2
-	     ./output/host/usr/sbin/grub-bios-setup \

boot/grub2/Config.in config BR2_TARGET_GRUB2 · line 42

Quoted 10 lines
boot/grub2/Config.in +5 -1
+	     sudo ./output/host/usr/sbin/grub-bios-setup \
 			-b ./output/host/usr/lib/grub/i386-pc/boot.img \
 			-c ./output/images/grub.img -d . /dev/loop0
-	  6. Your disk.img is ready!
+	  6. Cleanup loop device
+	     sudo partx -d /dev/loop0
+	     sudo losetup -d /dev/loop0
+	  7. Your disk.img is ready!
 
 	  To test your BIOS image in Qemu:

Just a remark for people who dislike to call sudo in their build scripts:

genimage can be used to create disk image. Installing grub using genimage is the tricky part. It can be done using :

        partition boot {
                in-partition-table = "no"
                image = "path_to_boot.img"
                offset = 0
                size = 512
        }
        partition grub {
                 in-partition-table = "no"
                 image = "path_to_grub.img"
                 offset = 512
        }

The result is not byte to byte identical to result using grub-bios-setup (why?) but it seems it does not matter.

Signature · 3 lines
J?r?me Pouiller, Sysmic
Embedded Linux specialist
http://www.sysmic.fr
#2 lore raw

PATCH 1/1 grub2: fix a few minor issues in help text

Dear J?r?me Pouiller,

(Side-note: could you try to avoid sending your e-mails twice to the mailing list: you're posting to both buildroot at busybox.net and buildroot at uclibc.org. Thanks!)

Quoted 18 lines · J?r?me Pouiller

Just a remark for people who dislike to call sudo in their build scripts:

genimage can be used to create disk image. Installing grub using genimage is the tricky part. It can be done using :

        partition boot {
                in-partition-table = "no"
                image = "path_to_boot.img"
                offset = 0
                size = 512
        }
        partition grub {
                 in-partition-table = "no"
                 image = "path_to_grub.img"
                 offset = 512
        }
Quoted 2 lines

The result is not byte to byte identical to result using grub-bios-setup (why?) but it seems it does not matter.

Really nice! Could you write a patch that extends the Config.in help text of grub2 to include this information? I'm wondering how the writing of the boot.img at offset 0 doesn't overwrite the partition table.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com