LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 06-14-2009, 11:52 PM   #1
centguy
Member
 
Registered: Feb 2008
Posts: 597
Blog Entries: 1

Rep: Reputation: 46
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!
 
Old 06-15-2009, 12:05 AM   #2
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
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
 
Old 06-15-2009, 12:17 AM   #3
grepmasterd
Member
 
Registered: Aug 2003
Location: Seattle
Distribution: ubuntu, lately
Posts: 182
Blog Entries: 1

Rep: Reputation: 35
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
 
Old 06-15-2009, 01:49 AM   #4
centguy
Member
 
Registered: Feb 2008
Posts: 597

Original Poster
Blog Entries: 1

Rep: Reputation: 46
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!!
 
Old 06-15-2009, 02:08 AM   #5
grepmasterd
Member
 
Registered: Aug 2003
Location: Seattle
Distribution: ubuntu, lately
Posts: 182
Blog Entries: 1

Rep: Reputation: 35
a follow-up suggestion: thoroughly read and understand the grub documentation. errors while using could put you in a sticky corner.
 
Old 06-15-2009, 08:23 AM   #6
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
Quote:
Originally Posted by centguy View Post
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.
 
Old 06-16-2009, 10:45 PM   #7
centguy
Member
 
Registered: Feb 2008
Posts: 597

Original Poster
Blog Entries: 1

Rep: Reputation: 46
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!
 
Old 06-16-2009, 11:28 PM   #8
grepmasterd
Member
 
Registered: Aug 2003
Location: Seattle
Distribution: ubuntu, lately
Posts: 182
Blog Entries: 1

Rep: Reputation: 35
Quote:
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 to be clear
http://www.gnu.org/software/grub/man...evice-map.html

glad you got it working
 
Old 06-16-2009, 11:42 PM   #9
shrinivasjoshi
LQ Newbie
 
Registered: Aug 2006
Location: Pune Maharashtra India
Distribution: RHEL
Posts: 5

Rep: Reputation: 0
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"
 
Old 06-17-2009, 08:27 AM   #10
centguy
Member
 
Registered: Feb 2008
Posts: 597

Original Poster
Blog Entries: 1

Rep: Reputation: 46
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.
 
Old 06-17-2009, 06:44 PM   #11
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
 
Old 06-17-2009, 10:02 PM   #12
centguy
Member
 
Registered: Feb 2008
Posts: 597

Original Poster
Blog Entries: 1

Rep: Reputation: 46
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.
 
Old 06-18-2009, 09:57 AM   #13
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iscsi: which local device (/dev/sda, /dev/sdb) is used WITHOUT dmesg? knikkerr Linux - Software 3 08-13-2010 04:30 AM
USB drive... /dev/sda1 doesn't show unless I try mounting /dev/sda as vfat finite Linux - Hardware 8 03-10-2009 12:52 AM
hdd/sda: How to find which one is hd0 and hd1 ? frenchn00b Linux - Newbie 11 05-14-2008 02:26 PM
Install lilo on external drive (/dev/sda), then boot as INTERNAL (/dev/hda)? slackware-elf Slackware 3 08-18-2007 04:51 PM
Sandisk USB card Reader not linking /dev/sg0 to /dev/sda acidraven Linux - Hardware 1 06-19-2004 03:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration