- System: Kubuntu 22.04
- There are two partitions on the original disk, EFI and Ubuntu root partition
- The Ubuntu root partition is using Btrfs filesystem, with two subvolumes,
@
and @home
Create partitions
- Using
sudo fdisk /dev/[disk]
to partition
- For example,
sudo fdisk /dev/nvme1n1
- Create GPT partition table
- Create EFI partition, then change the partition type using
t
to change the type to EFI
- Create Linux partition main partition
Copy EFI partition
1
| sudo dd if=/dev/nvme0n1p1 of=/dev/nvme1n1p1 status=progress
|
Copy Btrfs partition
- Boot into a live USB Linux
- Assume the Btrfs partition is
/dev/nvme0n1p2
and the new disk is /dev/nvme1n1p2
- Mount the old Btrfs partition
1
| mount /dev/nvme0n1p2 /mnt
|
- Start copying the Btrfs partition
1
| btrfs replace start /dev/nvme0n1p2 /dev/nvme1n1p2 /mnt
|
1
| btrfs replace status /mnt
|
- This method should keep all the Btrfs subvolumes and UUIDs.
Or Copy Linux partition using dd
1
| sudo dd if=/dev/nvme0n1p2 of=/dev/nvme1n1p2 status=progress
|
- This method will keep the original Btrfs partition’s UUID, so there is no need to modify the
/etc/fstab
file.
- The reason for using dd instead of rsync is that this way the Btrfs subvolume information is preserved.
- This step is recommended to be done using a live USB Linux.
Other operations
Resize the btrfs partition to use the entire disk
1
| sudo btrfs filesystem resize max [mounting point]
|
Check if the partition has any issues
1
| sudo btrfs check /dev/nvme1n1p2
|
View UUID
Backup important files to another disk
- Mount the disk to be migrated and another backup disk
1
| rsync -avx --info=progress2 --info=name0 --info=stats2 --info=flist0 /source_directory/ /destination_directory/
|
Another method
- If the two disks have the same size, you can use
dd
to copy the entire disk
- For example
dd if=/dev/sda of=/dev/sdb bs=4096
reference