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.
/media/internal_drive/ - This is the mountpoint for the root partition on the internal drive, yours will either reflect the label or UUID of that partition.
/media/external_drive/ - This is the mountpoint for the root partition on the external drive, yours will most likely reflect the label or UUID of that partition.
/dev/sdX - This is the device on which the destination root partition can be found. In most cases the internal disk will be sda therefore the external one is sdb. If you have more drive, please verify the proper device by using the mount, blkid or fdisk commands.
Cloning the contents of a disk
- Boot from a LiveCD
- Format the external disk as ext4 (assuming the internal uses ext4)
Mount your internal disk and external disk (/media/internal_drive/ & /media/external_drive/ will be example mountpoints in this solution. Your mount point may be different. You can check this with the mount command)
- Open a terminal and become root
ubuntu@host:~$ sudo -s [sudo] password for ubuntu: root@host:~#
Use rsync to make an identical copy of the filesystem
# rsync -aAHX /media/internal_drive/ /media/external_drive/
Making the external USB disk bootable
- Mount proc dev and sys into the new filesystem
# mount -o bind /proc /media/external_drive/proc # mount -o bind /dev /media/external_drive/dev # mount -o bind /sys /media/external_drive/sys
- Record the UUID for your internal and external partitions
# 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"
- Edit UUIDs in fstab (change to the new UUID on external)
# nano /media/external_drive/etc/fstab
- Edit UUID in resume (change to the new UUID on external)
# nano /media/external_drive/etc/initramfs-tools/conf.d/resume
- Ensure devices.map does not exist
# rm /media/external_drive/boot/grub/devices.map
- Change root to the actual drive
# chroot /media/external_drive/
- Install GRUB (MBR pointer) on the second disk
# grub-install /dev/sdX
- Update the grub.cfg file by probing for operating systems and updating the list of operating systems
# update-grub Generating grub.cfg Found linux image: ... ... done
- Exit the chroot
- Unmount proc dev and sys in the new filesystem
# umount /media/external_drive/proc # umount /media/external_drive/dev # umount /media/external_drive/sys