Debian: what to do if LVM on ISCSI is not activated after reboot.

root's picture

So you have created LVM on ISCSI disk and you find yourself obliged to enable and mount manually your filesystem after reboot:

root@pluto:~# pvscan 
  PV /dev/sdb    VG bkupvg   lvm2 [350.00 GiB / 0    free]
  PV /dev/sda5   VG rootvg   lvm2 [19.76 GiB / 13.72 GiB free]
  Total: 2 [369.75 GiB] / in use: 2 [369.75 GiB] / in no VG: 0 [0   ]
root@pluto:~# lvscan | grep backups
  inactive          '/dev/bkupvg/backups' [350.00 GiB] inherit
root@pluto:~# lvchange -a y /dev/bkupvg/backups
root@pluto:~# lvscan | grep backups
  ACTIVE            '/dev/bkupvg/backups' [350.00 GiB] inherit
root@pluto:~# mount -a
root@pluto:~# df|grep backup
/dev/mapper/bkupvg-backups 366986300 106629020 260357280  30% /backups

If you look at the boot order, you will see that iscsi is activated after LVM. You can see that in /etc/rcS directory:

lrwxrwxrwx   1 root root   14 Jul 13 15:15 S05lvm2 -> ../init.d/lvm2
lrwxrwxrwx   1 root root   20 Jul 13 15:15 S12networking -> ../init.d/networking
lrwxrwxrwx   1 root root   20 Jul 13 15:15 S19open-iscsi -> ../init.d/open-iscsi

But that is not a problem. Solution is:

1. add the "_netdev" to your fstab entry for the iSCSI mount:

/dev/mapper/bkupvg-backups /backups reiserfs _netdev 0 0

2. add your LVM volume group to LVMGROUPS in /etc/default/open-iscsi and make sure HANDLE_NETDEV is 1:

root@pluto:~# grep LVMGROUPS /etc/default/open-iscsi 
LVMGROUPS="bkupvg"
root@pluto:~# grep HANDLE_NETDEV /etc/default/open-iscsi 
HANDLE_NETDEV=1

That is it!

Of course, you have also workarounds if above instructions for whatever reason do not work for you or you have other flavor than Debian:

workaround 1:

Add to /etc/rc.local:

/sbin/vgchange -ay
/bin/mount -a

workaround 2:

Add to /etc/inittab:
md:35: once:/sbin/vgchange -a y

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content