I'm trying to resize the /var partition on Debian 11.6.
FYI:
(I replaced the true volume group name with "xxx")
# lsblk
NAME MAJ:MIN RM SIZE RO
TYPE MOUNTPOINT sda 8:0 0 447,1G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 488M 0 part /boot
└─sda3 8:3 0 446,2G 0 part
└─sda3_crypt 254:0 0 446,1G 0 crypt
├─xxx--vg-root 254:1 0 37,3G 0 lvm /
├─xxx--vg-tmp 254:2 0 7,4G 0 lvm /tmp
├─xxx--vg-var 254:3 0 108G 0 lvm /var
├─xxx--vg-home 254:4 0 287,4G 0 lvm /home
└─xxx--vg-varlog 254:5 0 6G 0 lvm
sr0 11:0 1 1024M 0 rom
cat /proc/mounts |grep vg-var
/dev/mapper/xxx--vg-var /var ext4 rw,relatime 0 0
I terminated all the processes accessing /var:
systemctl stop lightdm
systemctl stop tor
systemctl stop cron
lsof and fuser showed no more open files.
Then I did:
# lvresize -r -L 64G xxx-vg/var
Unfortunately I don't have the exact output anymore. lvresize asked if it should unmount the filesystem, I chose YES and it failed to do so.
Then I tried to manually unmount /var:
# umount -f /var
This also failed.
Edit: apparently this failed because /var/log was still mounted.
After some research I tried lazy umount:
# umount -l /var
This worked.
Edit: /var/log is now also unmounted.
Then I tried again:
# lvresize -r -L 64G xxx-vg/var
Do you want to unmount "/var" ? [Y|n] y
[...]
This question is strange, as the filesystem was already unmounted.
lvresize failed again (rest of the output):
[...]
umount: /var: not mounted.
fsadm: Cannot proceed with mounted filesystem "/var".
/sbin/fsadm failed: 1
Filesystem resize failed.
Then I tried to use fsadm directly and got the most absurd result:
# fsadm -y resize /dev/mapper/xxx--vg-var 64G
Do you want to unmount "/var" ? [Y|n] y
umount: /var: not mounted.
fsadm: Cannot proceed with mounted filesystem "/var".
mount and umount do work properly:
# mount /var && cat /proc/mounts |grep var
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
/dev/mapper/xxx--vg-var /var ext4 rw,relatime 0 0
umount /var && cat /proc/mounts |grep var
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
umount tells me:
# umount /var
umount: /var: not mounted.
I tried to check with fsadm:
# fsadm check /dev/mapper/xxx--vg-var
# echo $?
3
From the manual:
A status code of 3 indicates the requested check operation could not be performed because the filesystem is mounted and does not support an online fsck(8).
e2fsck isn't working either:
# e2fsck /dev/mapper/xxx--vg-var
e2fsck 1.46.2 (28-Feb-2021)
/dev/mapper/xxx--vg-var is in use.
e2fsck: Cannot continue, aborting.
Apparently /var is "half mounted".
Any suggestions?