Discussion Forums > Technology
Question - Using dd to clone different sized disks?
bork:
--- Quote from: Freedom Kira on May 06, 2011, 04:16:03 AM ---
--- Quote from: bork on May 06, 2011, 01:27:02 AM ---I have never used dd to clone my boot drive, used a script that mount the partitions on both existing drive and the new drive while in single user and runs dump to move. If interested, I can provide more details.
--- End quote ---
If I understand correctly, this does a simple data copy of all the data existing on the drive. It doesn't copy partition tables or MBR, which would mean he would have ended up with a drive that contained all the data except for how to boot. Which doesn't make for a very useful boot drive...
--- End quote ---
I did not include many details, did not know if there was much interest in an alternate method migrating from one hard drive to another. I will explain it now -
(click to show/hide)
This is a manual method of cloning your hard drive; it is the method I have used in cloning my Unix boot drives.
- write/record your existing hard drive partition information.
- disconnect the existing drive that you are cloning and install the new drive. Before doing this, I comment out the drives that are not involved in this move out of fstab.
- do a minimal clean install on the new drive: partitions adjusted to how you want them, boot loader setup, correct OS version. Do a boot-up test to make sure it is functional.
- reconnect the old drive, it need to be seen as the boot drive / master drive and the new disk as a secondary drive. I will use the ad0 as the original drive and ad1 as the new drive.
- boot system into single user mode and enter the following:
fsck -p
mount –u /
mount -a
swapon –a
- check dev for the device files for the new drive, should see the partitions ad1s1a, ad1s1e … if not create the dev files.
- Make some mount points for the new drives partitions:
mkdir /backup
mkdir /backup/root
mkdir /backup/usr
mkdir /backup/var
mkdir /backup/ (any other partitions)
I run Unix not Linux so were you see newfs, run mkfs (with appropriate options) instead.
I made this into a script:
-- script start --
#! /bin/sh
newfs /dev/ad1s1a
newfs /dev/ad1s1e
newfs /dev/ad1s1f
mount /dev/ad1s1a /backup/root
mount /dev/ad1s1e /backup/var
mount /dev/ad1s1f /backup/usr
(dump –Of - / ) | ( cd /backup/root ; restore –rf - )
(dump –Of - /var ) | ( cd /backup/var ; restore –rf - )
(dump –Of - /usr ) | ( cd /backup/usr ; restore –rf - )
umount /backup/root
umount /backup/var
umount /backup/usr
-- script end --
Swap drives, store old drive away until you are happy with the new drive. Edit fstab.
Freedom Kira:
I still think that only migrates data without copying partition tables or the MBR, MBR being the key point here.
Useful info nonetheless, though.
bork:
It is a manual method, it does not move partition tables. The disk partitions are created manually when you are doing the "minimal install" of the procedure on the new disk. I sort of avoid "automated" cloning, I do not like my loss of control of what some of these methods do. Its mostly due to my past experiences of upgrades gone bad that I do not trust them.
Freedom Kira:
The thing is, with that method you need to do an install, even if it is minimal. Using the dd command will get you a bootable disk without needing to reinstall, because it just dumps the contents of one drive onto another. Which is ideal when both disks are the same size, of course...
Edit: Problem solved. He says he ended up deleting and recreating the swap partition. I think this means he deleted the swap and extended his original partition... But whatever.
Navigation
[0] Message Index
[*] Previous page
Go to full version