To create and copy EXT4 partitions on a dual-SSD Linux system, use
fdisk or
parted to define the partition table, then format with
mkfs.ext4. For cloning,
dd provides a bit-for-bit copy of raw devices, while
rsync is superior for copying mounted filesystems because it preserves permissions and handles active files safely. This approach ensures data integrity without needing restoration tools.
Partitioning Strategy and Creation
Before copying data, you must establish the target structure. Since your second SSD contains four Linux partitions, including two large EXT4 volumes, consistency in naming and sizing is critical. Use
lsblk to identify device names like
/dev/sda or
/dev/nvme0n1. Avoid using generic names; always verify the correct disk to prevent overwriting your Windows NTFS partition on the first SSD.
For creating new partitions,
fdisk is the standard tool. Run
sudo fdisk /dev/sdX replacing
X with your target drive letter. Inside the interactive menu, press
n to add a new partition, select
p for primary, and accept default values for most cases unless specific alignment is required. Change the system type to
83 (Linux filesystem) if necessary, though modern kernels often auto-detect. Write changes with
w.
Once the partition exists, format it with the EXT4 file system. The command
sudo mkfs.ext4 /dev/sdXN where
N is the partition number initializes the superblock and inode tables. You can add labels using the
-L flag, such as
sudo mkfs.ext4 -L Data /dev/sdb2, which makes mounting easier later. Always check the partition table with
sudo fdisk -l after creation to ensure no errors occurred during the write process.
Cloning Partitions with DD
The
dd utility creates an exact binary image of a source partition onto a destination. This method is ideal when you need an identical replica, including boot sectors and hidden metadata. However, it requires that the destination partition be at least as large as the source. If the target is smaller, data will be truncated, leading to corruption.
To clone a partition, unmount it first to prevent data inconsistency. Use
sudo umount /dev/sdb2. Then execute:
sudo dd if=/dev/sdb2 of=/dev/sdc2 bs=4M status=progress
Here,
if specifies the input file (source), and
of specifies the output file (destination). The
bs=4M option sets the block size to 4 megabytes, significantly speeding up the transfer compared to the default 512-byte blocks. The
status=progress flag allows you to monitor the copy rate in real-time.
Be cautious with
dd. A typo in the
of parameter can wipe an entire drive instantly. Double-check device names using
lsblk before running the command. After completion, verify the clone by comparing checksums if possible, or simply mount both partitions and compare directory structures.
Synchronizing Data with Rsync
While
dd clones raw blocks,
rsync copies files within the mounted file system. This is often safer for daily backups or migrating data between differently sized partitions. It only transfers changed blocks, making subsequent syncs faster. First, mount both the source and target partitions to known directories, such as
/mnt/source and
/mnt/dest.
Use the following command to synchronize:
sudo rsync -avHAX --delete /mnt/source/ /mnt/dest/
The flags
-a enables archive mode, preserving permissions, ownership, and timestamps.
-v provides verbose output.
-H preserves hard links,
-A preserves ACLs, and
-X preserves extended attributes. The
--delete flag ensures that files deleted from the source are also removed from the destination, keeping them in perfect sync. Note the trailing slash on the source path; it means "copy the contents of," whereas omitting it would create a nested folder.
This method respects the EXT4 journaling features and avoids the risks associated with writing directly to block devices. It is particularly useful when moving data between SSDs with different wear levels or capacities, provided the target has enough free space.
Maintaining System Integrity
After creating or copying partitions, update your
/etc/fstab file if you plan to mount these drives automatically at boot. Use
sudo blkid to get the UUID of the new partition. Edit
/etc/fstab with a text editor and add an entry mapping the UUID to a mount point. Incorrect entries here can prevent the system from booting.
Additionally, consider the performance implications of having multiple partitions on the same SSD. While EXT4 handles fragmentation well, spreading heavy I/O operations across separate partitions on the same physical NAND flash can sometimes impact endurance due to parallel write amplification. Monitor disk usage with
df -h and
du -sh regularly to ensure balanced storage utilization.
If you encounter issues with file permissions after copying, refer to our guide on
Primary User Group for Linux Desktop Applications to understand how group memberships affect access rights. For users managing complex scripts that handle these paths, ensure proper quoting to avoid errors with special characters, as discussed in
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting.
Frequently Asked Questions
Can I clone an EXT4 partition while it is mounted?
No, you should never use
dd on a mounted partition because open files may change during the copy, resulting in a corrupted image. For live systems, use
rsync instead, which handles concurrent reads safely, or use LVM snapshots to freeze the state temporarily.
What happens if the destination partition is smaller than the source?
dd will fail or truncate data if the destination is too small, potentially destroying the file system structure. Always ensure the target partition is equal to or larger than the source. If using
rsync, the operation will simply stop when space runs out, leaving the destination partially copied but not necessarily corrupted.
How do I preserve symbolic links when copying?
By default,
rsync follows symbolic links unless specified otherwise. To preserve symlinks as links rather than copying the target content, use the
-l flag. Combined with
-a, this is included in archive mode, ensuring your link structure remains intact during migration.
Is it safe to delete old partitions after cloning?
Yes, but only after verifying that all data on the new partition is accessible and complete. Mount the new partition, check file counts, and run application-specific tests. Once confirmed, you can remove the old entries from
/etc/fstab and delete the old partition using
fdisk or
gparted.
Why does my cloned partition have a different UUID?
dd copies the exact UUID from the source, which can cause conflicts if both partitions are mounted simultaneously.
rsync creates a new file system with a unique UUID. If you need a unique ID for a
dd clone, use
tune2fs -U random /dev/sdXN to generate a new UUID after the copy.