LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is the /boot folder the MBR? (http://www.linuxquestions.org/questions/linux-newbie-8/is-the-boot-folder-the-mbr-377830/)

onmountain 10-28-2005 02:41 PM

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???

:confused:

Moloko 10-28-2005 02:48 PM

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

Dtsazza 10-28-2005 02:57 PM

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]

onmountain 10-28-2005 03:31 PM

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?

Moloko 10-28-2005 08:22 PM

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.

duffme 10-28-2005 08:54 PM

ghost
 
if you ghost the disk it will include the MBR
if you ghost the partition(s) it will not include the MBR

onmountain 10-29-2005 08:13 AM

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?

btmiller 10-29-2005 01:41 PM

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.


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