NetBSD LVM disk extend
Recently I filled up all space for mails placed in LVM on NetBSD VM running in Xen (XCP-ng) environment.
Xen uses LVM also under the hood, so resizing disk its trivial. Here are the steps:
- Power off your machine
- Locate disk in XenOrchestra
- Expand it to new size (2TB limit) by clicking its size, then entering new one
4. Start machine and run dmesg to check how many sectors your expanded disk now have
xbd3 at xenbus0 id 51776: Xen Virtual Block Device Interface
xbd3: using event channel 23
xbd3: 2000 GB, 512 bytes/sect x 4194304000 sectors
5. Enter new value of total sectors and partitions in disklabel -e /dev/xbd3
Total sectors = dmesg reported sectors
Partition d = whole disk, which is equal to total sectors
Partition a = slice for BSD file system - You need to tweak this accordingly. If you have only one partition which you probably have when using LVM put there total sectors minus offset
Save new disklabel
6. Resize physical disk in lvm
lvm pvresize /dev/rxbd3a
7. Extend logical volume with now new free space available on physical disk
lvm lvextend -L+1000G /dev/mapper/varmailvg-virtuallv
8. Umount resized FS and run fsck as lvm sugesst
umount /var/mail/virtual/
fsck -y /dev/mapper/varmailvg-virtuallv
9. Resize actual FS
resize_ffs /dev/mapper/varmailvg-virtuallv
10. Remount resized volume on previous mount point
mount /dev/mapper/varmailvg-virtuallv /var/mail/virtual/
Results:
Filesystem Size Used Avail %Cap Mounted on
/dev/mapper/varmailvg-virtuallv 1.9T 915G 954G 48% /var/mail/virtual