0

I'm tearing my hair out trying to figure this out.

I've recently built myself a home server to store and save all my media. I installed Ubuntu server 12.04LTS and setup a bunch of stuff on a 64gb SD card i had spare. I've since bought a 16gb USB3 stick to take over the OS so i can use the SD card again. I had assumed moving the OS from drive to drive would be a fairly easy process...

First i learned that you can't easily clone from a large drive to a small one. The total OS is only taking up 5gb of space at present, and even with a 3gb swap partition there's still more than enough raw space on the 16gb drive.

I tried using dd which just filled the usb with a 16gb EXT4 partition then failed. I resized the EXT4 partition on the SD card to 9gb and left the remaining space unpartitioned. Tried dd again which just created another 16gb EXT4 partition before complaining the drive was full. Clonezilla also failed, i forget the exact error message but it was still complaining that it doesn't have enough space on the destination drive (this was after it had been formatted and was only copying the 9gb EXT4 partition.

So, suggestions please!

3
  • What dd command did you use ? What was the error message from Clonezilla? You can boot a live CD and copy - paste the partition with gparted, but you then need to manually update grub and /etc/fstab.
    – Panther
    Oct 16, 2013 at 16:40
  • "sudo dd if=/dev/sda of /dev/sdb" making sure i was using the correct source and destination drives. I may try the copy+paste using a live CD next, although i also might have just accidentally broken my SD card reader.
    – user203309
    Oct 16, 2013 at 17:15
  • 1
    Well, that dd command will not work as you are copying the entire disk. dd if=/dev/sda1 of=/dev/sdb1 , but you have to make the partition on sdb first
    – Panther
    Oct 16, 2013 at 18:03

1 Answer 1

2

Problem is sudo dd if=/dev/sda of=/dev/sdb copies whole device not caring what partitions and how many are there. Solution is add count parameter

sudo dd if=/dev/sda of=/dev/sdb count=...

to find count number

fdisk -u -l /dev/sda 

where sda is the disk you are copying from

as count use number in the End column of last partition you want to copy. And make sure you are copying from/to correct devices.

Other possibility should be (i am pretty sure this works would like some confirmation) copying the partition table first like its described here https://unix.stackexchange.com/questions/19047/how-can-i-quickly-copy-a-gpt-partition-scheme-from-one-hard-drive-to-another/19051#19051

and then copy just the partition you want with

sudo dd if=/dev/sda1 of=/dev/sdb1

assuming you want to copy first partition

2
  • Thanks for this, i've run dd with mount at the end, it's taking longer than before as after 10 minutes it would say "drive full" which i'm taking as a good sign. I have to head out now so will leave it going and hopefully it'll work. Thanks for your responses everyone!
    – user203309
    Oct 16, 2013 at 19:24
  • Right, this worked and now boots off the USB3 drive! No swap partition setup for some reason, but i can sort that. Thanks for the help
    – user203309
    Oct 16, 2013 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .