Sunday, 12 February 2012

Ubuntu - Clone OS Partition

Hi,
  1. We have:
    • sda: destination clone disk 
    • sdb: disk need to clone
  2. You need to check your current hard drive using:
    • df
    • => your current hard drive was sdb
  3. Go to screen mode, because this process could be take a long times:
  4. Run command for clone:
    • dd if=xxx of=yyy bs=zzz
      • xxx: path of hard drive / partition you want to clone
      • yyy: destination
      • zzz: buffer size
    • E.G.:
      • dd if=/dev/sdb of=/dev/sda bs=10M
      • dd if=/dev/sdb1 of=/dev/sda1 bs=64k
    • Waiting until it completed:
      • sdb1: 100GB
        • dd if=/dev/sdb1 of=/dev/sda1 - about 6 hours
        • dd if=/dev/sdb1 of=/dev/sda1 bs=100M - 10'
  5. Mount new partition OS
    • sudo su
    • sudo mount /dev/sda1 /mnt
    • cd /mnt
    • blkid
      • /dev/sda1: UUID="07bcccc5-8285-491c-955a-b981a1d27dd4" TYPE="ext4" 
      • /dev/sda2: UUID="615bb823-b8cf-4739-9048-8b25ebfce3dd" TYPE="ext4" 
      • /dev/sda5: UUID="8f81b6fd-fedc-4bbc-90fa-a1755f6a0597" TYPE="swap" 
      • /dev/sdb1: UUID="39e07ef3-2292-44ef-a9b2-78cc7341fee0" TYPE="ext4" 
      • /dev/sdb2: UUID="b9072967-cfa4-4762-bf73-024d5672d4c1" TYPE="ext4" 
      • /dev/sdb5: UUID="48f14db3-bbac-474c-b7ee-1237fd25b60e" TYPE="swap"
    • vim etc/fstab
      • Change UUID to sda hard drive:
        • UUID=39e07ef3-2292-44ef-a9b2-78cc7341fee0 => UUID=07bcccc5-8285-491c-955a-b981a1d27dd4
        • UUID=b9072967-cfa4-4762-bf73-024d5672d4c1 => UUID=615bb823-b8cf-4739-9048-8b25ebfce3dd
        • UUID=48f14db3-bbac-474c-b7ee-1237fd25b60e => UUID=8f81b6fd-fedc-4bbc-90fa-a1755f6a0597
      • Save file
    • Reboot and make sure it not broken
  6. Update Grub:
    • http://ubuntuforums.org/showthread.php?t=1641020
    • Update new UUID for clone partition:
      • sudo tune2fs -U random /dev/sda1
    • Make sure you update grub and fstab before you reboot
      • sudo update-grub
    • With the old drive unplugged, from a LiveCD you can run the following to make sure G2 is on the MBR. Change XY to the correct names (example: sda5)
    • Or Download the Boot Info Script: http://bootinfoscript.sourceforge.net/
  7. Disabled sdb and run on sda
  8. Finished

Thanks

No comments:

Post a Comment