Upgrade SSD without reinstalling Qubes OS

Hi, I have to upgrade my 2 TB SSD with qubes to a bigger one (4TB).
I tried to clone the disk with clonezilla but I’m not able to resize the qubes LVM.
Anyone know how to do that?

I precise that if possible I want to avoid to reinstall qubes and restore backups because I have some huge non backupped VMs (bitcoin core, electrs, …) that I want to avoid to re-configure and re-sync.
SSD clone and resize should much faster.

Thanks

Clonezilla doesn’t work well when the target disk is larger. There’s no features in that that are helpful, so you have to do it manually.

You’ll need to use parted to resize the partition, then pvresive to extend the physical volume. I don’t believe any of the logical volumes should be changed with lvextend or lvresive. Volume groups shouldn’t need to be changed either.

Thanks for reply!

So the steps could be:

  • Clone with dd
  • resize partition with parted/gparted (or should be done after luks open?)
  • unlock luks and resize it (?) with "cryptsetup resize
  • resize2fs?
  • pvresize /dev/mapper/

I’ve done that recently. It was something like:

  1. dd (Don’t do this from Qubes OS on the SSD you clone. Instead, just boot from USB flash device, maybe Qubes Installer.
  2. Optional: trim the free space. I haven’t found an easier way to do it than just filling the whole LVM pool (e.g., by creating a new qube with large private storage and filling it by dd if=/dev/urandom of=brick bs=32M) and then removing it. Just fstrim isn’t enough, as it operates on FS level, not on LVM. (Doing this step after partition resize is still possible, but you have to fill much more data…)
  3. Resize the partition for encrypted LVM PV. I’ve used gdisk (quite low-level took), the (g)parted will probably be a more comfortable tool for that.
  4. Resize the LUKS container. IIRC it was resized automatically after reboot.
  5. Resize the LVM PV to maximum, probably using pvresize
  6. You’ll probably want to resize the pool by lvextend.

Resize2fs isn’t needed for resizing the pool. It would be needed for resizing the dom0’s volume. It would be also needed for extending domU’s volume, but this is done automatically.

Resize with parted before LUKS. gparted is the GUI version which dom0 does not include.

Resize LUKS. I believe it has to be unlocked.

There are no filesystems here to resize.

Thanks to both for reply. I finally resized the partition.

These are the full steps that I followed (maybe can be useful to someone else):

  1. Boot a live linux distro
  2. Clone the SSD:
sudo dd if=/dev/<old-ssd> of=/dev/<new-ssd> bs=4M status=progress
  1. Resize qubes partition:
sudo parted /dev/<new-ssd>
(parted) resizepart N 100% # N is the number of the partition, in my case was 3
(parted) quit
  1. Resize LUKS
sudo cryptsetup luksOpen /dev/<new-ssd> <name>
sudo cryptsetup resize <name>
  1. Resize physical volume
sudo pvresize /dev/mapper/<name>
  1. Reboot, remove Live USB and login to QubesOS
  2. Resize LVM
sudo lvextend -l +100%FREE /dev/mapper/<pool>

# Ex. sudo lvextend -l +100%FREE /dev/mapper/qubes_dom0-vm--pool

After these commands the pool seems to be resized and for now everything seems working correctly. Only after a second reboot from the resize Qubes stuck at login screen (was never happened before but maybe is related to something else (?))

I noticed some issues with space usage (not sure if it’s an issue related to the resize or just a qubes bug, probably the second one): I tried to clone a 600GB VM but the space usage displayed in Qubes Disk Space Monitor not changed (also after open/shutdown the cloned VM and a system reboot).
Do you know if there is another way to check the entire disk usage? (df -h shows only the dom0 usage)