My Purism 13 v3 laptop that I bought and setup in 2018 has a 500 GB SSD inside. During installation, I had chosen to size the boot partition 256 MiB and a root partition 30 GiB. Both had proven to be the wrong choices, given that a kernel initramfs is ~80 MiB now, and the root partition was constantly filled to ~90%.
The rest of the disk was the home partition, which also began to feel crowded - I archive games of the PlayJam GameStick, have kernel sources lying around and extract many firmwares and software packages for reverse engineering purposes.
It was time to get a larger harddisk.
Interlude: Smaller kernels
I had solved the /boot size problem with the help of a forum post and configured initramfs to only include needed kernel modules:
# dateien waren zu groß # https://debianforum.de/forum/viewtopic.php?p=1367229 MODULES=dep
After running update-initramfs -u, the initrd.img-6.x.x-amd64 files have only ~26 MiB instead of the previous ~80.
Choosing a harddisk
I wanted to go and buy a M.2 SSD, but when searching for the answer to "M.2 with NVMe or SATA connector", I saw that the laptop shipped with a 2.5" SATA SSD.
I wondered a bit why it wasn't a M.2 disk, but went to a shop and bought a 2TB SATA SSD. Only when opening up the laptop case and exchanging the drives, I saw that the Librem v3 indeed has a M.2 slot :(
I could have had nearly 10x the speeds of the ~530MiB/s SATA disks, - had I only looked at the whole image in the wiki instead of just focusing on the SATA disk.
Preparations
I downloaded the Debian netinstall image and copied it to a USB flash drive: sudo cp debian-12.7.0-amd64-netinst.iso /dev/sdb.
Then I put the new disk into the laptop, plugged in the flash drive and powered it on and waited until I saw the boot menu.
Now I connected a the old disk with a new SATA-to-USB3-adapter to the laptop and started the graphical rescue application.
The rescue mode worked, but required me to go back to the main menu several times to re-read the partition table, which I did not manage to do via the shell.
0: Copy old to new disk
Copying the old disk to the new one was easily done with a standard cp command:
$ cp /dev/sdc /dev/sda
sda was the new disk, sdb the flash drive and sdc the old disk I connected via USB.
1: Moving and increasing partition size
My system is encrypted, and so I had to move and resize several things.
Number | Size | Device | Usage | Task |
---|---|---|---|---|
1 | 256 MiB | /dev/sda1 | boot | Increase to 2 GiB |
2 | 487 GiB | /dev/sda2 | extended | Move by 1.75 GiB; increase to 1951 GiB |
5 | 487 GiB | /dev/sda5 | encrypted data | Increase to 1951 GiB |
To be able to increase the boot partition, I had to make space and move the extended partition further behind by 1.75 GiB.
Moving the second partition was possible with sfdisk (2048 - 256 = 1792):
$ echo '+1792M,' | sfdisk --move-data /dev/sda 2
It had a speed of ~200MiB/s.
After that I increased sizes of boot and extended partitions with parted:
$ parted (parted) resizepart 1 2048MB ... (parted) resizepart 2 2000GB ... (parted) resizepart 5 2000GB
Then I had to leave the shell and use the rescue menu's "read harddisk" to reload the partition table.
2: Encrypted disk
The actual data on the laptop are encrypted, and so I first had to increase the /dev/mapper/crypted_sda5 partition, which I again did with parted.
3: LVM
The encrypted partition contains a LVM "volume group", which can be inspected with vgdisplay. I think it already had the correct size.
Inside the volume group are LVM "logical volumes", the root, swap and home partitions (lvdisplay). I simply used lvresize to change their sizes - 200GiB for root, and the rest of the 2 TB to the home partition.
For some reasons the lvresize -s option did not work and I used resizefs on each of the partitions afterwards, which required me to e2fsck manually.
4: Booting
After all the partitions were resized, I ran grub-install /dev/sda. Unfortunately booting did not work, I only saw a UEFI tool coreinfo 0.1 with CPU and RAM information.
This was solved by running update-grub, which installed the boot manager into the UEFI instead of the MBR.