Dd copying my system nvme to a faster and larger nvme?

A device is here a real block special file which represents a raw device or partition. So /dev/nvme0n1p2.

A mapped device is a virtual block special file, which is used for decryption of the raw device here. So /dev/mapper/somename

I personally cannot say if btrfs makes a difference here, never done it, I don’t use luks. But this is an area, which I never touched or had to deal with.

Because you mounted /dev/mapper/cryptroot to /mnt/btrfs-root. Now you want to add the same partition to itself. Great idea :+1: :expressionless:

:+1: :partying_face:

1 Like

But then then new nvme1n1p2 is not decrypted or mounted yet…
Should I do before I run the command?

Erm… what?

Look you have the device /dev/nvme0n1p2 which is decrypted to /dev/mapper/cryptroot and mounted on /mnt/btrfs-root.

Now you want to add another device. This new device will share the same UUID and will be automatically btrfs.

After adding /dev/nvme1n1p2, you delete the /dev/mapper/cryptroot from the array, which will result in moving all data to /dev/nvme1n1p2.

But better check:

sudo btrfs filesystem show /mnt/btrfs-root
sudo btrfs filesystem usage /mnt/btrfs-root

And see what devices are used here.

sudo btrfs filesystem show /mnt/btrfs-root                                                   1 ✘ 
Label: none  uuid: c3a1d16a-28fe-4dfe-980b-456d676a7024
        Total devices 1 FS bytes used 327.93GiB
        devid    1 size 396.56GiB used 381.06GiB path /dev/mapper/cryptroot

sudo btrfs filesystem usage /mnt/btrfs-root                                                    ✔ 
Overall:
    Device size:                 396.56GiB
    Device allocated:            381.06GiB
    Device unallocated:           15.49GiB
    Device missing:                  0.00B
    Device slack:                  1.50KiB
    Used:                        337.72GiB
    Free (estimated):             48.36GiB      (min: 40.61GiB)
    Free (statfs, df):            48.36GiB
    Data ratio:                       1.00
    Metadata ratio:                   2.00
    Global reserve:              512.00MiB      (used: 0.00B)
    Multiple profiles:                  no

Data,single: Size:351.00GiB, Used:318.14GiB (90.64%)
   /dev/mapper/cryptroot         351.00GiB

Metadata,DUP: Size:15.00GiB, Used:9.79GiB (65.29%)
   /dev/mapper/cryptroot          30.00GiB

System,DUP: Size:32.00MiB, Used:80.00KiB (0.24%)
   /dev/mapper/cryptroot          64.00MiB

Unallocated:
   /dev/mapper/cryptroot          15.49GiB





Yeah, when you add another device to the current mountpoint /mnt/btrfs-root, then you will see 2 devices here. The UUID will not change and mountpoint also will not change. Both devices will be shown as one.

Ok thank you megavolt for all your time and energy!!
I’m going to do a RAM test first and then attempt that later. From exactly where I stopped.

So in the end, it all went fine with dd copying it. The reason no kernel gets confused is that the btrfs system in contained in a luks container and hence can’t be read.
Snap shots are still working.
I just had to reinstall grub in the end.

Scenario:
I had used the standard Calamares encrypted install of Manjaro KDE Plasma stable:
btrfs with a swap partition (so hibernation works).
Now I want to use another NVME or SSD or HDD as the system drive. In my case it is bigger.
In any case the size should be at least equal to the old NVME or SSD or HDD

Install your new drive in your device. Check if there is a faster connection slot available on your motherboard in case of an m.2-NVME.

I will edit this post and create a how-to slowly once I’ve tested hibernation and create a new thread.

Create a backup copy of your home folder.

Boot into a live system and there dd-copy the whole drive to an image on an external drive. Do not decrypt or mount the system drive! The OLD system drive here is assumed to be /dev/nvmeXnY, in my case, /dev/nvme0n1
YOU NEED TO ADJUST THE DEVICE NAMES

sudo dd if=/dev/nvmeXnY of=/run/media/EXTERNALDEVICENAME/dd-image status=progress

Once this has finished, open KDE Partition Manager and for your /dev/nvmeXnY create a new partition table. THIS WILL DELETE YOUR SYSTEM DRIVE (but you now have a backup image). Hit apply. Inside create an new unformatted partition. Hit apply.

Then select your NEW disk in KDE Partition Manager YOU NEED TO ADJUST THE DEVICE NAME:
/dev/nvmeZnA – In my case it is /dev/nvme1n1.
There, create a new partition table, gpt. This will again delete any data if there is any. Hit apply. Inside create an new unformatted partition. Hit apply.

You can skip the following step if your new drive is exact the exact size of the old drive:

sudo sfdisk --dump /dev/nvmeZnA > /run/media/EXTERNALDEVICENAME/partition_table_newdisk_unformatted

You may want to fill your NEW system disk with random data:

sudo cryptsetup -y -v luksFormat /dev/nvmeZnA
# Type YES in capitals
# Enter your password twice. You will need it just once.
sudo pacman -Sy pv
sudo cryptsetup luksOpen /dev/nvmeZnA whatever
sudo su
pv -tpreb /dev/zero | dd of=/dev/mapper/whatever bs=128M
exit
sudo cryptsetup luksClose whatever

DD copy the image to the new disk:

sudo dd if=/run/media/EXTERNALDEVICENAME/dd-image of=/dev/nvmeZnA status=progress

You can skip the following steps ((continue here*)) if your new drive is exact the exact size of the old drive:

sudo sfdisk --dump /dev/nvmeZnA > /run/media/EXTERNALDEVICENAME/partition_table_after_dd

Now we will look at the two files partition_table_after_dd and partition_table_newdisk_unformatted:
partition_table_newdisk_unformatted
Look at line:
last-lba: LONGERNUMBER
Take that longer number and copy-paste it into partition_table_after_dd and replace
“last-lba: SHORTERNUMBER”
Save the file.

sudo sfdisk /dev/nvmeZnA < /run/media/EXTERNALDEVICENAME/partition_table_after_dd

This will just correct the disk size (resp. it’s available size).

*Next follow the steps in

to reinstall you GRUB.

In my case (gpt, luks, btrfs and UEFI) the commands were (again, ADJUST DEVICE NAMES):

user $ lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME
user $ sudo fdisk -l /dev/nvmeZnA
user $ sudo cryptsetup luksOpen /dev/nvmeZnAp2 cryptroot
user $ su
root # mount -o subvol=@ /dev/mapper/cryptroot /mnt
root # mount /dev/nvmeZnAp1 /mnt/boot/efi

Create the chroot environment and use bash as shell
root # manjaro-chroot /mnt /bin/bash
root # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=manjaro --recheck
root # grub-mkconfig -o /boot/grub/grub.cfg

Verify the existance of an EFI system partition
root # lsblk -o PATH,PTTYPE,PARTTYPE,FSTYPE,PARTTYPENAME COPY TO CLIPBOARD

Verify the efi filesystem is loaded
root # ls /sys/firmware/efi
root # exit

Try loading the efi filesystem
root # modprobe efivarfs

Re-enter chroot
root # manjaro-chroot /mnt /bin/bash

Then mount the efi filesystem
root # mount -t efivarfs efivarfs /sys/firmware/efi/efivars

Verify the efi filesystem is loaded
root # ls /sys/firmware/efi

exit
exit
reboot

2 Likes

Thank you AK and Megavolt for continued support.

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.