Does grub2 solve this problem I am having with grub1? RE: usbsticks.
I am having this problem with grub1 and I wonder if grub2 solves it.
The problem is at the time I setup the grub system I do not know what device my usbstick will be on.
To be explicit I am writting menu.lst for a grub booter on a usbstick and I do not know what to put for X in the following statement:
root (hdX,0)
The usb stick will be used on many different computers with different number of hard drives. Therefore X actually varries.
Is there a solution for this in grub2? That is in writting the equivalent of menu.lst for grub2, is there a way to specify "the device that my menu.lst and my stage files are on" without knowing in advance where that will be?
If so, how would one do this in grub2?
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Quoted 6 lines · Paul Elliott
Is there a solution for this in grub2? That is in writting the equivalent of menu.lst for grub2, is there a way to specify "the device that my menu.lst and my stage files are on" without knowing in advance where that will be?
If so, how would one do this in grub2?
I think that device will be in the root variable. You'll just need to use paths without the device name, e.g.
linux /boot/vmlinuz
initrd /boot/initrd.img
Signature · 2 lines
Regards, Pavel Roskin
Quoted 7 lines · Pavel Roskin
Quoted 5 lines · Paul Elliott
Is there a solution for this in grub2? That is in writting the equivalent of menu.lst for grub2, is there a way to specify "the device that my menu.lst and my stage files are on" without knowing in advance where that will be?
Quoted 8 lines
Quoted 1 line
If so, how would one do this in grub2?
I think that device will be in the root variable. You'll just need to use paths without the device name, e.g.
linux
/boot/vmlinuz
initrd/boot/initrd.img
Ok, but how do I say the same device as I am in now, but the 3rd partiton, rather than the first.
How do I say (hdX,3) where X in the device I am in now? And X may vary at boot time depending on the number of hard disks on the target system?
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Quoted 6 lines · Paul Elliott
Ok, but how do I say the same device as I am in now, but the 3rd partiton, rather than the first.
How do I say (hdX,3) where X in the device I am in now? And X may vary at boot time depending on the number of hard disks on the target system?
I wish I knew the answer. There is some undocumented scripting functionality, but it doesn't appear to be capable of that yet. Perhaps there should be a "boot_device" variable for that purpose.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 5 lines · Pavel Roskin
Quoted 3 lines · Paul Elliott
Ok, but how do I say the same device as I am in now, but the 3rd partiton, rather than the first.
Quoted 8 lines
Quoted 3 lines
How do I say (hdX,3) where X in the device I am in now? And X may vary at boot time depending on the number of hard disks on the target system?
I wish I knew the answer. There is some undocumented scripting functionality, but it doesn't appear to be capable of that yet. Perhaps there should be a "
boot_device" variable for that purpose.
As usb devices become more used this will be an important problem.
For example, I want to create a usb flash drive for use in an installfest, for people with no CD or floppy.
Partition 1 will have the kernel and initrd for the Fedora installation process.
Partition 2 will have the same for Opensuse.
Partiton 3 the same for Mandriva.
Partiton 4 ubuntu.
How do I write a menu.lst to boot these different kernels with different parameters, and partitions? I do not know which device the usbstick will be at boot time, because the target systems have different number of hard disks.
As matters now stand, there is no way to do it, and you seem to be telling me the problem is not fixed with grub2!
It is easy to think of many analogous problems, in the comercial world.
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Quoted 1 line · Paul Elliott
As usb devices become more used this will be an important problem.
Are you sure that it will be seen as a separate device?
Quoted 2 lines
For example, I want to create a usb flash drive for use in an installfest, for people with no CD or floppy.
That would be great.
Quoted 5 lines
Partition 1 will have the kernel and initrd for the Fedora installation process.
Partition 2 will have the same for Opensuse.
Quoted 8 lines
Partiton 3 the same for Mandriva.
Partiton 4 ubuntu.
How do I write a menu.lst to boot these different kernels with different parameters, and partitions? I do not know which device the usbstick will be at boot time, because the target systems have different number of hard disks.
Would not the boot device be hd0?
Quoted 2 lines
As matters now stand, there is no way to do it, and you seem to be telling me the problem is not fixed with grub2!
Even if I add boot_device now, there is an issue with the variable expansion, to that ($boot_device,3) would not expand to a valid device name.
One possible approach would be to use LVM (Logical Volume Manager) - it's supported by grub2. You could install grub on a small boot partition and allocate the rest to as an LVM partition, that would be split into volumes. Then you could refer to the volumes by name.
Quoted 1 line
It is easy to think of many analogous problems, in the comercial world.
I agree.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 18 lines · Pavel Roskin
Quoted 1 line · Paul Elliott
As usb devices become more used this will be an important problem.
Are you sure that it will be seen as a separate device?
Quoted 2 lines
For example, I want to create a usb flash drive for use in an installfest, for people with no CD or floppy.
That would be great.
Quoted 7 lines
Partition 1 will have the kernel and initrd for the Fedora installation process.
Partition 2 will have the same for Opensuse.
Partiton 3 the same for Mandriva.
Quoted 8 lines
Quoted 6 lines
Partiton 4 ubuntu.
How do I write a menu.lst to boot these different kernels with different parameters, and partitions? I do not know which device the usbstick will be at boot time, because the target systems have different number of hard disks.
Would not the boot device be hd0?
No, usually the first hard disk is hd0, the second hard disk is hd1, and the usb sticks come after that. At least that is how it works under my computer. Usually it is because the number of hard disks differ that causes you not to know which device the usb stick is.
The Problem does not have to involve usbsticks. One can imagine a situation in which to device one is booting from is always the first scsi disk. But some computers have one or more IDE drives wich are recognized by the bios as hd0, hd1, ect.
The Fedora/RedHat kernels/initrd have this feature where you can specify the root partition to the kernel/initrd by volume label. You can say 'root=LABEL=/' to tell the kernel to find the partition with the label '/' and use that as the root partition. This feature does not require LVN. The kernel/initrd will check all the partitons and find the one lableled '/'.
But this does not have anything to do with how one specifies partitions to grub. But perhaps grub should adopt a similar feature.
Quoted 4 lines
Quoted 3 lines
As matters now stand, there is no way to do it, and you seem to be telling me the problem is not fixed with grub2!
Quoted 9 lines
Even if I add
boot_devicenow, there is an issue with the variable expansion, to that ($boot_device,3) would not expand to a valid device name.One possible approach would be to use LVM (Logical Volume Manager) - it's supported by grub2. You could install grub on a small boot partition and allocate the rest to as an LVM partition, that would be split into volumes. Then you could refer to the volumes by name.
This seems a long way to drag the cat around the barn. Or this would be like kicking dead whales down the beach. One should not have to invoke the complexity of LVN just so one can specify partitions.
Quoted 4 lines
Quoted 1 line
It is easy to think of many analogous problems, in the comercial world.
I agree.
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Quoted 10 lines · Paul Elliott
Quoted 5 lines
One possible approach would be to use LVM (Logical Volume Manager) - it's supported by grub2. You could install grub on a small boot partition and allocate the rest to as an LVM partition, that would be split into volumes. Then you could refer to the volumes by name.
This seems a long way to drag the cat around the barn. Or this would be like kicking dead whales down the beach. One should not have to invoke the complexity of LVN just so one can specify partitions.
OK, let's fix GRUB.
As for the expansion issue, I think I see how to fix it. grub_script_arg_add() should append expanded variables to the last argument, rather than allocate a new argument, unless the new argument is separated by spaces from the previous one.
GRUB_SCRIPT_ARG_TYPE_STR and GRUB_SCRIPT_ARG_TYPE_VAR are "write only". I think we should discard grub_script_arg_type_t or use it to keep track of spaces in the input.
As for the "boot_device", it could be set in the same place as "root", namely in grub_set_root_dev() in kern/main.c.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 19 lines · Pavel Roskin
Quoted 10 lines · Paul Elliott
Quoted 5 lines
One possible approach would be to use LVM (Logical Volume Manager) - it's supported by grub2. You could install grub on a small boot partition and allocate the rest to as an LVM partition, that would be split into volumes. Then you could refer to the volumes by name.
This seems a long way to drag the cat around the barn. Or this would be like kicking dead whales down the beach. One should not have to invoke the complexity of LVN just so one can specify partitions.
OK, let's fix GRUB.
As for the expansion issue, I think I see how to fix it.
grub_script_arg_add()should append expanded variables to the last argument, rather than allocate a new argument, unless the new argument is separated by spaces from the previous one.
Quoted 7 lines
GRUB_SCRIPT_ARG_TYPE_STRandGRUB_SCRIPT_ARG_TYPE_VARare "write only". I think we should discardgrub_script_arg_type_tor use it to keep track of spaces in the input.As for the "
boot_device", it could be set in the same place as "root", namely ingrub_set_root_dev()inkern/main.c.
Ok, you are well into grub2 internals, and beond the areas I am familiar with.
I am glad the problem is being addressed and glad I could be helpfull in pointing out the problem.
When grub2 is finished, I will look in the manual and see what syntax I need to use to solve problems like this.
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Quoted 3 lines · Paul Elliott
When grub2 is finished, I will look in the manual and see what syntax I need to use to solve problems like this.
Finished or not, we won't have a manual untill someone volunteers to work on it.
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 7 lines · Paul Elliott
Quoted 1 line
Would not the boot device be hd0?
No, usually the first hard disk is hd0, the second hard disk is hd1, and the usb sticks come after that. At least that is how it works under my computer. Usually it is because the number of hard disks differ that causes you not to know which device the usb stick is.
Nope. If you boot from a usb disk, it is always hd0. This is the PC BIOS.
Quoted 4 lines
The Problem does not have to involve usbsticks. One can imagine a situation in which to device one is booting from is always the first scsi disk. But some computers have one or more IDE drives wich are recognized by the bios as hd0, hd1, ect.
No. If you boot from a SCSI disk, it is hd0. All IDE disks are shifted to hd1, hd2, etc.
Quoted 10 lines
The Fedora/RedHat kernels/initrd have this feature where you can specify the root partition to the kernel/initrd by volume label. You can say 'root=LABEL=/' to tell the kernel to find the partition with the label '/' and use that as the root partition. This feature does not require LVN. The kernel/initrd will check all the partitons and find the one lableled '/'.
But this does not have anything to do with how one specifies partitions to grub. But perhaps grub should adopt a similar feature.
It is already there. GRUB 2 already supports setting a root based on a filesystem label or a path.
Okuji
Quoted 4 lines · Yoshinori K. Okuji
It is already there. GRUB 2 already supports setting a root based on a filesystem label or a path.
What is the syntax? How do I set it up? Are there example grub2 setups?
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
Quoted 4 lines · Paul Elliott
Quoted 3 lines · Yoshinori K. Okuji
It is already there. GRUB 2 already supports setting a root based on a filesystem label or a path.
Indeed! That's much easier that LVM :-)
Quoted 1 line
What is the syntax? How do I set it up? Are there example grub2 setups?
grub> help search
Usage: search [-f|-l|-s] NAME
Search devices by a file or a filesystem label. If --set is specified, the first device found is set to a variable. If no variable name is specified, "root" is used.
-f, --file search devices by a file (default) -l, --label search devices by a filesystem label -s, --set=VAR set a variable to the first device found -h, --help display this help and exit -u, --usage display the usage of this command and exit
grub>
That means, you can use unique labels like "usbstick-fedora8" and then use:
search -f usbstick-fedora8
linux /boot/vmlinuz-2.6.24-f8
initrd /boot/initrd-2.6.24-f8.img
or something like that.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 5 lines · Pavel Roskin
grub> help search
Usage: search [-f|-l|-s] NAME
Search devices by a file or a filesystem label. If --set is specified, the first device found is set to a variable. If no variable name is specified, "root" is used.
Actually, I was wrong to assume that "root" is used even if "--set" is not specified.
Quoted 4 lines
That means, you can use unique labels like "usbstick-fedora8" and then use:
search -f usbstick-fedora8
That should be:
search -f usbstick-fedora8 -s
Signature · 2 lines
Regards, Pavel Roskin
Quoted 3 lines · Yoshinori K. Okuji
Nope. If you boot from a usb disk, it is always hd0. This is the PC BIOS.
I just tried this on my nephew's Dell. Durring boot I pushed F12 to bring up the boot device menu. I choose usb device.
I had a usbstick with super grub disk on it.
When it booted, it showed the boot device was hd1.
Signature · 3 lines
Paul Elliott 1(512)837-1096 [email protected] PMB 181, 11900 Metric Blvd Suite J http://www.io.com/~pelliott/pme/ Austin TX 78758-3117