Create floppy emulation boot CD with grub-mkimage
PATCH 1/1 Create floppy emulation boot CD with grub-mkimage
A CD created by "grub-mkrescue --image-type=cdrom" does not work for me for some reason. Is it probably necessary to supply -boot-load-seg to genisoimage?
But booting a grub2 rescue floppy image in El Torito emulation mode works. This patch adds the image type "floppycd" to create such a CD.
Christian
2008-02-08 Christian Franke <[email protected]>
* util/i386/pc/grub-mkrescue.in: Add --image-type=floppycd to create a floppy emulation boot CD when non emulation mode does not work.
util/i386/pc/grub-mkrescue.in +16 -4
@@ -45,7 +45,7 @@ Make GRUB rescue image. --overlay=DIR overlay directory DIR in the memdisk image --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-type=TYPE select floppy, floppycd, or cdrom (default) grub-mkimage generates a bootable rescue image of the specified type.
@@ -77,7 +77,7 @@ for option in "$@"; do --image-type=*) image_type=`echo "$option" | sed 's/--image-type=//'` case "$image_type" in - floppy|cdrom) ;; + floppy|floppycd|cdrom) ;; *) echo "Unknown image type \`$image_type'" 1>&2 exit 1 ;;
@@ -113,7 +113,7 @@ if test "x$overlay" = x ; then : ; else cp -dpR ${overlay}/* ${aux_dir}/ fi -if [ "x${image_type}" = "xfloppy" ] ; then +if [ "x${image_type}" = "xfloppy" -o "x${image_type}" = "xfloppycd" ] ; then # build memdisk memdisk_img=`mktemp` tar -C ${aux_dir} -cf ${memdisk_img} boot
@@ -125,8 +125,20 @@ if [ "x${image_type}" = "xfloppy" ] ; th rm -f ${memdisk_img} # build floppy image - cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > $output_image + if [ "x${image_type}" = "xfloppycd" ] ; then + floppy_dir=`mktemp -d` + floppy_img=${floppy_dir}/grub_floppy + else + floppy_img=${output_image} + fi + cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${floppy_img} rm -f ${core_img} + + if [ "x${image_type}" = "xfloppycd" ] ; then + # build iso image + genisoimage -b grub_floppy -o ${output_image} -r ${floppy_dir} + rm -rf ${floppy_dir} + fi else # build core.img core_img=`mktemp`
Quoted 2 lines · Christian Franke
A CD created by "grub-mkrescue --image-type=cdrom" does not work for me for some reason.
This is AFAIK the most widely used method for CD boot. Do other CDs work for you?
If this is a bug, I think it's better to fix it instead of adding workarounds.
Quoted 2 lines
Is it probably necessary to supply -boot-load-seg to genisoimage?
Could you test that?
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 /.)
Quoted 9 lines · Robert Millan
Quoted 2 lines · Christian Franke
A CD created by "grub-mkrescue --image-type=cdrom" does not work for me for some reason.
This is AFAIK the most widely used method for CD boot. Do other CDs work for you?
Yes, all of my boot CDs work :-)
Meantime, I found the problem: cdboot.img was > 512 bytes. I forgot to add the ld script necessary for the Cygwin build (-N does not work). Should have checked this first, sorry.
Now the CD boots, but the result is interesting:
Real PC: escape to rescue mode, root=hd31, no (cd0) device, no modules.
VMWare: same.
VirtualPC: escape to rescue mode, root=cd15, (cd0) exists, normal mode can be started manually.
VirtualBox: Works as expected.
Both floppy and "floppy(on)cd" both work as expected.
Quoted 3 lines
If this is a bug, I think it's better to fix it instead of adding workarounds.
Yes, but the patch provides the end-user with a simple way to create a fall back boot CD when the normal boot CD does not work for whatever reason. And the patch does not break anything existing.
Christian
Quoted 6 lines · Christian Franke
Yes, all of my boot CDs work :-)
Meantime, I found the problem: cdboot.img was > 512 bytes. I forgot to add the ld script necessary for the Cygwin build (-N does not work). Should have checked this first, sorry.
Is this a remaining patch that was needed for Cygwin?
Quoted 10 lines
Now the CD boots, but the result is interesting:
Real PC: escape to rescue mode, root=hd31, no (cd0) device, no modules.
VMWare: same.
VirtualPC: escape to rescue mode, root=cd15, (cd0) exists, normal mode can be started manually.
VirtualBox: Works as expected.
Interesting, yes. But no idea what it means :-(
Maybe Bean will know ...
Quoted 6 lines
Quoted 2 lines
If this is a bug, I think it's better to fix it instead of adding workarounds.
Yes, but the patch provides the end-user with a simple way to create a fall back boot CD when the normal boot CD does not work for whatever reason. And the patch does not break anything existing.
You could ask Marco or Okuji and see what they think about it. If they agree with you, I'll have to shut up ;-)
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 /.)
Quoting Robert Millan <[email protected]>:
Quoted 2 lines
You could ask Marco or Okuji and see what they think about it. If they agree with you, I'll have to shut up ;-)
I'm neither of both, but here are my two cents:
I think it's a good idea. Many old BIOSes are buggy when it comes to CD-ROM boot support. Having an extra option doesn't hurt, especially for rescuing the system. The change doesn't bloat the bootloader, it only enlarges an extra script slightly. Having a bootable floppy image on a CD could be handy in some circumstances. Maintenance is easy, since both CD images can be checked in qemu.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 9 lines · Pavel Roskin
Quoting Robert Millan <[email protected]>:
Quoted 2 lines
You could ask Marco or Okuji and see what they think about it. If they agree with you, I'll have to shut up ;-)
I'm neither of both, but here are my two cents:
I think it's a good idea. Many old BIOSes are buggy when it comes to CD-ROM boot support.
Well, if you're sure about that, then I don't mind.
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 /.)
Quoted 10 lines · Robert Millan
Quoted 4 lines · Christian Franke
Yes, all of my boot CDs work :-)
Meantime, I found the problem: cdboot.img was > 512 bytes. I forgot to add the ld script necessary for the Cygwin build (-N does not work). Should have checked this first, sorry.
Is this a remaining patch that was needed for Cygwin?
This it is a small update to the "[PATCH] Build on Cygwin" posted here 2007-11-23, no feedback yet.
Quoted 4 lines
Quoted 4 lines
Now the CD boots, but the result is interesting:
Real PC: escape to rescue mode, root=hd31, no (cd0) device, no modules.
Quoted 10 lines
Quoted 6 lines
VMWare: same.
VirtualPC: escape to rescue mode, root=cd15, (cd0) exists, normal mode can be started manually.
VirtualBox: Works as expected.
Interesting, yes. But no idea what it means :-(
I will investigate this further ...
Christian
Quoted 3 lines · Christian Franke
This it is a small update to the "[PATCH] Build on Cygwin" posted here 2007-11-23, no feedback yet.
Ok, I just replied.
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 /.)
Quoted 20 lines · Robert Millan
Quoted 6 lines · Christian Franke
Yes, all of my boot CDs work :-)
Meantime, I found the problem: cdboot.img was > 512 bytes. I forgot to add the ld script necessary for the Cygwin build (-N does not work). Should have checked this first, sorry.
Is this a remaining patch that was needed for Cygwin?
Quoted 10 lines
Now the CD boots, but the result is interesting:
Real PC: escape to rescue mode, root=hd31, no (cd0) device, no modules.
VMWare: same.
VirtualPC: escape to rescue mode, root=cd15, (cd0) exists, normal mode can be started manually.
VirtualBox: Works as expected.
For VirtualPC, try the following patch:
kern/i386/pc/init.c +3 -3
@@ -77,9 +77,9 @@ make_install_device (void)if (grub_root_drive ==0xFF ) grub_root_drive = grub_boot_drive; -if (grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) -grub_sprintf (dev,"(cd%u" , - grub_root_drive -GRUB_BIOSDISK_MACHINE_CDROM_START ); +if ((grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) && + (grub_root_drive <GRUB_BIOSDISK_MACHINE_CDROM_END )) +grub_strcpy (dev,"(cd0)" );else grub_sprintf (dev, "(%cd%u", (grub_root_drive & 0x80) ? 'h' : 'f',
For Real PC, you should be able to fix it by setting GRUB_BIOSDISK_MACHINE_CDROM_START to 0x9F in /include/grub/i386/pc/biosdisk.h, but i don't recommend using it as default value.
Signature · 1 line
Bean
kern/i386/pc/init.c make_install_device (void) · line 85
Quoted 12 lines · Bean
if (grub_root_drive == 0xFF) grub_root_drive = grub_boot_drive;kern/i386/pc/init.c +3
-3-if (grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) -grub_sprintf (dev,"(cd%u" , - grub_root_drive -GRUB_BIOSDISK_MACHINE_CDROM_START ); +if ((grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) && + (grub_root_drive <GRUB_BIOSDISK_MACHINE_CDROM_END )) +grub_strcpy (dev,"(cd0)" );else grub_sprintf (dev, "(%cd%u", (grub_root_drive & 0x80) ? 'h' : 'f',
I'm confused by this. Did you mean the opposite? I.e. when grub_root_drive is out of bounds, set dev to cd0.
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 /.)
Quoted 14 lines · Robert Millan
kern/i386/pc/init.c make_install_device (void) · line 85
Quoted 12 lines · Bean
if (grub_root_drive == 0xFF) grub_root_drive = grub_boot_drive;kern/i386/pc/init.c +3
-3-if (grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) -grub_sprintf (dev,"(cd%u" , - grub_root_drive -GRUB_BIOSDISK_MACHINE_CDROM_START ); +if ((grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) && + (grub_root_drive <GRUB_BIOSDISK_MACHINE_CDROM_END )) +grub_strcpy (dev,"(cd0)" );else grub_sprintf (dev, "(%cd%u", (grub_root_drive & 0x80) ? 'h' : 'f',
Quoted 2 lines
I'm confused by this. Did you mean the opposite? I.e. when
grub_root_driveis out of bounds, set dev to cd0.
in biosdisk, cdrom drive is probed from GRUB_BIOSDISK_MACHINE_CDROM_START to GRUB_BIOSDISK_MACHINE_CDROM_END, the first one found is treated as (cd0).
Signature · 1 line
Bean
Quoted 25 lines · Bean
Quoted 6 lines
...
Quoted 4 lines
Now the CD boots, but the result is interesting:
Real PC: escape to rescue mode, root=hd31, no (cd0) device, no modules.
Quoted 7 lines
Quoted 7 lines
VMWare: same.
VirtualPC: escape to rescue mode, root=cd15, (cd0) exists, normal mode can be started manually.
VirtualBox: Works as expected.
For VirtualPC, try the following patch:
kern/i386/pc/init.c +0
-0@@ -77,9 +77,9 @@ make_install_device (void)if (grub_root_drive ==0xFF ) grub_root_drive = grub_boot_drive;
kern/i386/pc/init.c make_install_device (void) · line 85
Quoted 10 lines
kern/i386/pc/init.c +3
-3-if (grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) -grub_sprintf (dev,"(cd%u" , - grub_root_drive -GRUB_BIOSDISK_MACHINE_CDROM_START ); +if ((grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) && + (grub_root_drive <GRUB_BIOSDISK_MACHINE_CDROM_END )) +grub_strcpy (dev,"(cd0)" );else grub_sprintf (dev, "(%cd%u", (grub_root_drive & 0x80) ? 'h' : 'f',
Thanks. This works, after changing "(cd0)" to "(cd0" :-)
Quoted 6 lines
For Real PC, you should be able to fix it by setting
GRUB_BIOSDISK_MACHINE_CDROM_STARTto0x9Fin /include/grub/i386/pc/biosdisk.h, but i don't recommend using it as default value.
With this change, the rescue CD works also on the real PC (Asus MB with Phoenix Award BIOS) and VMware.
I have added this to get diagnostic output of boot/root_drive:
kern/i386/pc/init.c 2008-02-09 17:01:17.093750000 +0100 renamed from kern/i386/pc/init.c 2008-02-03 20:29:53.125000000 +0100 +0 -0
@@ -247,6 +247,12 @@
voidgrub_machine_set_prefix (void)
{
+ char val[20];
+ grub_sprintf (val, "0x%02x", grub_boot_drive);
+ grub_env_set ("drive_boot", val);
+ grub_sprintf (val, "0x%02x", grub_root_drive);
+ grub_env_set ("drive_root", val);+
/* Initialize the prefix. */ grub_env_set ("prefix", make_install_device ());
}
Results:
PC: grub_boot_drive=0x9f, but INT13 Extensions reported for 0x9f
VMware: grub_boot_drive=0x9f
VirtualPC: grub_boot_drive=0xef
VirtualBox: grub_boot_drive=0xe0
GRUB_MOD_INIT(biosdisk) detects INT13 Extensions for 0x9f on the real PC, therefore "(cd0)" does not appear in "ls" output. Nevertheless, access to (cd0) and everthing else works as expected due to the default setting of biosdisk.c::cd_start = 0x9f.
But this won't work with any other setting of GRUB_BIOSDISK_MACHINE_CDROM_START.
Conclusions:
- I like standards, because there are so many to choose from :-)
- We probably should discuss boot CD drive detection in a new thread.
- A floppy emulation rescue CD as a last resort makes sense ;-)
Christian
Quoted 89 lines · Christian Franke
Quoted 25 lines · Bean
Quoted 6 lines
...
Quoted 4 lines
Now the CD boots, but the result is interesting:
Real PC: escape to rescue mode, root=hd31, no (cd0) device, no modules.
Quoted 7 lines
Quoted 7 lines
VMWare: same.
VirtualPC: escape to rescue mode, root=cd15, (cd0) exists, normal mode can be started manually.
VirtualBox: Works as expected.
For VirtualPC, try the following patch:
kern/i386/pc/init.c +0
-0@@ -77,9 +77,9 @@ make_install_device (void)if (grub_root_drive ==0xFF ) grub_root_drive = grub_boot_drive;kern/i386/pc/init.c make_install_device (void) · line 85
Quoted 10 lines
kern/i386/pc/init.c +3
-3-if (grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) -grub_sprintf (dev,"(cd%u" , - grub_root_drive -GRUB_BIOSDISK_MACHINE_CDROM_START ); +if ((grub_root_drive >=GRUB_BIOSDISK_MACHINE_CDROM_START ) && + (grub_root_drive <GRUB_BIOSDISK_MACHINE_CDROM_END )) +grub_strcpy (dev,"(cd0)" );else grub_sprintf (dev, "(%cd%u", (grub_root_drive & 0x80) ? 'h' : 'f',Thanks. This works, after changing "(cd0)" to "(cd0" :-)
Quoted 6 lines
For Real PC, you should be able to fix it by setting
GRUB_BIOSDISK_MACHINE_CDROM_STARTto0x9Fin /include/grub/i386/pc/biosdisk.h, but i don't recommend using it as default value.With this change, the rescue CD works also on the real PC (Asus MB with Phoenix Award BIOS) and VMware.
I have added this to get diagnostic output of boot/root_drive:
kern/i386/pc/init.c 2008-02-09 17:01:17.093750000 +0100 renamed from kern/i386/pc/init.c 2008-02-03 20:29:53.125000000 +0100 +6
-0@@ -247,6 +247,12 @@ void grub_machine_set_prefix (void) { + char val[20]; + grub_sprintf (val, "0x%02x", grub_boot_drive); + grub_env_set ("drive_boot", val); + grub_sprintf (val, "0x%02x", grub_root_drive); + grub_env_set ("drive_root", val); + /* Initialize the prefix. */ grub_env_set ("prefix", make_install_device ()); }Results:
PC: grub_boot_drive=0x9f, but INT13 Extensions reported for
0x9fVMware: grub_boot_drive=0x9f
VirtualPC: grub_boot_drive=0xef
VirtualBox: grub_boot_drive=0xe0
GRUB_MOD_INIT(biosdisk)detects INT13 Extensions for0x9fon the real PC, therefore "(cd0)" does not appear in "ls" output. Nevertheless, access to (cd0) and everthing else works as expected due to the default setting ofbiosdisk.c::cd_start=0x9f.But this won't work with any other setting of
GRUB_BIOSDISK_MACHINE_CDROM_START.
Quoted 6 lines
Conclusions:
- I like standards, because there are so many to choose from :-)
- We probably should discuss boot CD drive detection in a new thread.
- A floppy emulation rescue CD as a last resort makes sense ;-)Christian
I don't know which drive to start scanning for cdrom. 0x9F means at most 31 hard drives, i think it's fine for the most time.
Signature · 1 line
Bean
Quoted 19 lines · Bean
Quoted 17 lines · Christian Franke
...
Results:PC: grub_boot_drive=0x9f, but INT13 Extensions reported for
0x9fVMware: grub_boot_drive=0x9f
VirtualPC: grub_boot_drive=0xef
VirtualBox: grub_boot_drive=0xe0
GRUB_MOD_INIT(biosdisk)detects INT13 Extensions for0x9fon the real PC, therefore "(cd0)" does not appear in "ls" output. Nevertheless, access to (cd0) and everthing else works as expected due to the default setting ofbiosdisk.c::cd_start=0x9f.
Quoted 7 lines
Quoted 2 lines
...
I don't know which drive to start scanning for cdrom.
0x9Fmeans at most 31 hard drives, i think it's fine for the most time.
Agree.
Sorry, my info was wrong, it should read:
PC: Reports INT13 Extensions *not* available for drive 0x9f.
All VMs: INT13 Extensions available for grub_boot_drive.
CD device scanning fails if BIOS reports no INT13 Extensions for the boot CD drive. I will post a patch in a new thread. Please apply your init.c "(cd0" patch also, as it is necessary if grub_boot_drive is not equal to ..._CDROM_START.
Christian
util/i386/pc/grub-mkrescue.in Make GRUB rescue image. · line 48
Quoted 5 lines · Christian Franke
--overlay=DIR overlay directory DIR in the memdisk image --pkglibdir=DIR use images from directory DIR instead of ${pkglibdir} --grub-mkimage=FILE use FILE as grub-mkimageutil/i386/pc/grub-mkrescue.in +1
-1- --image-type=TYPE select floppy or cdrom (default) + --image-type=TYPE select floppy, floppycd, or cdrom (default)
I find this user interface confusing. How does one know what "floppycd" means?
I think it'd be much easier to understand if this was a separate option, something like:
--image-type=TYPE select floppy or cdrom (default)
--some-option explain what it does
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 /.)
Quoted 9 lines · Robert Millan
util/i386/pc/grub-mkrescue.in Make GRUB rescue image. · line 48
Quoted 6 lines · Christian Franke
--overlay=DIR overlay directory DIR in the memdisk image --pkglibdir=DIR use images from directory DIR instead of ${pkglibdir} --grub-mkimage=FILE use FILE as grub-mkimageutil/i386/pc/grub-mkrescue.in +1
-1- --image-type=TYPE select floppy or cdrom (default) + --image-type=TYPE select floppy, floppycd, or cdrom (default)
Quoted 9 lines
I find this user interface confusing. How does one know what "floppycd" means?
I think it'd be much easier to understand if this was a separate option, something like:
--image-type=TYPE select floppy or cdrom (default)
--some-option explain what it does
Good point.
--emulation create floppy emulation cdrom image
Christian
Quoted 16 lines · Christian Franke
Quoted 15 lines · Robert Millan
util/i386/pc/grub-mkrescue.in Make GRUB rescue image. · line 48
Quoted 7 lines · Christian Franke
--overlay=DIR overlay directory DIR in the memdisk image
--pkglibdir=DIR use images from directory DIR instead of
${pkglibdir}
--grub-mkimage=FILE use FILE as grub-mkimageutil/i386/pc/grub-mkrescue.in +1
-1- --image-type=TYPE select floppy or cdrom (default) + --image-type=TYPE select floppy, floppycd, or cdrom (default)I find this user interface confusing. How does one know what "floppycd" means?
I think it'd be much easier to understand if this was a separate option, something like:
Quoted 9 lines
Quoted 4 lines
--image-type=TYPE select floppy or cdrom (default)
--some-option explain what it doesGood point.
--emulation create floppy emulation cdrom image
or
--boot-type=(native|emulation)
select cdrom native (default) or floppy emulation
boot type
Christian
Quoted 25 lines · Christian Franke
Quoted 24 lines · Christian Franke
Quoted 10 lines · Robert Millan
util/i386/pc/grub-mkrescue.in Make GRUB rescue image. · line 48
Quoted 7 lines · Christian Franke
--overlay=DIR overlay directory DIR in the memdisk image
--pkglibdir=DIR use images from directory DIR instead of
${pkglibdir}
--grub-mkimage=FILE use FILE as grub-mkimageutil/i386/pc/grub-mkrescue.in +1
-1- --image-type=TYPE select floppy or cdrom (default) + --image-type=TYPE select floppy, floppycd, or cdrom (default)Quoted 10 lines
I find this user interface confusing. How does one know what "floppycd" means?
I think it'd be much easier to understand if this was a separate option, something like:
--image-type=TYPE select floppy or cdrom (default)
--some-option explain what it doesGood point.
Quoted 8 lines
Quoted 2 lines
--emulation create floppy emulation cdrom image
or
--boot-type=(native|emulation)
select cdrom native (default) or floppy emulation
boot type
Since it is a flag for enabling a compatibility option, I think it's more like a boolean.
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 /.)
Quoted 6 lines · Robert Millan
Quoted 3 lines
--boot-type=(native|emulation)
select cdrom native (default) or floppy emulation
boot typeSince it is a flag for enabling a compatibility option, I think it's more like a boolean.
Actually, there is also hard drive emulation, which might be useful for USB flash keys eventually, so it's not a boolean option. But we can always change it later.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 7 lines · Pavel Roskin
Quoted 4 lines · Robert Millan
Quoted 4 lines
--boot-type=(native|emulation)
select cdrom native (default) or floppy emulation
boot type
Quoted 9 lines
Quoted 3 lines
Since it is a flag for enabling a compatibility option, I think it's more like a boolean.
Actually, there is also hard drive emulation, which might be useful for USB flash keys eventually, so it's not a boolean option. But we can always change it later.
There is a hdd emulation mode for bootable CD in the El Torito standard.
AFIAK, there is no emulation mode for bootable USB flash keys. Their images are identical to large floppies ("superfloppy" without partitions) or hard disks (with partitions). Some BIOS boot both types, some don't.
This results in 6 possible image variants:
1. Floppy: --image-type=floppy 2. CD, no emulation: --image-type=cdrom [--emulation=none] 3. CD, floppy emulation: --image-type=cdrom --emulation=floppy 4. CD, hdd emulation: --image-type=cdrom --emulation=hdd
5. USB without partitions: --image-type=superfloppy
6. USB with partitions: --image-type=hdd
It may be possible to use the image #1 as image #5.
Christian
Quoted 11 lines · Christian Franke
This results in 6 possible image variants:
1. Floppy: --image-type=floppy 2. CD, no emulation: --image-type=cdrom [--emulation=none] 3. CD, floppy emulation: --image-type=cdrom --emulation=floppy 4. CD, hdd emulation: --image-type=cdrom --emulation=hdd5. USB without partitions: --image-type=superfloppy
6. USB with partitions: --image-type=hddIt may be possible to use the image #1 as image #5.
I don't think it is really practical to support USB drives in grub-mkrescue. You'd have to require root permissions, which IMO beats the point of having a separate script from grub-install in first place.
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 /.)
Quoted 11 lines · Robert Millan
Quoted 9 lines · Christian Franke
This results in 6 possible image variants:
1. Floppy: --image-type=floppy 2. CD, no emulation: --image-type=cdrom [--emulation=none] 3. CD, floppy emulation: --image-type=cdrom --emulation=floppy 4. CD, hdd emulation: --image-type=cdrom --emulation=hdd5. USB without partitions: --image-type=superfloppy
6. USB with partitions: --image-type=hdd
Quoted 8 lines
Quoted 2 lines
It may be possible to use the image #1 as image #5.
I don't think it is really practical to support USB drives in grub-mkrescue. You'd have to require root permissions, which IMO beats the point of having a separate script from grub-install in first place.
It may be useful to create small rescue images which can be later put on USB key with dd. (BTW: The "floppy" image actually boots from USB at least on one of my PC. It appears as hd0).
Here a new patch, it uses the --emulation=floppy syntax from above.
My recent tests (see "[PATCH] Ensure boot CD can be accessed") show that direct CD boot might always not work.
The patch also adds a --joliet option, useful to access the long file names on Windows (which has no RR support).
Christian
2008-02-15 Christian Franke <[email protected]>
* util/i386/pc/grub-mkrescue.in: Add --emulation=floppy to create a floppy emulation boot CD when non emulation mode does not work.
Add --joliet to enable Joliet cdrom filesystem extension.
util/i386/pc/grub-mkrescue.in +30 -3
@@ -46,6 +46,8 @@ Make GRUB rescue image. --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) + --emulation=TYPE select boot emulation type floppy, or none (default) + --joliet enable Joliet filesystem extension (cdrom only) grub-mkimage generates a bootable rescue image of the specified type.
@@ -56,6 +58,8 @@ EOF image_type=cdrom input_dir=${pkglibdir} grub_mkimage=grub-mkimage +emulation=none +joliet= # Check the arguments. for option in "$@"; do
@@ -82,6 +86,16 @@ for option in "$@"; do echo "Unknown image type \`$image_type'" 1>&2 exit 1 ;; esac ;; + --emulation=*) + emulation=`echo "$option" | sed 's/--emulation=//'` + case "$emulation" in + floppy|none) ;; + *) + echo "Unknown emulation type \`$emulation'" 1>&2 + exit 1 ;; + esac ;; + --joliet) + joliet="-J" ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage
@@ -113,7 +127,7 @@ if test "x$overlay" = x ; then : ; else cp -dpR ${overlay}/* ${aux_dir}/ fi -if [ "x${image_type}" = "xfloppy" ] ; then +if [ "x${image_type}" = xfloppy -o "x${emulation}" = xfloppy ] ; then # build memdisk memdisk_img=`mktemp` tar -C ${aux_dir} -cf ${memdisk_img} boot
@@ -125,8 +139,21 @@ if [ "x${image_type}" = "xfloppy" ] ; th rm -f ${memdisk_img} # build floppy image - cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > $output_image + if [ "x${image_type}" = xcdrom ] ; then + floppy_dir=`mktemp -d` + floppy_img=${floppy_dir}/grub_floppy.img + else + floppy_img=${output_image} + fi + cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${floppy_img} rm -f ${core_img} + + if [ "x${image_type}" = xcdrom ] ; then + # build iso image + genisoimage -b grub_floppy.img \ + -o ${output_image} -r ${joliet} ${floppy_dir} + rm -rf ${floppy_dir} + fi else # build core.img core_img=`mktemp`
@@ -139,7 +166,7 @@ else # build iso image genisoimage -b boot/grub/grub_eltorito \ -no-emul-boot -boot-load-size 4 -boot-info-table \ - -o ${output_image} -r ${aux_dir} + -o ${output_image} -r ${joliet} ${aux_dir} rm -rf ${aux_dir} fi
Quoted 10 lines · Christian Franke
Quoted 5 lines
I don't think it is really practical to support USB drives in grub-mkrescue.
You'd have to require root permissions, which IMO beats the point of having a separate script from grub-install in first place.It may be useful to create small rescue images which can be later put on USB key with dd.
(BTW: The "floppy" image actually boots from USB at least on one of my PC. It appears as hd0).
Yes, but how different would those be from floppy output? As you point out, floppy images work as well.
Besides, dd'ing a grub image to that stick would render the rest of the device useless for filesystem data.
Quoted 2 lines
The patch also adds a --joliet option, useful to access the long file names on Windows (which has no RR support).
Is there any drawback in using --joliet ? If not, I think it's better to do it by default to avoid "option creep".
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 /.)
Quoted 6 lines · Robert Millan
Quoted 4 lines · Christian Franke
Quoted 4 lines
I don't think it is really practical to support USB drives in grub-mkrescue. You'd have to require root permissions, which IMO beats the point of having a separate script from grub-install in first place.
Quoted 8 lines
Quoted 3 lines
It may be useful to create small rescue images which can be later put on USB key with dd. (BTW: The "floppy" image actually boots from USB at least on one of my PC. It appears as hd0).
Yes, but how different would those be from floppy output? As you point out, floppy images work as well.
For a BIOS which handles USB flash drives like USB hard drives, a valid hard disk boot sector with a partition table should be present.
With the floppy image, GRUB detects bogus partitions on (hd0), because boot.img contains the "floppy_probe" code in the partition table space. The boot sector is also not properly patched for hdd (need to replace jmp by nop at "boot_drive_check").
But it actually works without any change.
Quoted 4 lines
Besides, dd'ing a grub image to that stick would render the rest of the device useless for filesystem data.
Yes. But if you need a rescue boot device when floppy or CD cannot be used for some reason, you probably do not care about this :-)
It may be possible to produce a rescue image with a valid partition table such that a filesystem partition can be added later.
Otherwise, grub-setup/install may work to install grub on an USB flash drive which has partition table and filesystem.
Quoted 7 lines
Quoted 2 lines
The patch also adds a --joliet option, useful to access the long file names on Windows (which has no RR support).
Is there any drawback in using --joliet ? If not, I think it's better to do it by default to avoid "option creep".
I'm not aware of any drawback.
Christian
Hi Robert and Frankie,
I would like to understand is it possible to install grub on usb?
i would like to do rescue disk,
and what are the steps you have done in-order to install grub in the usb,
What grub version did you used?
any code change in this version ?
i am working on suse 10.3 and fedora 7 linux dist
thanks Tsah
Quoted 41 lines · Robert Millan
Quoted 4 lines · Christian Franke
Quoted 4 lines
I don't think it is really practical to support USB drives in grub-mkrescue.
You'd have to require root permissions, which IMO beats the point ofhaving
Quoted 6 lines
Quoted 1 line
a separate script from grub-install in first place.
It may be useful to create small rescue images which can be later put on USB key with dd.
(BTW: The "floppy" image actually boots from USB at least on one of my PC. It appears as hd0).Yes, but how different would those be from floppy output? As you point out,
floppy images work as well.Besides, dd'ing a grub image to that stick would render the rest of the device
useless for filesystem data.Quoted 2 lines
The patch also adds a --joliet option, useful to access the long file names on Windows (which has no RR support).
Is there any drawback in using --joliet ? If not, I think it's better to do
it by default to avoid "option creep".--
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 /.)
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 5 lines
Tsah Marco Cel - 972-54-5414357 Home - 972-774240642 Fax - 972-77-4240642
Quoted 11 lines · Robert Millan
On Fri, Feb 15, 2008 at 11:32:49PM +0100, Christian Franke wrote:
...
Quoted 2 lines
The patch also adds a --joliet option, useful to access the long file names on Windows (which has no RR support).
Is there any drawback in using --joliet ? If not, I think it's better to do it by default to avoid "option creep".
Here a new version of the patch with Joliet enabled always. Should not break anything.
Christian
2008-03-01 Christian Franke <[email protected]>
* util/i386/pc/grub-mkrescue.in: Add --emulation=floppy to create a floppy emulation boot CD when non emulation mode does not work.
Enable Joliet CD filesystem extension.
util/i386/pc/grub-mkrescue.in +26 -3
@@ -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) + --emulation=TYPE select boot emulation type floppy or none (default) grub-mkimage generates a bootable rescue image of the specified type.
@@ -56,6 +57,7 @@ image_type=cdrom input_dir=${pkglibdir} grub_mkimage=grub-mkimage +emulation=none # Check the arguments. for option in "$@"; do
@@ -82,6 +84,14 @@ echo "Unknown image type \`$image_type'" 1>&2 exit 1 ;; esac ;; + --emulation=*) + emulation=`echo "$option" | sed 's/--emulation=//'` + case "$emulation" in + floppy|none) ;; + *) + echo "Unknown emulation type \`$emulation'" 1>&2 + exit 1 ;; + esac ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage
@@ -113,7 +123,7 @@ cp -dpR ${overlay}/* ${aux_dir}/ fi -if [ "x${image_type}" = "xfloppy" ] ; then +if [ "x${image_type}" = xfloppy -o "x${emulation}" = xfloppy ] ; then # build memdisk memdisk_img=`mktemp` tar -C ${aux_dir} -cf ${memdisk_img} boot
@@ -125,8 +135,21 @@ rm -f ${memdisk_img} # build floppy image - cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > $output_image + if [ "x${image_type}" = xcdrom ] ; then + floppy_dir=`mktemp -d` + floppy_img=${floppy_dir}/grub_floppy.img + else + floppy_img=${output_image} + fi + cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${floppy_img} rm -f ${core_img} + + if [ "x${image_type}" = xcdrom ] ; then + # build iso image + genisoimage -b grub_floppy.img \ + -o ${output_image} -r -J ${floppy_dir} + rm -rf ${floppy_dir} + fi else # build core.img core_img=`mktemp`
@@ -139,7 +162,7 @@ # build iso image genisoimage -b boot/grub/grub_eltorito \ -no-emul-boot -boot-load-size 4 -boot-info-table \ - -o ${output_image} -r ${aux_dir} + -o ${output_image} -r -J ${aux_dir} rm -rf ${aux_dir} fi
Quoted 18 lines · Christian Franke
Here a new version of the patch with Joliet enabled always. Should not break anything.
Christian
2008-03-01 Christian Franke <[email protected]>
* util/i386/pc/grub-mkrescue.in: Add --emulation=floppy to create a floppy emulation boot CD when non emulation mode does not work.
Enable Joliet CD filesystem extension.
util/i386/pc/grub-mkrescue.in line 49
Quoted 4 lines
util/i386/pc/grub-mkrescue.in +1
-0@@ -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) + --emulation=TYPE select boot emulation type floppy or none (default)
Uhm maybe it'd be better to mention what the emulation is for. As it is, user might wonder what is the appropiate --emulation value for --image-type=floppy, or even why --emulation=floppy doesn't produce floppy images.
What do you think?
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 /.)
Quoted 16 lines · Robert Millan
On Sat, Mar 01, 2008 at 10:05:22PM +0100, Christian Franke wrote:
...
util/i386/pc/grub-mkrescue.in line 50
Quoted 8 lines
util/i386/pc/grub-mkrescue.in +1
-0@@ -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) + --emulation=TYPE select boot emulation type floppy or none (default)Uhm maybe it'd be better to mention what the emulation is for. As it is, user might wonder what is the appropiate --emulation value for --image-type=floppy, or even why --emulation=floppy doesn't produce floppy images.
Quoted 3 lines
What do you think?
OK, e.g.
. --emulation=TYPE select El Torito boot emulation type floppy
. or none (default) (cdrom only)
Or with the help syntax used by the grub binaries:
. --emulation=(floppy|none) select El Torito boot emulation type (cdrom only)
. [default=none]
Christian
Quoted 33 lines · Christian Franke
Quoted 22 lines · Robert Millan
On Sat, Mar 01, 2008 at 10:05:22PM +0100, Christian Franke wrote:
...
Review line 52
Quoted 12 lines
--- grub2.orig/util/i386/pc/grub-mkrescue.in 2008-02-09
14:02:56.057039500 +0100
+++ grub2/util/i386/pc/grub-mkrescue.in 2008-03-01
21:52:23.493466900 +0100(quoted diff) +1
-0@@ -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) + --emulation=TYPE select boot emulation type floppy or none (default)Uhm maybe it'd be better to mention what the emulation is for. As it is, user
might wonder what is the appropiate --emulation value for --image-type=floppy,
or even why --emulation=floppy doesn't produce floppy images.Quoted 3 lines
What do you think?
OK, e.g.
. --emulation=TYPE select El Torito boot emulation type floppy
. or none (default) (cdrom only)
Quoted 5 lines
Or with the help syntax used by the grub binaries:
. --emulation=(floppy|none) select El Torito boot emulation type (cdrom only)
. [default=none]
I don't mind either way. Anyone else does?
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 /.)
Quoted 16 lines · Robert Millan
...
Quoted 15 lines
Quoted 9 lines
Uhm maybe it'd be better to mention what the emulation is for. As it is, user might wonder what is the appropiate --emulation value for --image-type=floppy,
or even why --emulation=floppy doesn't produce floppy images.What do you think?
OK, e.g.
. --emulation=TYPE select El Torito boot emulation type floppy
. or none (default) (cdrom only)
Quoted 9 lines
Quoted 5 lines
Or with the help syntax used by the grub binaries:
. --emulation=(floppy|none) select El Torito boot emulation type (cdrom only)
. [default=none]I don't mind either way. Anyone else does?
A new version of the patch is attached.
One might decide to unify bin<>sh help syntax later.
Christian
2008-03-07 Christian Franke <[email protected]>
* util/i386/pc/grub-mkrescue.in: Add --emulation=floppy to create a floppy emulation boot CD when non emulation mode does not work.
Enable Joliet CD filesystem extension.
util/i386/pc/grub-mkrescue.in +27 -3
@@ -46,6 +46,8 @@ Make GRUB rescue image. --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) + --emulation=TYPE select El Torito boot emulation type floppy + or none (default) (cdrom only) grub-mkimage generates a bootable rescue image of the specified type.
@@ -56,6 +58,7 @@ EOF image_type=cdrom input_dir=${pkglibdir} grub_mkimage=grub-mkimage +emulation=none # Check the arguments. for option in "$@"; do
@@ -82,6 +85,14 @@ for option in "$@"; do echo "Unknown image type \`$image_type'" 1>&2 exit 1 ;; esac ;; + --emulation=*) + emulation=`echo "$option" | sed 's/--emulation=//'` + case "$emulation" in + floppy|none) ;; + *) + echo "Unknown emulation type \`$emulation'" 1>&2 + exit 1 ;; + esac ;; -*) echo "Unrecognized option \`$option'" 1>&2 usage
@@ -113,7 +124,7 @@ if test "x$overlay" = x ; then : ; else cp -dpR ${overlay}/* ${aux_dir}/ fi -if [ "x${image_type}" = "xfloppy" ] ; then +if [ "x${image_type}" = xfloppy -o "x${emulation}" = xfloppy ] ; then # build memdisk memdisk_img=`mktemp` tar -C ${aux_dir} -cf ${memdisk_img} boot
@@ -125,8 +136,21 @@ if [ "x${image_type}" = "xfloppy" ] ; th rm -f ${memdisk_img} # build floppy image - cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > $output_image + if [ "x${image_type}" = xcdrom ] ; then + floppy_dir=`mktemp -d` + floppy_img=${floppy_dir}/grub_floppy.img + else + floppy_img=${output_image} + fi + cat ${input_dir}/boot.img ${core_img} /dev/zero | dd bs=1024 count=1440 > ${floppy_img} rm -f ${core_img} + + if [ "x${image_type}" = xcdrom ] ; then + # build iso image + genisoimage -b grub_floppy.img \ + -o ${output_image} -r -J ${floppy_dir} + rm -rf ${floppy_dir} + fi else # build core.img core_img=`mktemp`
@@ -139,7 +163,7 @@ else # build iso image genisoimage -b boot/grub/grub_eltorito \ -no-emul-boot -boot-load-size 4 -boot-info-table \ - -o ${output_image} -r ${aux_dir} + -o ${output_image} -r -J ${aux_dir} rm -rf ${aux_dir} fi
Quoted 7 lines · Christian Franke
2008-03-07 Christian Franke <[email protected]>
* util/i386/pc/grub-mkrescue.in: Add --emulation=floppy to create a floppy emulation boot CD when non emulation mode does not work.
Enable Joliet CD filesystem extension.
Committed.
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 /.)