LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 12-19-2008, 01:07 PM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.1, Debian Squeeze
Posts: 7,064
Blog Entries: 21

Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
[SOLVED] Grub map on 2 HDD LVM system not working as expected


Hello

The grub map option is not working as I expected. I'm trying to use it to allow booting ubuntu 8.04 from a temporary second HDD. As part of a reorganisation, the permanent HDD (/dev/sda) now contains only the /boot filesystem. All the other file systems are provided by LVM. All the LVM data is now on a temporary HDD (dev/sdb).

The next step is to install WXP on /dev/sda. This will replace the MBR and make ubuntu unbootable. The normal procedure to fix this is to boot Linux from a CD and install a grub MBR; grub can then be configured to boot WXP.

In case that fails I want to make /dev/sdb bootable (belt and braces!) so have copied the MBR (except the partition table) and /boot to it. Problem is that /etc/fstab lists /boot as being on /dev/sda. The attempted solution was to change grub's menu.lst to map Linux's /dev/sdb as grub's hd0, hoping that would make it /dev/sda. Here are the relevant menu.lst stanzas. The first is the normal one, the second is the attempted solution.

title Ubuntu 8.04.1, kernel 2.6.24-19-generic
root (hd0,0)
kernel /vmlinuz-2.6.24-19-generic root=/dev/mapper/CW8-root ro
initrd /initrd.img-2.6.24-19-generic

title Ubuntu 8.04.1, kernel 2.6.24-19-generic (temporary HDD)
map (hd1) (hd0)
root (hd0,0)
kernel /vmlinuz-2.6.24-19-generic root=/dev/mapper/CW8-root ro
initrd /initrd.img-2.6.24-19-generic

After choosing the second stanza at boot time, the mounted /boot is the one from the usual /dev/sda. It's identical to /dev/sdb's /boot file system except it does not have a marker file called "THIS_IS_ON_THE_TEMP_HDD".

When it did not work I edited grub's device.map file, adding the second of these two lines:
(hd0) /dev/sda
(hd1) /dev/sdb

Same result.

Sorry it's taken so many words to explain.

The question is what have I misunderstood about grub's map option or its effect on /dev/sd[ab] naming? Subsidiary question: is there another way of making the temporary HDD bootable given the fstab issue.

Best

Charles

Last edited by catkin; 12-26-2008 at 08:02 AM. Reason: Solved
 
Old 12-19-2008, 03:03 PM   #2
yancek
Senior Member
 
Registered: Apr 2008
Distribution: PCLinux, Ubuntu, Peppermint
Posts: 2,356

Rep: Reputation: 272Reputation: 272Reputation: 272
This is the standard map entry for Grub. It assumes trying to boot Ubuntu, which is on the second drive, first partition, booting from Grub on the first drive. You need both map entries as far as I know.

title Ubuntu
rootnoverify (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
chainloader +1

I'm not sure what you are trying to do, I assume it is just to make the second drive bootable and you have all the /boot files on that drive as well as the OS? Set the second drive to boot first in BIOS, see if it boots, if so, change it back.

May have misunderstood your intent here?
 
Old 12-19-2008, 03:13 PM   #3
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 408

Rep: Reputation: 47
Could you not simply copy the /boot partition to sdb and create an mbr on sdb too?

copy sda:/boot to sdb:/boot
make sdb bootable.

This is what I did a while back for a software RAID1:

# grub --no-floppy --device-map=/boot/grub/device.map

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
grub> quit

hope this helps
 
Old 12-20-2008, 01:33 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.1, Debian Squeeze
Posts: 7,064
Blog Entries: 21

Original Poster
Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
Thumbs down

Quote:
Originally Posted by yancek View Post
This is the standard map entry for Grub. It assumes trying to boot Ubuntu, which is on the second drive, first partition, booting from Grub on the first drive. You need both map entries as far as I know.

title Ubuntu
rootnoverify (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
chainloader +1

I'm not sure what you are trying to do, I assume it is just to make the second drive bootable and you have all the /boot files on that drive as well as the OS? Set the second drive to boot first in BIOS, see if it boots, if so, change it back.

May have misunderstood your intent here?
Thanks Yanek

For maximum availability (and for the fun of doing it) I want all the boot options:
  1. Start grub from the first HDD MBR and:
    1. Boot ubuntu from the /boot file system on the first HDD (this is the existing setup)
    2. Boot ubuntu from the /boot file system on the second HDD
  2. Start grub from the second HDD MBR and:
    1. Boot ubuntu from the /boot file system on the first HDD
    2. Boot ubuntu from the /boot file system on the second HDD
The /boot file system is on the first partition on both HDDs.

I'd like this to work regardless of whether the BIOS is set to boot the first or second HDD.

I tried to install grub in the second HDD MBR by

dd if=/dev/sda of=/dev/sdb bs=446 count=1

This didn't work; on setting the BIOS to boot from the second HDD and booting, the screen is filed with GRUB GRUB GRUB ...

Best

Charles
 
Old 12-20-2008, 01:39 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.1, Debian Squeeze
Posts: 7,064
Blog Entries: 21

Original Poster
Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
Quote:
Originally Posted by eco View Post
Could you not simply copy the /boot partition to sdb and create an mbr on sdb too?

copy sda:/boot to sdb:/boot
make sdb bootable.

This is what I did a while back for a software RAID1:

# grub --no-floppy --device-map=/boot/grub/device.map

grub> device (hd0) /dev/sda
grub> root (hd0,0)
grub> setup (hd0)
grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
grub> quit

hope this helps
Thanks eco

Yes -- that's what I tried to do. Those instructions for installing grub into the MBRs look very useful. The "device (hd0) /dev/sdb" is especially helpful. I will try them on the second HDD.

Best

Charles
 
Old 12-20-2008, 06:40 AM   #6
Duck2006
Member
 
Registered: Sep 2006
Distribution: Ubuntu 8.04 Hardy Heron LST
Posts: 346

Rep: Reputation: 33
Some info on grub.

http://users.bigpond.net.au/hermanzone/p15.htm
 
Old 12-20-2008, 08:30 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.1, Debian Squeeze
Posts: 7,064
Blog Entries: 21

Original Poster
Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
Quote:
Originally Posted by Duck2006 View Post
Thanks Duck

Understanding helps! Have read a lot of grub background on the web today and plan to list the best pages in a later post. Comments on the following hypotheses much appreciated.

grub's map command changes the disk ordering in the BIOS tables. It is only necessary when the OS to be booted needs to be on the first HDD. It is only effective when the OS gets disk ordering from the BIOS tables. ubuntu (all Linuxes?) do not do so (it uses bus enumeration?) therefore grub's map command cannot be used to swap /dev/sda and /dev/sdb on ubuntu systems.

grub's root command tells grub where to look for the kernel to boot. If /boot is a separate file system then grub's root is not the same as Linux's root.

When grub is configured to boot ubuntu (all Linuxes?) from (hd1,0), which is ubuntu's /dev/sdb1, it will do so but ubuntu will mount any /boot file system according to /etc/fstab.

Following eco's advice I have now got grub on the second disk to boot ubuntu OK.

Further changes pending more understanding.

Best

Charles
 
Old 12-26-2008, 09:38 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Slackware 13.1, Debian Squeeze
Posts: 7,064
Blog Entries: 21

Original Poster
Rep: Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789Reputation: 789
Lightbulb OP questions answered etc.

Hello

The answer to my original question, "what have I misunderstood about grub's map option or its effect on /dev/sd[ab] naming?", is that GRUB's map command only changes the order of HDDs in the BIOS and that this will only affect /dev/sd[ab] naming if the OS consults the BIOS to get the HDD order. Tests showed that GRUB's map command does not affect ubuntu 8.04's /dev/sd[ab] naming.

The answer to my secondary original question, "is there another way of making the temporary HDD bootable given the fstab issue?" is "only by solving the fstab issue".

Some background is necessary to make the question comprehensible. The system's original HDD had a single small primary partition containing /boot; all the rest of the space was used for an extended partition containing a single logical partition of LVM data. A need arose to install Windows; this required a second primary. There are no tools to resize partitions used for LVM so the LVM data had to be moved to a second HDD allowing the first HDD to be re-partitioned.

For robustness during the migration, I wanted to make the second HDD bootable. LVM was no problem -- the booting kernel scans all block devices looking for LVM data. The difficulty was the /boot partition. I had copied it to the second HDD but fstab configured /boot as /dev/sda1. GRUB's map command was not able to switch /dev/sda and /dev/sdb as I originally thought it would.

One solution is to swap /dev/sda and /dev/sdb some other way. They were both SATA drives so I simply swapped their ports.

Another solution is to change fstab. This was done by booting ubuntu 8.04.1 alternate into rescue mode, mounting the LVM root and /usr file systems then editing fstab. The only gotcha was that vi's display was garbled because of an incompatible $TERM -- worked around by searching to the change site and making the change blind. The ubuntu alternate CD has to be used for a system using LVM because the standard CD's kernel does not contain LVM's device mapper.

Further questions arising during the thread were how to configure GRUB a) to boot ubuntu when the file system containing /boot is on another disk from the one GRUB is running from and b) to boot Windows when the file system containing the startup files is on another disk from the one GRUB is running from.

yancek's and eco's suggestions worked fine (thanks )

Looking for the minimal (necessary and sufficient) solution and adding explanatory comments I evolved the following GRUB stanza for Windows.

Code:
title		Windows XP
# The next line puts the second HDD first in the BIOS HDD table because WXP needs its system 
# drive (containing the startup files) to be the first HDD.
map (hd1) (hd0)
# The next line starts whatever is in the second HDD, first partition, first (512 B) block.
# "second" means GRUB's second which is not affected by the map command.
# The program in the first block takes over control from GRUB Stage 1.
chainloader	(hd1,0)+1
Thanks to Duck for the GRUB documentation link, http://users.bigpond.net.au/hermanzone/p15.htm. Other links I found helpful were online GRUB 0.97 manual, GRUB grotto and The GRUB MBR.

Thanks again to all for assistance in this interesting learning experience.

Best

Charles
 
  


Reply

Tags
fstab, grub, linux, map, ubuntu


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
12.1 LUKS and LVM install on system with multiple SATA and IDE HDD Z038 Slackware - Installation 10 02-03-2010 06:05 PM
My newly bought hdd-s seem to have lower than expected rw-speed MasterOfTheWind Linux - Hardware 5 06-24-2008 10:32 AM
LXer: How To Set Up Software RAID1 On A Running LVM System (Incl. GRUB Configuration) LXer Syndicated Linux News 0 03-25-2008 06:20 PM
Core 5, 2.2Terabytes not working with LVM or File System big_ginge21 Fedora 2 09-05-2006 12:21 PM
Grub and System.map cuco76 Linux - Software 4 06-25-2004 01:58 PM


All times are GMT -5. The time now is 03:02 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration