How to clone a disk or partition in Linux

Cloning a disk or partition in Linux creates a sector-for-sector copy that can be archived before repair work, moved onto replacement storage, or preserved before repartitioning. A block clone keeps filesystem structures, boot data, and unused space exactly as stored on the source, which makes it useful when a normal file copy would miss layout details.

This guide uses dd to read one unmounted block device into an image file so the copy can be inspected before it is restored or written elsewhere. lsblk identifies the correct source and its size, dd performs the raw copy, and mount -o loop,ro attaches the finished image read-only so the contents can be checked without changing the clone.

Take the clone from an unmounted source whenever possible so the filesystem is copied from a stable on-disk state, and make sure the destination filesystem has free space at least equal to the source device. If the source is the running root or boot filesystem, switch to live or rescue media first, and if the source already has read errors, stop using dd and move to GNU ddrescue so failed sectors can be skipped and retried safely.

Steps to clone a disk or partition with dd in Linux:

  1. Inspect the source block device and confirm where it is currently mounted.
    $ lsblk -o NAME,PATH,SIZE,TYPE,MOUNTPOINTS /dev/sdb
    NAME   PATH       SIZE TYPE MOUNTPOINTS
    sdb    /dev/sdb    64G disk
    └─sdb2 /dev/sdb2   64G part /mnt/source

    Use a whole-disk node such as /dev/sdb or /dev/nvme1n1 when the clone must include the partition table and every partition. Use a partition node such as /dev/sdb2 when only one filesystem needs to be copied.

  2. Unmount the source device before starting the clone.
    $ sudo umount /dev/sdb2

    If the source is the running root or boot filesystem, do not clone it from the active system. Move the workflow to live or rescue media first instead of forcing a block copy from a mounted system volume.

  3. Confirm the source size so the destination filesystem can hold the full image file.
    $ lsblk -b -o PATH,SIZE /dev/sdb2
    PATH           SIZE
    /dev/sdb2 68719476736

    The destination filesystem needs free space at least equal to the source size because the image file will grow to the full block-device size.

  4. Create the directory that will hold the clone image.
    $ mkdir -p ~/disk-images
  5. Copy the source device into an image file with dd.
    $ sudo dd if=/dev/sdb2 of=~/disk-images/source-clone.img bs=4M status=progress conv=fsync
    16384+0 records in
    16384+0 records out
    68719476736 bytes (69 GB, 64 GiB) copied, 162.4 s, 423 MB/s

    status=progress prints transfer statistics while the copy is running, and conv=fsync flushes the saved image before dd exits.

    Never reverse if and of. The of target is overwritten immediately, and an existing image file at the same path is replaced.

  6. Check that the saved image looks like the expected filesystem.
    $ file ~/disk-images/source-clone.img
    /home/operator/disk-images/source-clone.img: Linux rev 1.0 ext4 filesystem data, UUID=cf86df97-0537-4beb-b8d5-5b2f7b06fb8e, volume name "clone-src" (extents) (64bit) (large files) (huge files)

    This quick check is most useful for a partition image. A whole-disk image usually reports partition-table metadata instead of one directly mountable filesystem.

  7. Create a temporary mount point for the verification check.
    $ sudo mkdir -p /mnt/source-clone
  8. Mount the cloned image read-only through a loop device.
    $ sudo mount -o loop,ro ~/disk-images/source-clone.img /mnt/source-clone

    mount -o loop attaches the image through an available loop device, and ro keeps the verification check read-only so the clone is not modified during inspection.

  9. List the top-level contents of the mounted image to confirm that the expected data is present.
    $ ls -1 /mnt/source-clone
    etc
    home
    lost+found
    var

    Check for directories or files that prove the correct source was copied, such as /etc, application data, or the expected project tree from the source filesystem.

  10. Unmount the cloned image when the verification check is complete.
    $ sudo umount /mnt/source-clone