LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 10-28-2005, 02:41 PM   #1
onmountain
LQ Newbie
 
Registered: Oct 2005
Distribution: Debian
Posts: 16

Rep: Reputation: 0
Is the /boot folder the MBR?


Hi. I am trying to ghost my / (or root) partition to a different partition, so I can transfer it to an identical PC (so I can apt-get update and test everythig before deploying). Is the /boot folder that appears to have GRUB in it actually the MBR? My limited understanding is that the 446 bytes on a hard drive is the MBR, so that when you do the following, I am actually getting everythig on hda1, even the MBR?
dd if=/dev/hda1 of=/home/testdd1
What I want to do is be able to have two partitions, one for the current version of linux and various apps, as well as a second partition for a new version. I would use dd to transfer my whole partition over to the identical PC and then just change the GRUB to point to the new boot partition right? That way, I could always fall back on the previous partition with just a GRUB change???

 
Old 10-28-2005, 02:48 PM   #2
Moloko
Member
 
Registered: Mar 2004
Location: Netherlands
Distribution: Debian
Posts: 729

Rep: Reputation: 30
The MBR is not in boot, but in the first sector van the hard disk (not visible), copy it with dd if you need it on another pc:

dd if=/dev/hda of=/path/to/image count=1 bs=446
 
Old 10-28-2005, 02:57 PM   #3
Dtsazza
Member
 
Registered: Oct 2005
Location: Oxford, UK
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282

Rep: Reputation: 30
The MBR is the first part of the disk. However, /dev/hda1 is not actually the disk itself, but the first partition on the disk. The MBR is usually outside of any partitions (starts at cylinder 0, head 0, sector 1), so you wouldn't be able to get it in this fashion. There is an option when you install GRUB to install the MBR on a specific partition; if that's what you did and put it on hda1 (i.e. (hd0,0) in grub-speak), then you can get it with your command. However - IIRC, hard drives are hard-coded to look at the physical start of the drive, so there would have to be some sort of MBR there, that pointed at the one on hda1.

This does go beyond my knowledge a little - but something I just tried was changing the if parameter of dd from /dev/hda1 to /dev/hda, so that the entire drive is copied. It seemed to work, though I <Ctrl-C>ed it after a few seconds. I don't know where exactly you could store the image of an entire drive (you'd need a partition bigger than the drive itself)... but if you could find somewhere, this looks like it might work.

[edit]bah, sniped - and by whole numbers of minutes, too...[/edit]

Last edited by Dtsazza; 10-28-2005 at 02:59 PM.
 
Old 10-28-2005, 03:31 PM   #4
onmountain
LQ Newbie
 
Registered: Oct 2005
Distribution: Debian
Posts: 16

Original Poster
Rep: Reputation: 0
Ok. Those 2 replies really made it clear to me. hda is the whole drive with the MBR in the first area... while hda1 is just that one partition. So... if I dd the first partition to say another empty one of sufficient size, I should be able to replicate the whole linux system. Then I could add that as an option to my boot system GRUB right?

I looked in my /boot/grub/menu.lst file and at the end see this:
## ## End Default Options ##

title Debian GNU/Linux, kernel 2.4.27-2-386
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-2-386 root=/dev/hda1 ro
initrd /boot/initrd.img-2.4.27-2-386
savedefault
boot

title Debian GNU/Linux, kernel 2.4.27-2-386 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-2-386 root=/dev/hda1 ro single
initrd /boot/initrd.img-2.4.27-2-386
savedefault
boot

That is all my system offers me right now for a choice when I boot up. I take it if I change this t0 incude and additional choice:
## ## End Default Options ##

title Debian GNU/Linux, kernel 2.4.27-2-386
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-2-386 root=/dev/hda9 ro <=============
initrd /boot/initrd.img-2.4.27-2-386
savedefault
boot

I just altered the hda1 to an example one of hda9. Is that how this works? What tells it the default boot option, I assume right now it is the actual order in the file?

I noticed they all say hd0,0. I take it that is from the /boot/grub/device.map, which says:
(hd0) /dev/hda

Should that stay the same, assuming I am only using one disk drive in each machine like I am?
 
Old 10-28-2005, 08:22 PM   #5
Moloko
Member
 
Registered: Mar 2004
Location: Netherlands
Distribution: Debian
Posts: 729

Rep: Reputation: 30
You have to change hd(x,y) to match with root=/dev/hd[z]

If you dd the partition hda1, than hda1 on the other partition or drive has to have the exact same properties. It has to have the exact same number of sectors. Dd cannot adept to a different size! Use a different method if the sizes are not the same:
- mount the root partition read-only
- mount the destination partition
- execute from the toplevel:#: find . -xdev | cpio -pm /path/to/mount

Copy the MBR seperately and dd it back to the other drive.

Note that it is not required to have a primary partition to boot Linux. Hda(0,4) is just as useful or any other designation.
 
Old 10-28-2005, 08:54 PM   #6
duffme
LQ Newbie
 
Registered: Oct 2005
Location: DC, USA
Distribution: SuSE 10.0, Debian
Posts: 6

Rep: Reputation: 0
ghost

if you ghost the disk it will include the MBR
if you ghost the partition(s) it will not include the MBR
 
Old 10-29-2005, 08:13 AM   #7
onmountain
LQ Newbie
 
Registered: Oct 2005
Distribution: Debian
Posts: 16

Original Poster
Rep: Reputation: 0
So what do I have to change in the grub configuration file to get a ghosted partition to boot up?
For example:

title Debian GNU/Linux, kernel 2.4.27-2-386
root (hd0,0)
kernel /boot/vmlinuz-2.4.27-2-386 root=/dev/hda1 ro
initrd /boot/initrd.img-2.4.27-2-386
savedefault
boot

What does the "root (hd0,0)" in the above designate anyway? Does that mean the MBR is located there on this particular drive? The "root=/dev/hda1" seems to be the partition with linux that is booted in this case. Why do they require the first "root (hd0,0)" part?
 
Old 10-29-2005, 01:41 PM   #8
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 3,996

Rep: Reputation: 261Reputation: 261Reputation: 261
The (hd0,0) is the location of the partition with the kernel. GRUB enumerates drives and partitions starting at 0, so (hd0,0) is the first partition of the first hard drive (hd0,1) is the 2nd partition of the first hard drive, etc. The root= line is passed directly to the kernel so it knows what to mount as the root partition of the Linux filesystem. The bootloader and the kernel are separate entities, although the bootloader does pass some information to the kernel (such as its command line).You can have a separate /boot partition holding the kernel that is separate from your Linux root partition. You don't appear to do this but many people do. So you must tell the bootloader two things, (1) where the kernel image is located and (2) what to tell the kernel about where the Linux root partition is.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP! MBR Destoyed, Can't Boot! squeakypants Linux - Newbie 39 02-04-2005 09:54 PM
Boot problems (MBR) french_frogger Linux - General 6 12-20-2004 01:13 PM
/boot as opposed to MBR babyphil Linux - General 5 08-21-2004 11:13 PM
"LI" from boot floppy? Can't load XP or Linux. Damaged MBR or boot sector or ...? SparceMatrix Linux - General 10 09-27-2002 01:20 PM
boot record (MBR) emperor13 Linux - General 1 12-01-2001 11:21 AM


All times are GMT -5. The time now is 03:05 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration