[HowTo] Clone a Manjaro Installation to a new storage device

Difficulty: ★★☆☆☆

  1. Boot a live session aka a Manjaro Installation Medium.
Blockdevice naming convention
  • s → SCSI
  • d → Disk
  • X → Disk X
  • Y → Partition Y of Disk X

Example: /dev/sda1

  • NVME - Nonvolatile Memory Express
  • X → Number X
  • n → Namespace
  • Y → Number Y
  • p → Partition
  • Z → Number Z

Example: /dev/nvme0n1p1

Clone the partition table/scheme

  1. Save the partition table of your current installation:
sudo sfdisk --dump /dev/sdX > sdX.table
  1. Write the saved partition table to the new disk:
sudo sfdisk /dev/sdY < sdX.table

Cloning the content

Take a look at the output of

lsblk --fs

You need to clone each partition. You can run this command in parallel or in sequence:

sudo dd if=/dev/sdXY of=/dev/sdYX status=progress

A possible template for a script:

# Old Drive
export OD='sda';
# New Drive
export ND='sdb'; 
# Partition 1, 2 and 3
for p in 1 2 3;
do
    echo "sudo dd if=/dev/${OD}${p} of=/dev/${ND}${p} status=progress";
done

:bangbang: For safety reason don’t use this method for BTRFS. Use this one:

  1. Mount the old partition
sudo mount -m /dev/sdXY /tmp/btrfs-old
  1. Glue the new partition with the old partition
sudo btrfs device add -f /dev/sdYX /tmp/btrfs-old
  1. Remove/Delete the old device. This will move all data from the deleting device to the new device:
sudo btrfs device delete /dev/sdXY /tmp/btrfs-old
  1. Check the progress in a new terminal:
sudo watch -n1 btrfs filesystem usage /tmp/btrfs-old
  1. Now the whole btrfs partition is moved to the new device.

:notebook: Expand the partitions as needed with gparted or kparted. If it asks to repair the cloned partition table then repair it. That happens due it detects more space than assigned to the table.

Reinstalling the bootloader

UEFI

:notebook: Keep in mind that if your new storage drive is connected via usb and will replace the internal one, this will lead to boot problems, if it is a nvme.

  1. Mount the partition manually:
sudo mount /dev/sdXY /mnt/boot/efi 
BTRFS
sudo mount -o subvol=@ /dev/sdXY /mnt/boot/efi 
sudo mount /dev/sdXY /mnt/boot/efi 
  1. Reinstall the bootloader
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Manjaro --recheck
  1. Update Bootloader Menu:
grub-mkconfig -o /boot/grub/grub.cfg 

BIOS/CSM/LEGACY

  1. Mount the partition manually:
sudo mount /dev/sdXY /mnt/boot/efi 
BTRFS
sudo mount -o subvol=@ /dev/sdXY /mnt/boot/efi 
  1. Reinstall the bootloader
grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/sdX 
  1. Update Bootloader Menu:
grub-mkconfig -o /boot/grub/grub.cfg 

Reboot

Shutdown the computer and unplug the old drive and boot with the new one.

Hope that helps someone. :wink:

9 Likes