Linux - NewbieThis 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
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.
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???
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Posts: 282
Rep:
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]
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 (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 ##
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?
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.