4

I am trying to install my first Linux system and I am stuck setting up the hard drives. Given my lack of experience I decided to use the guided setup from the hard drive setup screen figuring I would go back after the completed Debian installation and simply resize my drives as needed.

However when trying to run

sudo service lvm2 start
I get a message "unit lvm2.service is masked".

Any ideas as to why this is happening? all I could find was a note that LVM as not compatible with grub /boot and should be outside the storage disk managed by LVM.

If so is it truly referring to the entire disk on which /boot is loaded or can it be simply a separate logical partition on that disk?

JdeBP
  • 68,745
lynx
  • 71

3 Answers3

5

Short answer: it's OK.

/lib/systemd/system/lvm2.service is created as a symbolic link to /dev/null by the lvm2 Debian package, causing the service to be permanently masked, because the job of the SysVinit-style /etc/init.d/lvm2 start-up script is actually split into multiple native systemd units.

lvm2.service needs to exist, though, because otherwise the SysVinit compatibility logic would automatically create a systemd unit that would just run that script. Since a systemd-native /lib/systemd/system/lvm2.service exists, that won't happen - but because all the actual work is done by instances of lvm2-pvscan@.service and the lvm2-monitor.service, the only job of unit lvm2.service is to mask out the redundant SysVinit-style startup script.

Also, you're correct that LVM can be used on a Debian system disk, as long as /boot is placed into a traditional non-LVM partition that the system firmware can understand - as GRUB is using the services of the system firmware to access files from that filesystem.

(Yes, modern versions of GRUB do include the capacity to read filesystems on LVM. Debian 9's version of GRUB even includes the lvm.mod GRUB module. But the problem is mostly that the Debian Installer cannot yet set it up reliably - or could not at the time of Debian 9 release. I would guess it's probably mostly about getting the installer to "understand" the new possibilities when having /boot inside LVM, and getting it to warn the user about configurations that won't work.)

telcoM
  • 96,466
  • thanks for that, while I don't yet understand all the detail you have provided at least I know I'm not heading into a brick wall. By the way I have installed Ver. 9.5 so even better I assume. – lynx Sep 17 '18 at 13:24
  • Thanks. What is the solution to start LVM service then? https://unix.stackexchange.com/questions/502363/failed-to-start-lvm2-service-unit-lvm2-service-is-masked – Tim Feb 22 '19 at 23:36
1

If you have a distribution without Systemd (for example: an old Debian or a recent Devuan) try this:

/etc/init.d/lvm2 start

For all the other standard cases (for example: a recent Debian) check the other answers to discover why you should not try to start this service.

Kerd
  • 29
  • 1
    Welcome to the site. As it stands, the post is qualified as "low-quality-post". You might want to add additional information as to what's the purpose of the command, how does it address OP's specific concerns, and why exactly you recommend this solution to OP's question. – Sergiy Kolodyazhnyy Feb 27 '19 at 02:12
  • 1
    @SergiyKolodyazhnyy I've edited the question to make it useful in some circumstances. – Valerio Bozz Aug 04 '20 at 15:23
  • @Valerio Thank you, the post is much better now. The original author of the answer may not return to update it further, but thanks to your edit the answer may now be useful to others, within certain context of course. – Sergiy Kolodyazhnyy Aug 06 '20 at 09:03
-1

If you are stuck on unit lvm2.service is masked and you want at whatever cost to start that legacy service, you can try to check if your service is a symlink to /dev/null:

ls -l /lib/systemd/system/lvm2.service

(You should see lvm2.service -> /dev/null)

In that case, just remove that dummy service:

rm /lib/systemd/system/lvm2.service

And you would be able to start your service again:

systemctl start lvm2

In any case check the other answers to discover why that service is disabled.