Huge Discounts on Mobiles, Books, Cameras, Computers etc: @Flipkart
Flipkart.com

Monday, June 08, 2015

Clone your bootable usb drive in minutes!

I have an Intel i3 NUC which runs Xubuntu full install on a Sandisk Extreme 16GB USB 3.0 stick. It doesn't have a hard disk :-) Everything was working fine (mostly use it to share hdd, printer etc and also as a media player - Kodi/XMBC), until it ran out of space trying to upgrade from Ububtu 14.10 to 15.04. So I bought a new Sandisk Ultra Fit 64GB USB 3.0 and was finding it hard to setup everything from scratch and reconfigure/customize it. I wanted to give Kubuntu a try, but install failed as it was not able to partition the USB drive (don't remember, but I think I was able to boot and install Xubuntu into same drive). I didn't want to waste anymore time and just wanted to get things going quickly. Was looking for easy ways to clone and found this!

There is a command called dd and using it I could clone my usb disk and boot from the new one in about 10-15 minutes!

The syntax is as follows:
dd if=/dev/sdc of=/dev/sda
Make sure you give the whole device (sdc vs sdc1) and not a partition. Also double check the source and target device names (sda/sdb/sdc) before you start the command.

Couple of things to keep in mind:

  • Target has to be same size or larger than source. If larger you can resize partitions later
  • boot record will be copied only if you clone whole device vs a partition
  • You can use the UI (eg: Disks) or sudo fdisk -l to find out the device names
  • You can optimize transfer by setting block sizes, eg: sudo dd if=/dev/sdx of=/dev/sdy bs=8M

Source:

Target:

You can see that after the operation, I have the same partitions from the 16GB drive on my new 64GB one. To resize existing partition, I removed the swap, resized main (leaving some space for swap at the end) and then created swap at the end. This was done using GParted.


Hope it saves many hours or days of yours, have fun!

No comments:

Post a Comment