Easiest way to clone bootable Ubuntu flash drive

PostmanPot

Honorary Master
Joined
Jul 16, 2005
Messages
35,014
Reaction score
81
Location
Cape Town
Hi all

I have an HP Microserver running Ubuntu off an 8GB flash drive. Ubuntu has been tweaked as a Mac fileserver with mount points, various drive support, etc.

What's the easiest way to clone it to another flash drive as a safety backup in case the current one fails?

I can use a Windows/Mac/Linux machine to do it, please let me know?
 
Hi all

I have an HP Microserver running Ubuntu off an 8GB flash drive. Ubuntu has been tweaked as a Mac fileserver with mount points, various drive support, etc.

What's the easiest way to clone it to another flash drive as a safety backup in case the current one fails?

I can use a Windows/Mac/Linux machine to do it, please let me know?

Running an OS off flash is never recommended.

I learnt the hard way and lost 3x USB installs on my HP N40L.

Rather buy a nice ICYDOCK and use an HDD.
 
I'd go with gparted & copy partition by partiton. Done this with Centos for kiosk systems before without hassles.
 
Hi all

I have an HP Microserver running Ubuntu off an 8GB flash drive. Ubuntu has been tweaked as a Mac fileserver with mount points, various drive support, etc.

What's the easiest way to clone it to another flash drive as a safety backup in case the current one fails?

I can use a Windows/Mac/Linux machine to do it, please let me know?

dd

To an image file:
Code:
sudo dd if=/dev/sdx of=/destinationfolder/imagefilename.img bs=1M

To another flash stick:
Code:
sudo dd if=/dev/sdx of=/dev/sdy bs=1M

if input file
of output file
sdx your source drive, sda etc
sdy your destination device sdb etc

DO NOT mix up your source and destination devices as you will lose whatever is on it.
 
Last edited:
Hrm if the target was a vm it's easy, did that when I started with my micro server. I just used VMware to boot from the flash disk and then cloned it to a vm disk
 
dd

To an image file:
Code:
sudo dd if=/dev/sdx of=/destinationfolder/imagefilename.img bs=1M

To another flash stick:
Code:
sudo dd if=/dev/sdx of=/dev/sdy bs=1M

if input file
of output file
sdx your source drive, sda etc
sdy your destination device sdb etc

DO NOT mix up your source and destination devices as you will lose whatever is on it.

This is all good and well but without a working MBR/GPT and grub this won't boot.
 
Can't you plug the drive into a Mac, use Disk Utility to create an image, then restore the image to the backup drive? Might be worth a try.
 
This is all good and well but without a working MBR/GPT and grub this won't boot.

:confused:

The OP want's to clone a existing working flash stick. The above will image the entire stick including mbr/gpt/grub, every single readable bit on the flash stick will be imaged.
 
:confused:

The OP want's to clone a existing working flash stick. The above will image the entire stick including mbr/gpt/grub, every single readable bit on the flash stick will be imaged.
It definitely works to clone a working boot drive.
 
Does this copy the drive UUID as well?

Yes, when you image a drive you also image the UUID. Like I said it's a bit-for-bit image.

If you image a hard drive and write that image back to another hard drive in the same pc they will have the same UUIDs and you will have to generate new UUIDs for the second drive.
 
dd

To an image file:
Code:
sudo dd if=/dev/sdx of=/destinationfolder/imagefilename.img bs=1M

To another flash stick:
Code:
sudo dd if=/dev/sdx of=/dev/sdy bs=1M

if input file
of output file
sdx your source drive, sda etc
sdy your destination device sdb etc

DO NOT mix up your source and destination devices as you will lose whatever is on it.


Thanks Ponder, this works perfectly.

I copied a distro with persistent data on from a 1GB stick to a 4GB stick (quick formatted FAT32), now have 2 bootable sticks.
 
dd

To an image file:
Code:
sudo dd if=/dev/sdx of=/destinationfolder/imagefilename.img bs=1M

To another flash stick:
Code:
sudo dd if=/dev/sdx of=/dev/sdy bs=1M

if input file
of output file
sdx your source drive, sda etc
sdy your destination device sdb etc

DO NOT mix up your source and destination devices as you will lose whatever is on it.


Thanks Ponder, this works perfectly.

I copied a distro with persistent data on from a 1GB stick to a 4GB stick (quick formatted FAT32), now have 2 bootable sticks.
 
Ponder, can you help me with the command to copy to an image file:

Distro is currently running on the machine on USB stick, sdb1
I'd like to copy the image to a data partition on the HDD of the same machine, sda5

So I issue:

sudo dd if=/dev/sdb1 of=/sda5/Porteusimage/ bs=1M

where Porteusimage is a folder I created on sda5

and terminal returns:

dd: failed to open ‘/sda5/Porteusimage/’: No such file or directory

since I'm not specifying the target directory correctly

How do I fix this?
 
You have not specified an image file name.

Code:
sudo dd if=/dev/sdb1 of=/sda5/Porteusimage/imagefilename.img bs=1M

EDIT: If you are only imaging /dev/sdb1 partition on a bootable stick you will not be able to boot that image when you restore it as you would be missing the mbr/grub which usually gets written to /dev/sdb which is right at the beginning of the stick. You can image the mbr separately or I would suggest imaging the entire flash stick /dev/sdb which would be easier and possibly safer.




Ponder, can you help me with the command to copy to an image file:

Distro is currently running on the machine on USB stick, sdb1
I'd like to copy the image to a data partition on the HDD of the same machine, sda5

So I issue:

sudo dd if=/dev/sdb1 of=/sda5/Porteusimage/ bs=1M

where Porteusimage is a folder I created on sda5

and terminal returns:

dd: failed to open ‘/sda5/Porteusimage/’: No such file or directory

since I'm not specifying the target directory correctly

How do I fix this?
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X