You are not logged in.

#1 2012-07-19 21:42:52

Goran
Member
Registered: 2012-01-24
Posts: 92

[SOLVED] Cloning from USB to SSD with dd.

I have a persistent Arch installation on an 8 GB USB stick, and I'm looking to clone that over to my new SSD (Intel 330 series - 60 GB).

The typical dd command to accomplish that is something like: dd if=/dev/sda of=/dev/sdb bs=4096 conv=notrunc,noerror

However, I suspect that this command assumes sda and sdb to be spinning disks, and that a transfer from USB to SSD would probably warrant a different block size, and maybe some other options.

So, for my transfer scenario, is there something else that I should be aware of, or should I just run the typical command?

Last edited by Goran (2012-07-23 11:30:20)

Offline

#2 2012-07-20 06:59:33

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: [SOLVED] Cloning from USB to SSD with dd.

I think that "dd"-ing would clone the partition table as well (along with the MBR) which I think is a bad idea. It would result in an 8 GB SSD. Unless you know of any other cloning method, you can use rsync, update the fstab and reinstall the bootloader:

https://wiki.archlinux.org/index.php/Fu … le_command
https://wiki.archlinux.org/index.php/Fu … quirements


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#3 2012-07-20 07:22:07

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: [SOLVED] Cloning from USB to SSD with dd.

In theory you could dd and resize the paritions to make use of your whole SSD however DSpider's suggestion is much better.

It will allow you to align your partitions correctly from the start and even switch file systems if your current file system doesn't support discard.

Offline

#4 2012-07-20 07:25:01

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: [SOLVED] Cloning from USB to SSD with dd.

You can give clonezilla a try. It will back up your mbr (separately), in case you need it.

Offline

#5 2012-07-20 07:41:46

DSpider
Member
From: Romania
Registered: 2009-08-23
Posts: 2,273

Re: [SOLVED] Cloning from USB to SSD with dd.

The MBR is not that difficult to back up separately:

# dd count=1 bs=440 if=/dev/sda of=/home/user/mbr.img

To restore it, you simply reverse the if (input file) and of (ouput file):

# dd if=/home/user/mbr.img of=/dev/sda

Edit: Be careful with this one. Don't restore it to an NTFS partition, else you will have to use testdisk to restore the boot code from the NTFS backup sector. I did it myself once, by mistake, after messing around with the SATA cables and changing the drive order. Always double (triple) check with "sudo fdisk -l".

Last edited by DSpider (2012-07-20 08:19:12)


"How to Succeed with Linux"

I have made a personal commitment not to reply in topics that start with a lowercase letter. Proper grammar and punctuation is a sign of respect, and if you do not show any, you will NOT receive any help (at least not from me).

Offline

#6 2012-07-20 20:11:30

Goran
Member
Registered: 2012-01-24
Posts: 92

Re: [SOLVED] Cloning from USB to SSD with dd.

DSpider wrote:

I think that "dd"-ing would clone the partition table as well (along with the MBR) which I think is a bad idea. It would result in an 8 GB SSD. Unless you know of any other cloning method, you can use rsync, update the fstab and reinstall the bootloader:

But wouldn't that require an existing filesystem on the SSD? I should have probably emphasized the fact that my SSD is brand new, as in "just out of the box", so it doesn't have a ready partition than can just receive files.

Unless rsync is doing something special in this case, I'm guessing that it's basically the same method as using cp, which would require a ready filesystem on the destination drive.


mikesd wrote:

In theory you could dd and resize the paritions to make use of your whole SSD however DSpider's suggestion is much better.

It will allow you to align your partitions correctly from the start and even switch file systems if your current file system doesn't support discard.

The filesystem on the USB stick is ext4, so it should support discard (I'll just have to add it in fstab).

Offline

#7 2012-07-20 20:46:34

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: [SOLVED] Cloning from USB to SSD with dd.

Why do you want to use dd rather than a filesystem-aware solution like fsarchiver?


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#8 2012-07-21 21:16:10

velusip
Member
Registered: 2010-12-01
Posts: 18

Re: [SOLVED] Cloning from USB to SSD with dd.

alphaniner has a good point.  You are better off preconfiguring necessary partitions and then filesystems on the SSD,  Then you can mount both devices and copy your file structure from the USB block device to the new SSD block device.

There are other options, but seriously consider the above first.

e.g. If the USB device has only 1 partition I see no problem with using dd to copy it directly to the SSD and then adjust the partition table, filysystems, mountpoints, and now out-of-place data.  It's a bit more work than just copying files with both drives mounted, but it might teach you how to play with your partition scheme of choice and manipulating filesystems (MBR/GPT and fs resize tools).

e.g. If the USB device has several partitions that you would need to redefine over a larger drive after a dd, it makes things far more complicated and I wouldn't bother unless you are up for a challenge (without an auto resizing tool).

Offline

#9 2012-07-23 11:29:23

Goran
Member
Registered: 2012-01-24
Posts: 92

Re: [SOLVED] Cloning from USB to SSD with dd.

Ok. I went with the popular advice, and used rsync to make the move.

It seemed a little more demanding than the "dd and resize" approach, because I had to create a partition and a filesystem on the new drive before I could move anything over (along with modifying menu.lst and fstab), but it wasn't too bad.

The links posted by DSpider were helpful, but I think the information there could be improved: There is no need to chroot in order to properly install the bootloader on some arbitrary disk. Instead, one can simply specify the --root-directory, and grub-install will write files to the right place.

I don't really know how the ArchWiki operates, relating to edits, but I would be willing to include that piece of information, and remove the chroot info (assuming this is a good idea).

Anyway, thanks for all the feedback.

Offline

#10 2012-07-23 12:28:26

Awebb
Member
Registered: 2010-05-06
Posts: 6,304

Re: [SOLVED] Cloning from USB to SSD with dd.

It can be installed with --root-directory, yes, but the chroot method ensures, that the data in the bootloader is made by the exact version installed on the system, not on the host system. I wouldn't just edit the wiki, but use the discussion tab to find that out.

More about the Wiki: https://wiki.archlinux.org/index.php/Help:Editing

Offline

Board footer

Powered by FluxBB