Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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!!
You can't always rely on that. As you can tell by the # comment, it wasn't even generated by grub. Which MIGHT mean, that grub has already been installed (and installed to the MBR in peril, had it said /dev/hda).
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.