Skip to contentSkip to conversation

grub disk-image builder.

DISCUSSION Franklin PIAT 3 participants 5 messages Jan 23, 2008 – Jan 24, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

For my personal needs, i've written a script to build floppy or hard-disk images.

It's very similar to mkgrub-rescue.sh (and slightly based on it), except the images are formatted. Therefore it's possible to put a grub.cfg and splash images on it.

I'm providing it here for anyone interested.

I could improve it you find some interest in it. (or feel free to fork or adopt it, if you want... it's GPL).

Franklin

#1 lore raw
Quoted 8 lines · Franklin PIAT

Hello,

For my personal needs, i've written a script to build floppy or hard-disk images.

It's very similar to mkgrub-rescue.sh (and slightly based on it), except the images are formatted. Therefore it's possible to put a grub.cfg and splash images on it.

It's already possible to put arbitrary files in grub-mkrescue. Is that what you needed?

If you find that something is missing in grub-mkrescue, I think it's better to get it integrated in the same script rather than providing a collection of utilities.

grub-mkrescue is only aimed at creating floppies (or CD images, although we don't support that too well yet). For disks or disk-like media, grub-install should work. Did you find any drawback or limitation in that method? It's very useful for us that you tell us, since we can't think of every possible use case.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#2 lore raw
Quoted 10 lines · Robert Millan
Quoted 8 lines · Franklin PIAT

Hello,

For my personal needs, i've written a script to build floppy or hard-disk images.

It's very similar to mkgrub-rescue.sh (and slightly based on it), except the images are formatted. Therefore it's possible to put a grub.cfg and splash images on it.

Quoted 6 lines

It's already possible to put arbitrary files in grub-mkrescue. Is that what you needed?

If you find that something is missing in grub-mkrescue, I think it's better to get it integrated in the same script rather than providing a collection of utilities.

I've just had a look at yesterday's commit, which introduces --overlay. great ! (Debian's Unstable is a few day behind cvs)

Since I wanted to test splashscreen, I needed to put unicode.pff (1480KiB) + a tga image (1200KiB uncompressed)... That's why i came up with hard disk images.

But now, with RLE'd TGA, JPEG and PNG, 2.88MiB floppy should do in most case (I haven't tested it).

I've attached a patch for "--image-size" option. (it's GPL)

The one feature that one could miss, is the ability to mount and modify the image, to easily customize rescue's grub.cfg, from a random Operating system that understand fat. -- I don't need that feature.

Franklin

Quoted 5 lines

grub-mkrescue is only aimed at creating floppies (or CD images, although we don't support that too well yet). For disks or disk-like media, grub-install should work. Did you find any drawback or limitation in that method? It's very useful for us that you tell us, since we can't think of every possible use case.

grub-mkrescue.in?revision=1.5 renamed from grub-mkrescue.in?revision=1.5-orig +11 -1
@@ -46,6 +46,7 @@
   --pkglibdir=DIR         use images from directory DIR instead of ${pkglibdir}
   --grub-mkimage=FILE     use FILE as grub-mkimage
   --image-type=TYPE       select floppy or cdrom (default)
+  --image-size=1440       size of the image size (720, 1440 or 2880 KiB).
 
 grub-mkimage generates a bootable rescue image of the specified type.
 
@@ -54,6 +55,7 @@
 }
 
 image_type=cdrom
+image_size=1440
 input_dir=${pkglibdir}
 grub_mkimage=grub-mkimage
 
@@ -82,6 +84,14 @@
             echo "Unknown image type \`$image_type'" 1>&2
             exit 1 ;;
         esac ;;
+    --image-size=*)
+    	image_size=`echo "$option" | sed 's/--image-size=//'`
+        case "$image_size" in
+          720|1440|2880) ;;
+          *)
+            echo "Invalid image size \`$image_size'" 1>&2
+            exit 1 ;;
+        esac ;;
     -*)
 	echo "Unrecognized option \`$option'" 1>&2
 	usage
@@ -125,7 +135,7 @@
 core_img=`mktemp`
 ${grub_mkimage} -d ${input_dir}/ -m ${memdisk_img} -o ${core_img} memdisk cpio biosdisk ${modules}
 rm -f ${memdisk_img}
-cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > $floppy_image
+cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=${image_size} > $floppy_image
 rm -f ${core_img}
 
 if [ "x${image_type}" = "xfloppy" ] ; then
#3 lore raw
Quoted 9 lines · Franklin PIAT

I've just had a look at yesterday's commit, which introduces --overlay. great ! (Debian's Unstable is a few day behind cvs)

Since I wanted to test splashscreen, I needed to put unicode.pff (1480KiB) + a tga image (1200KiB uncompressed)... That's why i came up with hard disk images.

But now, with RLE'd TGA, JPEG and PNG, 2.88MiB floppy should do in most case (I haven't tested it).

Unfrotunately it can't use more than ~600 kiB without overwriting the vga region (and others), so this is prevented in grub-mkimage.

This limitation can be resolved by putting the filesystem at the beginning of the device, and moving our code out of the way, just like we do for normal boot from hard disk.

You should be able to do this with grub-install (either on floppy or bigger devices). Does this work for you?

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#4 lore raw
In reply to Robert Millan
Quoted 17 lines · Robert Millan
Quoted 8 lines · Franklin PIAT

Hello,

For my personal needs, i've written a script to build floppy or hard-disk images.

It's very similar to mkgrub-rescue.sh (and slightly based on it), except the images are formatted. Therefore it's possible to put a grub.cfg and splash images on it.

It's already possible to put arbitrary files in grub-mkrescue. Is that what you needed?

If you find that something is missing in grub-mkrescue, I think it's better to get it integrated in the same script rather than providing a collection of utilities.

Quoted 5 lines

grub-mkrescue is only aimed at creating floppies (or CD images, although we don't support that too well yet). For disks or disk-like media, grub-install should work. Did you find any drawback or limitation in that method? It's very useful for us that you tell us, since we can't think of every possible use case.

It would be useful, for testing, if grub-mkrescue can make a floppy/hd image with a filesystem on it. IIRC it can't make hd images yet, right?

--
Marco