[HowTo] A simple cloning procedure for USB-sticks to work on Dockstar/GoFlex
January 22, 2013 11:18AM
Hello everybody,

having just read once again how to clone a USB-stick and seeing the hassle involved in doing so, I thought I would share my way of doing it, as this has several advantages, which, I hope, will become clear in the course of my post.

I have a separate boot partition (as suggested in this German blog), which makes things a little harder, but still, I believe, quite easy. For those of you who use a combined boot/root partition, the procedure below is very much the same and should be aeasy to adapt. Also, I created a directory /stick, but you can replace that with /mnt if you like.

One stick fits all

Before you think of making an archive of the working stick, make sure that you do the following while your plug is up and running using the stick. The aim is to be able to use the stick on any Dockstar/GoFlex you might have available and get instant network access via DHCP:

rm /stick/etc/udev/rules.d/70-persistent-net.rules
rm /stick/lib/udev/rules.d/75-persistent-net-generator.rules

(sorry, I need to give credit to whoever suggested this, but I cannot remember where I read it ...).

Archive the stick

I am assuming that /dev/sdx1 is the boot partition and /dev/sdx2 is the root partition of the working USB-drive (of course, you can find out what letter you should substitute for x using, e.g. blkid). Then the following will create an archive of the whole stick (which has around 150 MB with just a basic squeeze / wheezy install) on your desktop (linux) machine:

sudo mount /dev/sdx2 /stick
sudo mount /dev/sdx1 /stick/boot
sudo tar -czf <Stickname>.tar.gz /stick
sudo chown $USER:$USER <Stickname>.tar.gz
sudo umount /stick/boot
sudo umount /stick

Prepare the new stick (with optimized performance parameters)

Now, if you want to have a second USB-drive with the same capabilities as the first one, go and do the following:

First of all, use any tool to partition the drive, e.g. gparted. Then, you might want to go for optimized performance and do something like this:

sudo mkfs.ext2 -L USB-Boot /dev/sdx1
sudo mkfs.ext4 -L USB-Root /dev/sdx2
sudo tune2fs -c 0 /dev/sdx1
sudo tune2fs -o journal_data_writeback -O ^has_journal -c 0 /dev/sdx2

(an idea based also on this blog (in German))

Generate the new stick

Now, the drive is ready to be written, which will happen like this:

sudo mount /dev/sdx2 /stick
sudo mkdir /stick/boot
sudo mount /dev/sdx1 /stick/boot
sudo tar --strip-components=1 -xzf <Stickname>.tar.gz -C /stick
# this may now take some time because of synch:
sudo umount /stick/boot
sudo umount /stick

Voila, your drive is ready! And all you had to make sure about is that there is enough space on the drive and not whether it has the exact same specs as the one you originally used. Furthermore, this procedure allows you to save snapshots of whatever status your installation might have reached.

I hope this is useful to you. Enjoy!

---
Standart ist der Standardfehler



Edited 1 time(s). Last edit at 02/15/2013 08:13AM by chessplayer.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: