环境

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

问题

  • Storage fails to activate or mount automatically during boot

​Raw​

# lvs -o +devices
LV VG Attr LSize Devices
lv_one vg_one -wi-ao 20.00G /dev/mpath/mpath1(0)
lv_two vg_two -wi-ao 385.00G /dev/mpath/mpath2(0)
lv_three vg_three -wi-ao 250.00G /dev/mpath/mpath3(0)
lv_four vg_four -wi--- 250.00G /dev/mpath/mpath4(0)
lv_five vg_five -wi--- 20.00G /dev/mpath/mpath5(0)

​Raw​

# grep vg_one /etc/fstab
/dev/vg_one/lv_one /data ext3 defaults 0 0
# mount | grep vg_one -c
0

决议

1) Add the ​​_netdev​​ option to the fstab options column for this device

​Raw​

/dev/vg_one/lv_one    /data    ext3    defaults,_netdev    0 0

2) Enable the ​​netfs​​ service

​Raw​

# chkconfig netfs on

  • In additional, some application or database use lv directly (raw device), it means this device's vg doesn't have file system, in this situation, the method above still work. For example:

​Raw​

/dev/vg_test/lv_test    /data    ext4    defaults,_netdev    0 0

lv "/dev/vg_test/lv_test" do not need to be existed, it mean you do not need to create file system or create lv purposely. Only make sure vg name is correct, after os boot, vg "vg_test" will be activated. But it will have file system mount failed message during os boot:

​Raw​

Setting up Logical Volume Management: 1 logical volume(s) in volume group "vg_test" now active      [OK]
Checking network-attached filesystems
Mounting filesystems: mount: special device /dev/vg_test/lv_test does not exist [FAILED]

根源

  • The storage needs more time to become ready on the host
  • For iSCSI storage, the operation of activating vg defined in script file "/etc/rc.sysinit" was done before network service starting.
  • While the _netdev mount option was created for network connected devices, it can be used to introduce a delay before running another activation and mount
  • The _netdev options calls the /etc/init.d/netfs script, which by default starts after networking.
  • The netfs script calls another vgchange and mount for this device, allowing activation and mounting