Difficulty: ★★☆☆☆
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
Check what partition table is used:
lsblk -o NAME,SIZE,PTTYPE /dev/sdX
DOS/MBR
DOS/MBR
- Save the partition table of your current installation:
sudo sfdisk --dump /dev/sdX > sdX-dos.table
- Write the saved partition table to the new disk:
sudo sfdisk /dev/sdY < sdX-dos.table
- Open the disk again with
cfdisk
and write the current partition table again. It should be able to correct it if the end of the table isn’t correct.
sudo cgdisk /dev/sdY
GPT
GPT
- Save the partition table of your current installation:
sudo sgdisk --backup=sdX-gpt.backup /dev/sdX
- Write the saved partition table to the new disk:
sudo sgdisk --load=sdX-gpt.backup /dev/sdY
- Open the disk again with
cgdisk
and write the current partition table again. It should be able to correct it if the end of the table isn’t correct.
sudo cgdisk /dev/sdY
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
For safety reason don’t use this method for BTRFS. Use this one:
- Mount the old partition
sudo mount -m /dev/sdXY /tmp/btrfs-old
- Glue the new partition with the old partition
sudo btrfs device add -f /dev/sdYX /tmp/btrfs-old
- 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
- Check the progress in a new terminal:
sudo watch -n1 btrfs filesystem usage /tmp/btrfs-old
- Now the whole btrfs partition is moved to the new device.
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
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.
- 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
- Reinstall the bootloader
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=Manjaro --recheck
- Update Bootloader Menu:
grub-mkconfig -o /boot/grub/grub.cfg
BIOS/CSM/LEGACY
- Reinstall the bootloader
grub-install --force --target=i386-pc --recheck --boot-directory=/boot /dev/sdX
- 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.