0

I have Debian 9 with successfully configured iSCSI and multipath:

# multipath -ll /dev/mapper/mpathb
mpathb (222c60001556480c6) dm-2 Promise,Vess R2600xi
size=10T features='1 retain_attached_hw_handler' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 12:0:0:0 sdc 8:32 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
  `- 13:0:0:0 sdd 8:48 active ready running

/dev/mapper/mpathb is a part of LVM group vg-one-100:

# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/dm-2  vg-one-100 lvm2 a--  10,00t 3,77t
# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  vg-one-100   1  17   0 wz--n- 10,00t 3,77t

vg-one-100 group contains several volumes:

# lvs
  LV          VG         Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv-one-0-1  vg-one-100 -wi-a----- 20,00g                                                    
  lv-one-1-0  vg-one-100 -wi-a-----  2,41g                                                    
  lv-one-10-0 vg-one-100 -wi------- 20,00g                                                    
  lv-one-11-0 vg-one-100 -wi------- 30,00g                                                    
  lv-one-12-0 vg-one-100 -wi-------  2,41g                                                    
  lv-one-13-0 vg-one-100 -wi-------  2,41g                                                    
  lv-one-14-0 vg-one-100 -wi-------  2,41g                                                    
  lv-one-15-0 vg-one-100 -wi-------  2,41g                                                    
  lv-one-16-0 vg-one-100 -wi-------  2,41g                                                    
  lv-one-17-0 vg-one-100 -wi------- 30,00g                                                    
  lv-one-18-0 vg-one-100 -wi------- 30,00g                                                    
  lv-one-23-0 vg-one-100 -wi------- 20,00g                                                    
  lv-one-31-0 vg-one-100 -wi------- 20,00g                                                    
  lv-one-8-0  vg-one-100 -wi------- 30,00g                                                    
  lv-one-9-0  vg-one-100 -wi------- 20,00g                                                    
  lvm_images  vg-one-100 -wi-a-----  5,00t                                                    
  lvm_system  vg-one-100 -wi-a-----  1,00t          

My lvm.conf includes the next filters:

# grep filter /etc/lvm/lvm.conf | grep -vE '^.*#'
    filter = ["a|/dev/dm-*|", "r|.*|"]
    global_filter = ["a|/dev/dm-*|", "r|.*|"]

lvmetad is disabled:

# grep use_lvmetad /etc/lvm/lvm.conf | grep -vE '^.*#'
    use_lvmetad = 0

If lvmetad is disabled, then lvm2-activation-generator will be used.

In my case lvm2-activation-generator generated all needed unit files and execute it during the boot:

# ls -1 /var/run/systemd/generator/lvm2-activation*
/var/run/systemd/generator/lvm2-activation-early.service
/var/run/systemd/generator/lvm2-activation-net.service
/var/run/systemd/generator/lvm2-activation.service

# systemctl status lvm2-activation-early.service
● lvm2-activation-early.service - Activation of LVM2 logical volumes
   Loaded: loaded (/etc/lvm/lvm.conf; generated; vendor preset: enabled)
   Active: inactive (dead) since Thu 2019-03-28 17:20:48 MSK; 3 weeks 4 days ago
     Docs: man:lvm2-activation-generator(8)
 Main PID: 897 (code=exited, status=0/SUCCESS)

systemd[1]: Starting Activation of LVM2 logical volumes...
systemd[1]: Started Activation of LVM2 logical volumes.
root@virt1:~# systemctl status lvm2-activation-net.service
● lvm2-activation-net.service - Activation of LVM2 logical volumes
   Loaded: loaded (/etc/lvm/lvm.conf; generated; vendor preset: enabled)
   Active: inactive (dead) since Thu 2019-03-28 17:21:24 MSK; 3 weeks 4 days ago
     Docs: man:lvm2-activation-generator(8)
 Main PID: 1537 (code=exited, status=0/SUCCESS)

systemd[1]: Starting Activation of LVM2 logical volumes...
lvm[1537]:   4 logical volume(s) in volume group "vg-one-100" now active
systemd[1]: Started Activation of LVM2 logical volumes.
root@virt1:~# systemctl status lvm2-activation.service
● lvm2-activation.service - Activation of LVM2 logical volumes
   Loaded: loaded (/etc/lvm/lvm.conf; generated; vendor preset: enabled)
   Active: inactive (dead) since Thu 2019-03-28 17:20:48 MSK; 3 weeks 4 days ago
     Docs: man:lvm2-activation-generator(8)
 Main PID: 900 (code=exited, status=0/SUCCESS)

systemd[1]: Starting Activation of LVM2 logical volumes...
systemd[1]: Started Activation of LVM2 logical volumes.

The problem in: I can't automatically activate all LVM volumes during the boot because lvm2-activator-net.service activate volumes after it has been attached (logged-in) over iSCSI instead of multipath device (journalctl fragment):

. . .
kernel: sd 11:0:0:0: [sdc] 21474836480 512-byte logical blocks: (11.0 TB/10.0 TiB)
kernel: sd 10:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
kernel: sd 11:0:0:0: [sdc] Write Protect is off
kernel: sd 11:0:0:0: [sdc] Mode Sense: 97 00 10 08
kernel: sd 11:0:0:0: [sdc] Write cache: enabled, read cache: enabled, supports DPO and FUA
kernel: sd 10:0:0:0: [sdb] Attached SCSI disk
kernel: sd 11:0:0:0: [sdc] Attached SCSI disk
iscsiadm[1765]: Logging in to [iface: default, target: iqn.2012-07.com.promise:alias.tgt0000.2000000155588d75, portal: 172.16.0.151,3260] (multiple)
iscsiadm[1765]: Logging in to [iface: default, target: iqn.2012-07.com.promise:alias.tgt0000.2000000155588d75, portal: 172.16.1.151,3260] (multiple)
iscsiadm[1765]: Login to [iface: default, target: iqn.2012-07.com.promise:alias.tgt0000.2000000155588d75, portal: 172.16.0.151,3260] successful.
iscsiadm[1765]: Login to [iface: default, target: iqn.2012-07.com.promise:alias.tgt0000.2000000155588d75, portal: 172.16.1.151,3260] successful.
systemd[1]: Started Login to default iSCSI targets.
systemd[1]: Starting Activation of LVM2 logical volumes...
systemd[1]: Starting Activation of LVM2 logical volumes...
multipathd[884]: sdb: add path (uevent)
systemd[1]: Started Activation of LVM2 logical volumes.
systemd[1]: Started Activation of LVM2 logical volumes.
systemd[1]: Reached target Remote File Systems (Pre).
systemd[1]: Mounting /var/lib/one/datastores/101...
systemd[1]: Mounting /var/lib/one/datastores/100...
multipathd[884]: mpathb: load table [0 21474836480 multipath 1 retain_attached_hw_handler 0 1 1 service-time 0 1 1 8:16 1]
multipathd[884]: mpathb: event checker started
multipathd[884]: sdb [8:16]: path added to devmap mpathb
multipathd[884]: sdc: add path (uevent)
multipathd[884]: mpathb: load table [0 21474836480 multipath 1 retain_attached_hw_handler 0 2 1 service-time 0 1 1 8:16 1 service-time 0 1 1 8:32 1]
. . .

Conditions to start lvm2-activation-net.service is correct:

# grep After /var/run/systemd/generator/lvm2-activation-net.service 
After=lvm2-activation.service iscsi.service fcoe.service

How can I properly activate all logical volumes during the boot?

2

Since you seem to have a single physical volume, I really wonder how partial activation can happen in your case. It should be all or nothing. But here are a couple of issues to take care of anyway:

  • You need persistent multipath device names. I'm not sure where mpathb comes from, but I recommend against enabling user_friendly_names in /etc/multipath.conf for clarity. Either configure the alias manually or use the WWID as provided by your storage.
  • The LVM filters are regular expressions, not shell globs, so you need to change the syntax to something like

    filter = ["a|^/dev/mapper/222c60001556480c6$|", "r|.|"]
    

    (global_filter is optional for proper functionality, but it may make a difference for bootup times.)

  • You have to delay activation until the multipath devices of all your physical volumes appear. One possibility is adding

    Requires = dev-mapper-222c60001556480c6.device
    After = dev-mapper-222c60001556480c6.device
    

    to /etc/systemd/system/lvm2-activation-net.service.d/wait_for_storage.conf. Another is creating a dedicated activation service.

  • iSCSI storage devices (and their multipath devices) can take a long time to appear. You might need to create /etc/systemd/system/dev-mapper-222c60001556480c6.device containing

    [Unit]
    JobTimeoutSec=3min
    

    to make sure systemd does not time out too quickly waiting for it. Use symbolic links to a common file if you've got several such devices.

Even if the above does not immediately fix your problem, it will make debugging more tractable. Good luck!

  • I have already enabled user_friendly_names in /etc/multipath.conf (I forgot mention this). I will try your advises and let you know if it helps to me. Partly activated volumes are present because I activate it manually after boot. Thank's! – Yurij Goncharuk Apr 23 at 10:46
  • I've just added delay activation until the multipath device apper and it works. Thank you very much!!! – Yurij Goncharuk Apr 23 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.