satelliteuser083 Posted December 31, 2006 Report Share Posted December 31, 2006 OK, I probably AM asking for the impossible, but I thought I would, anyway ;) . I want to make an exact copy of one linux-partition onto another, either on the same physical HDD or a second one. Seeing how clever linux is, thought there might just be some utility or another to do this. Any tips? Thanks. Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted January 1, 2007 Report Share Posted January 1, 2007 Yes, you can do this quite easily. First, you can create the new partition, or if you have it already, make sure it has a filesystem, like reiserfs, ext3 or whatever you want to use. Then, you can simply mount them like this. For example, let's say I have a / partition on /dev/sda2 and I then want to copy it to a new partition called /dev/sda3, this is what I would do: mkdir /mnt/oldroot mkdir /mnt/newroot mount /dev/sda2 /mnt/oldroot mount /dev/sda3 /mnt/newroot cp -Rp /mnt/oldroot/* /mnt/newroot/ do all of this from a Live CD, or from the Mandriva install CD in rescue mode. Just exit to the prompt, rather than let the rescue CD mount your partitions for you. That way you have control of what is where. The R parameter copies recursively, and the p parameter keeps permissions. Case is important, so make sure it's like how I typed it. After that, I would be modifying my /etc/fstab to use the new entry and rebooting to verify it all mounted and came up OK, and checking mount points to make sure the old partition wasn't mounted, and then I'd erase the old partition to use for something else. Quote Link to comment Share on other sites More sharing options...
satelliteuser083 Posted January 1, 2007 Author Report Share Posted January 1, 2007 Many thanks. Before I try the copying, just one daft(?) question: the fact that you've used sda is pure coincidence, isn't it? My partitions are called hda8 and hda9; am not quite sure whether or not the device-type is significant. Hopefully not. :unsure: Quote Link to comment Share on other sites More sharing options...
Patkos Csaba Posted January 2, 2007 Report Share Posted January 2, 2007 Device type shouldn't be significant. By the way, maybe you are interested in these commands too: 1) This creates an image of hda7 into a file dd if=/dev/hda7 conv=noerror > /hda7.img 2) Image than can be mounted ... for example testing or backup ... like this: losetup /dev/loop/0 /hda7.img mkdir /recovery mount /dev/loop/0 /recovery 3) Unmount it like this: umount /recovery losetup -d /dev/loop/0 Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted January 2, 2007 Report Share Posted January 2, 2007 No, I just used sda as an example. sdx is normally for scsi/sata type disks, whereas hdx is for ide types. Quote Link to comment Share on other sites More sharing options...
satelliteuser083 Posted January 2, 2007 Author Report Share Posted January 2, 2007 Well, I tried your code and now have a image-copy of LE2005 on a spare partition. Great . Still have a few probs with booting, sadly; perhaps I could trouble you again? The copy-partition previously contained Suse 10 and I used Suse-grub to boot the OS's - Suse 10, LE2005, Mdk2006 and Windoze 2k (oh, the joy in using Suse's grub-config tool :D ). On rebooting LE2005 (and I cannot for the life of me remember how I managed that) I used MCC to put grub back in the MBR. It's now possible to boot LE2005 and LE2005(copy), but not Mdk2006, which hangs with some message about not being able to find the image. Grub's menu.lst is below; can you spot any obvious error? Also, if I were to edit menu.lst, how would I get the result back into the MBR? Thanks. BTW, LE2005 is on hda6, LE2005(copy) on hda9 and Mdk2006 on hda7; swap is on hda8. timeout 20 default 0 title linux LE2005 kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 acpi=ht resume=/dev/hda8 splash=silent vga=788 initrd (hd0,5)/boot/initrd.img title linux-nonfb kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 acpi=ht resume=/dev/hda8 initrd (hd0,5)/boot/initrd.img title failsafe kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 failsafe acpi=ht resume=/dev/hda8 devfs=nomount initrd (hd0,5)/boot/initrd.img title windows root (hd0,0) chainloader +1 title linux Mdk2006 kernel (hd0,5)/boot/vmlinuz-2.6.12-12mdk root=/dev/hda7 initrd (hd0,5)/boot/initrd.img title linuxLE2005Copy kernel (hd0,5)/boot/vmlinuz-2.6.11-6mdk root=/dev/hda9 initrd (hd0,5)/boot/initrd.img Quote Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted January 3, 2007 Report Share Posted January 3, 2007 (edited) If you can boot LE2005, and you used it to install grub, then it needs to know about the 2006 install. Make sure you have an entry in /etc/fstab for your 2006 boot partition (wherever /boot/blah is), something like /dev/hda7 /mnt/mdk2006 blahblah and then your grub's menu.lst entry would be: title linux Mdk2006 kernel (hd0,5)/mnt/hda7/boot/vmlinuz-2.6.12-12mdk root=/dev/hda7 initrd (hd0,5)/mnt/hda7/boot/initrd.img This is all done inside whichever one controls grub (I assume LE2005). Technically, also LE2005(copy)'s entry should use a similar structure to 2006's entry. It (LE2005(copy)) can boot, because technically it is using the kernel that is located in your LE2005's installation, but you really should point it to its own installation's kernel. I'm kinda new with grub, but I think you then need to do grub-install /dev/hda after editing. Edited January 3, 2007 by Steve Scrimpshire Quote Link to comment Share on other sites More sharing options...
tyme Posted January 3, 2007 Report Share Posted January 3, 2007 You don't need to run grub-install after modifying menu.lst - grub gets this data when it starts up, directly from the menu.lst file. Quote Link to comment Share on other sites More sharing options...
satelliteuser083 Posted January 3, 2007 Author Report Share Posted January 3, 2007 I modified /etc/fstab to the following: /dev/hda6 / ext3 noatime 1 1 /dev/hdc /mnt/cdrom iso9660 user,iocharset=iso8859-1,noauto,ro,exec 0 0 none /mnt/floppy supermount dev=/dev/fd0,fs=ext2:vfat,--,umask=0,iocharset=iso8859-1,sync,codepage=850 0 0 /dev/hda1 /mnt/win_c vfat umask=0,iocharset=iso8859-1,codepage=850 0 0 /dev/hda5 /mnt/win_d vfat umask=0,iocharset=iso8859-1,codepage=850 0 0 none /proc proc defaults 0 0 /dev/hda7 /mnt/mdk2006 ext3 noatime 1 1 /dev/hda9 /mnt/mdk102Copy ext3 noatime 1 1 /dev/hda8 swap swap defaults 0 0 /dev/hde5 /mnt/pcmciahdd ext3 noatime,user,noauto 0 0 and /boot/grub/menu.lst to: timeout 20 default 0 title linux LE2005 kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 acpi=ht resume=/dev/hda8 splash=silent vga=788 initrd (hd0,5)/boot/initrd.img title linux-nonfb kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 acpi=ht resume=/dev/hda8 initrd (hd0,5)/boot/initrd.img title failsafe kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 failsafe acpi=ht resume=/dev/hda8 devfs=nomount initrd (hd0,5)/boot/initrd.img title windows root (hd0,0) chainloader +1 title linuxMdk2006 kernel (hd0,5)/mnt/mdk2006/boot/vmlinuz-2.6.12-12mdk root=/dev/hda7 initrd (hd0,5)/mnt/mdk2006/boot/initrd.img title linuxLE2005Copy kernel (hd0,5)/mnt/mdk102Copy/boot/vmlinuz-2.6.11-6mdk root=/dev/hda9 initrd (hd0,5)/mnt/mdk102Copy/boot/initrd.img At boot, with linuxLE2005Copy selected in grub, this error message appeared: kernel (hd0,5)/mnt/mdk102Copy/boot/vmlinuz-2.6.11-6mdk root=/dev/hda9 Error 15: File not found similarly, with linuxMdk2006 selected, the message was: kernel (hd0,5)/mnt/mdk2006/boot/vmlinuz-2.6.12-12mdk root=/dev/hda7 Error 15: File not found (BTW, I assumed that your '/mnt/hda7' and '/mnt/hda9' were typos, after boot didn't work the first time) I've checked for these images and the addresses DO appear to be correct. Interestingly enough, immediately following boot of LE2005 (the only one which DOES boot), KDiskFree shows /dev/hda7 as being unmounted. I can then mount it manually. Possibly the fault lies in /etc/fstab? Any further tips? Thanks. Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted January 3, 2007 Report Share Posted January 3, 2007 I think your original setup was fine, with it pointing to (hd0,5)/boot/ for the kernel, etc. Make sure that the kernel for Mandriva 2006 and LE2005copy exists in this directory. You may find it exists in the boot directory of your install for Mandriva 2006 and LE2005copy. The easiest way to find out is mount these two partitions, and take a look in the /boot directory. And then copy this to the boot directory on /dev/hda5. Quote Link to comment Share on other sites More sharing options...
satelliteuser083 Posted January 3, 2007 Author Report Share Posted January 3, 2007 (edited) Well, I fixed the problem by 'cheating'. I chainloaded into each partition (except LE2005), where I knew that there was a lilo loader. May not be the prettiest solution, but at least it works. Sometime in the future I'll play around with grub and try to boot directly, but at the moment I'm happy. Thanks to all who helped. timeout 20 default 0 title linux LE2005 kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 acpi=ht resume=/dev/hda8 splash=silent vga=788 initrd (hd0,5)/boot/initrd.img title linux-nonfb kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 acpi=ht resume=/dev/hda8 initrd (hd0,5)/boot/initrd.img title failsafe kernel (hd0,5)/boot/vmlinuz root=/dev/hda6 failsafe acpi=ht resume=/dev/hda8 devfs=nomount initrd (hd0,5)/boot/initrd.img title windows root (hd0,0) chainloader +1 title linux Mdk2006 root (hd0,6) chainloader +1 title linuxLE2005Copy root (hd0,8) chainloader +1 Oh, one final thing. I want to update an existing LE2005 to mva2006; is the latter the one with FREE on the splash-screen? If not, how do I go about updating? Thanks again. Edited January 3, 2007 by satelliteuser083 Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted January 3, 2007 Report Share Posted January 3, 2007 Mandriva 2006 is with "Free" on the splashscreen, etc if you download the Free version. Otherwise, purchasing Powerpack will get rid of the free stuff, or you can change your splashscreen to something else to get rid of the "free" stuff. Updating can be done using easyurpmi if you have fast internet connection, or by downloading and upgrading using the CD/DVD media. However, I always recommend a clean install and just preserve your data in your home directory. Means reconfiguring stuff you had set up before, but otherwise it's much better and less likely to have niggles. Quote Link to comment Share on other sites More sharing options...
satelliteuser083 Posted January 3, 2007 Author Report Share Posted January 3, 2007 Thanks. The whole purpose of this partition-copy exercise was to update my current LE2005 to 2006 and, because I haven't got a clue anymore how I arrived at 2005's configuration and certainly wouldn't be able to re-configure it, I need a copy in case the upgrade goes wrong (as you imply it could) :unsure: . I'll give the update a bash; who knows, it may work. ;) Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted January 3, 2007 Report Share Posted January 3, 2007 It's not that the upgrade goes wrong as such, more the little niggly problems. You can in fact live with them, but I hate niggles, prefer perfection ;) You could have copied the partition into a file using the dd command, and just stored this on the new filesystem than copy it to a workable. The only problem, if something goes wrong, is using a live cd to get the partition back from the file again. But nothing major. Either way works just as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.