Resizing a disk at Mythic Beasts
I have a server hosted at Mythic Beasts and I'd run out of disk space. They have instructions but I'm not experienced enough to be able to follow them as is, though I broadly followed it to make sure I was roughly on track.
Here's what I did so I can do it again. I do not necessarily think I did it in the optimal or correct way, but it did work. YMMV.
> df
...
/dev/mapper/nicecupoftea2--vg-root 156193244 135604120 12628756 92% /
...
> sudo lsblk
...
sr0 11:0 1 667M 0 rom
vda 252:0 0 200G 0 disk
├─vda1 252:1 0 487M 0 part /boot
├─vda2 252:2 0 1K 0 part
└─vda5 252:5 0 159.5G 0 part
├─nicecupoftea2--vg-root 253:0 0 151.5G 0 lvm /
└─nicecupoftea2--vg-swap_1 253:1 0 8G 0 lvm [SWAP]
> sudo parted /dev/vda
(parted) print free
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 512MB 511MB primary ext2 boot
512MB 513MB 1048kB Free Space
2 513MB 172GB 171GB extended
5 513MB 172GB 171GB logical lvm
172GB 215GB 43.0GB Free Space
(parted) mkpart
Partition type? primary/logical? primary
File system type? [ext2]?
Start? 173GB
End? 215GB
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 215GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 512MB 511MB primary ext2 boot
2 513MB 172GB 171GB extended
5 513MB 172GB 171GB logical lvm
3 173GB 215GB 41.7GB primary ext2 lba
> sudo fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 999423 997376 487M 83 Linux
/dev/vda2 1001470 335542271 334540802 159.5G 5 Extended
/dev/vda3 337891328 419430399 81539072 38.9G 83 Linux
/dev/vda5 1001472 335542271 334540800 159.5G 8e Linux LVM
> sudo pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created.
> sudo vgdisplay
--- Volume group ---
VG Name nicecupoftea2-vg
System ID
Format lvm2
...
> sudo vgextend nicecupoftea2-vg /dev/vda3
Volume group "nicecupoftea2-vg" successfully extended
> sudo lvextend -l +100%FREE nicecupoftea2-vg/root
Filesystem at /dev/mapper/nicecupoftea2--vg-root is mounted on /; online resizing required
old_desc_blocks = 10, new_desc_blocks = 12
The filesystem on /dev/mapper/nicecupoftea2--vg-root is now 49911808 (4k) blocks long.
> df
Filesystem 1K-blocks Used Available ...
/dev/mapper/nicecupoftea2--vg-root 196321316 135604972 51129744 73% /
...
Various links
How to resize a logical volume with 5 simple LVM commands guide helped and so did Creating and managing partitions in Linux with parted.
Overview of Logical Volume Manager (LVM) was handy, and How to Increase the size of a Linux LVM by expanding the virtual machine disk (steps to take, what the hex things mean).
I didn't know whether to use ext4 or what so I went with the default/existing, ext2 (some info). I didn't know if it should be logical or physical, my conclusion was that it didn't matter for my purposes.