There are multiple ways of cloning a disk. The utility dd, for example, performs a full clone on the block level. This solution explains how to make a clone on the filesystem level.

In this example we will be cloning the contents of the internal disk onto an external USB disk. We will then go through the process of making the external USB disk bootable.

A Universally Unique Identifier (UUID) is a string given to a partition on a drive. In this solution you will be copying data onto a different partition with a UUID that does not match, so you will need to change those.

A few things will be different when doing this yourself.

Cloning the contents of a disk

ubuntu@host:~$ sudo -s
[sudo] password for ubuntu: 
root@host:~#

# rsync -aAHX /media/internal_drive/ /media/external_drive/

Making the external USB disk bootable

# mount -o bind /proc /media/external_drive/proc
# mount -o bind /dev /media/external_drive/dev
# mount -o bind /sys /media/external_drive/sys

# blkid
/dev/sda1: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="ext4"
/dev/sda5: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="swap"
/dev/sdb1: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="ext4"

# nano /media/external_drive/etc/fstab

# nano /media/external_drive/etc/initramfs-tools/conf.d/resume

# rm /media/external_drive/boot/grub/devices.map

# chroot /media/external_drive/

# grub-install /dev/sdX

# update-grub
Generating grub.cfg
Found linux image: ...
...
done

# exit

# umount /media/external_drive/proc
# umount /media/external_drive/dev
# umount /media/external_drive/sys 

komputes/HowToCloneFilesystem (last edited 2010-07-20 20:38:42 by ua-178)