User Tools

Site Tools


docs:tips_n_tricks:lvm.html

LVM

Get rid of detatched PVs

After removing a LVM physical device without unmounting and deactivating the volumes first, you see this kind of error:

~ # pvs
/dev/vg_foo/lv_bar: read failed after 0 of 4096 at 53687025664: Input/output error
/dev/vg_foo/lv_bar: read failed after 0 of 4096 at 53687083008: Input/output error
/dev/vg_foo/lv_bar: read failed after 0 of 4096 at 0: Input/output error
/dev/vg_foo/lv_bar: read failed after 0 of 4096 at 4096: Input/output error
PV         VG         Fmt  Attr PSize   PFree
/dev/md127 vg_fnords lvm2 a--  742.96g 177.71g
:
:

To get rid of them, you have to check for /dev/dm-XX device corresponding to the logical volume(s) in question:

~ # ls -la /dev/disk/by-label
total 0
drwxr-xr-x 2 root root 840 Jul 12 16:40 ./
drwxr-xr-x 8 root root 160 Jul 12 16:40 ../
:
lrwxrwxrwx 1 root root  11 Jul 12 16:22 foobar -> ../../dm-37
:

(assuming the filesystem label of the logical volume in question has been “foobar”)

No you can remove that device mapper device from the system by

~ # dmsetup remove /dev/dm-37

… and your lvm commands are quiet again :-)

Boot with /usr etc. on LVM

Recent Ubuntu and Mint distributions seem to have trouble booting systems where relevant filesystems on LVM are referenced by label or uuid instead of /dev/… .

Tracking this down on Mint 18.2 lead me to the file /usr/share/initramfs-tools/scripts/local-block/lvm2, where lvm lvchange is only called for devices matching the pattern /dev/*/*

enigmaticPhysicist on Ask Ubuntu regarding Can't find LVM root dropped back to initramfs had a solution to this by adding an initrd script:

/etc/initramfs-tools/scripts/local-top/forcelvm
#!/bin/sh
PREREQ=""
prereqs()
{
   echo "$PREREQ"
}
case $1 in
prereqs)
   prereqs
   exit 0
   ;;
esac
. /scripts/functions
# Begin real processing below this line
 
# This was necessary because ubuntu's LVM autodetect is completely broken. This
# is the only line they needed in their script. It makes no sense.
# How was this so hard for you to do, Ubuntu?!?!?
lvm vgchange -ay

N.B.: Ubuntu Bug #1573982 seems to handle this.

booting initrd

docs/tips_n_tricks/lvm.html.txt · Last modified: 31.07.2018 11:12 CEST by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki