is hd0 = /dev/sda
I use GRUB bootloader on the MBR on an internal hard drive to
boot a Linux OS on a portable hard drive. After booting to OS on the portable hard drive, /dev/sda corresponds to the portable hard drive. Now, I want to install GRUB on the MBR of the portable hard drive so that I can boot the portable hard drive directly without relying on MBR of the internal hard drive. Can I do root (hd0,0) setup (hd0) for the job ? I just don't want to overwrite the MBR on the internal drive. Cheers! |
It's hard to say. hd0 could be /dev/sda or /dev/hda. On my desktop hd0 was /dev/sda, when it only had SATA drives. I recently transfered an old 500GB IDE HDD to the system and hd0 is now /dev/hda, with all of the manual grub updates to keep on chugging. Which you can avoid if you use that virtual thing and partition labels, yada yada yada.
I'd recommend a grub boot CD at a minimum (el-torito). (or flash drive if your mobo allows that boot option). Boot it, enter grubs command mode, and poke around to see what it sees as it's options. help, and tab completion are available in command mode. It helps if the drives are somewhat unique, filesystem types differ between relative partitions and such. Worst case scenario, dd an image of the MBR that is in peril before making changes. And restore it if things go bad. Of course it helps to have a knoppix cd or gentoo live cd around. Or other options. HTH |
this is all pretty well documented, isn't it?
http://www.gnu.org/software/grub/man...ub.html#device also look inside /boot/grub/devices.map |
waow!! I am really amazed by the community's help. /boot/grub/device.map seems to unambiguosly tell me the mapping.
I have: # this device map was generated by anaconda (hd0) /dev/sda so I guess what I should do. Thanks a lot!! |
a follow-up suggestion: thoroughly read and understand the grub documentation. errors while using could put you in a sticky corner.
|
Quote:
Back in the early days I've had a few times where /boot/grub/devices.map didn't exist, or was just plain wrong. Certainly adding or manipulating it manually doesn't always yield expected results. And if you reconfigure your hardware like I did, it may not automatically update to reflect those changes. Although less of an issue these days with better and better releases. Until you take the road less traveled. |
Yes. sda and sdb could be mapped to internal drive or external drive "randomly". So the reliability of /boot/grub/devices.map is zero (I think).
Just a quick update. I use gparted to figure out the exact drives mapping (hey, i use gparted a lot just to see the partition table). I issued a "grub" command and typed: device (hd0) /dev/sdb root (hd0,2) setup (hd0,2) to install a boot loader on /dev/sdb3. Everything works as expected. Thanks! |
Quote:
http://www.gnu.org/software/grub/man...evice-map.html glad you got it working :) |
Hi,
As long as I know, sda & sdb not get allocated "Randomly", "sda" stands for SCSI device connected as a Primary Master. Here in your case its SATA. "sdb" stands for SCSI device connected as a Primary Slave. If the disk is IDE ATA, It will show "hda" and "hdb" |
shrinivasjoshi:
so what are the names of sdc, sdd, ... ? second primary slave ? third primary slave.. ? I run out of imagination. thanks for the comments anyway. |
When you install grub you can query grub for the device mapping and install accordingly. It won't change during installation.
However, when adding or removing disks, the next time you boot things can look differently. In this post I wrote everything I know about disk UUID so grub recognizes your disk by signature instead by location in the hda/sda chain. jlinkels |
jlinkels:
Thanks. Your post is very detailed and very useful. I wish people can write replies just like you. Straight to the point and full of useful information. |
after the fact, you can always use /proc for most of that information.
$ cat /proc/partitions or sfdisk -l or cfdisk / gparted / others... I just cat /proc/partitions, since there's a delay between when I stick a usb drive in and it registers. cat lets me know when it registers and as what device. Since I don't run dbus/hal/avahi, it allocates somewhat randomly for non-primary drives. If I boot with USB drive in place, it's /dev/sdb. If I plug it in after the fact it is /dev/sdf. Although the second USB drive always seems to get /dev/sdg. Not really a grub thing, just saying. Since my docking station drives are all ext3, and all of my flash cards are Fat32, it makes fstab a dynamic file for me. There's ways to keep it stable, just saying it's easier / simpler for me to mod as needed. But I need to monitor (/proc/partitions) to know what specifically needs a mod. Since I take the stance that if it's not currently used, and can be turned off, it is off / unplugged / yada yada yada. |
All times are GMT -5. The time now is 05:39 AM. |