linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] How LVM root volumes gets mounted at boot time ?
@ 2014-07-25 20:50 Vivek Satpute
  2014-07-28  8:22 ` Peter Rajnoha
  0 siblings, 1 reply; 7+ messages in thread
From: Vivek Satpute @ 2014-07-25 20:50 UTC (permalink / raw)
  To: linux-lvm

[-- Attachment #1: Type: text/plain, Size: 1630 bytes --]

Hi,

I am seeing that LVM2 is integrated with systemd framework and so
accordingly there are many changes in the way how LVM rootfs volume get
mounted at boot-up time.

For root LVM volume, LVM create virtual block device "/dev/rhel_host/root".
And systemd shows following description of this device.

[root@host vivek]# systemctl show dev-rhel_host-root.device
Id=dev-rhel_host-root.device
Names=dev-rhel_host-root.device
Following=sys-devices-virtual-block-dm\x2d0.device
Description=/dev/rhel_host/root
*LoadState=loaded*
*ActiveState=active*
*SubState=plugged*
InactiveExitTimestamp=Thu 2014-07-24 15:13:50 IST
InactiveExitTimestampMonotonic=17789280
ActiveEnterTimestamp=Thu 2014-07-24 15:13:50 IST
ActiveEnterTimestampMonotonic=17789280
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=no
CanStop=no
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureIsolate=no
IgnoreOnIsolate=yes
IgnoreOnSnapshot=yes
NeedDaemonReload=no
JobTimeoutUSec=1min 30s
ConditionTimestampMonotonic=0
ConditionResult=no
Transient=no
*SysFSPath=/sys/devices/virtual/block/dm-0*


I want to know,
1) How systemd and LVM create above dependency of "/dev/rhel_host/root" ?
How "/dev/rhel_host/root" gets SysFsPath "*/sys/devices/virtual/block/dm-0"
? *

2) Which is the udev rule/systemd file creates above dependency (seen by
command "systemctl show dev-rhel_host-root.device").

3) How LVM root volume " /dev/rhel_host/root" gets mounted ? Does it
handled by LVmetaD ?

Any suggestions/inputs would be welcome.


Thanks and Regards,
Vivek

[-- Attachment #2: Type: text/html, Size: 5470 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] How LVM root volumes gets mounted at boot time ?
  2014-07-25 20:50 [linux-lvm] How LVM root volumes gets mounted at boot time ? Vivek Satpute
@ 2014-07-28  8:22 ` Peter Rajnoha
  2014-08-07 18:20   ` Vivek Satpute
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Rajnoha @ 2014-07-28  8:22 UTC (permalink / raw)
  To: vivekonline86; +Cc: LVM general discussion and development

On 07/25/2014 10:50 PM, Vivek Satpute wrote:
> Hi, 
> 
> I am seeing that LVM2 is integrated with systemd framework and so
> accordingly there are many changes in the way how LVM rootfs volume get
> mounted at boot-up time.
> 
> For root LVM volume, LVM create virtual block device
> "/dev/rhel_host/root". And systemd shows following description of this
> device.
> 
> [root@host vivek]# systemctl show dev-rhel_host-root.device
> Id=dev-rhel_host-root.device
> Names=dev-rhel_host-root.device
> Following=sys-devices-virtual-block-dm\x2d0.device
> Description=/dev/rhel_host/root
> *LoadState=loaded*
> *ActiveState=active*
> *SubState=plugged*
> InactiveExitTimestamp=Thu 2014-07-24 15:13:50 IST
> InactiveExitTimestampMonotonic=17789280
> ActiveEnterTimestamp=Thu 2014-07-24 15:13:50 IST
> ActiveEnterTimestampMonotonic=17789280
> ActiveExitTimestampMonotonic=0
> InactiveEnterTimestampMonotonic=0
> CanStart=no
> CanStop=no
> CanReload=no
> CanIsolate=no
> StopWhenUnneeded=no
> RefuseManualStart=no
> RefuseManualStop=no
> AllowIsolate=no
> DefaultDependencies=yes
> OnFailureIsolate=no
> IgnoreOnIsolate=yes
> IgnoreOnSnapshot=yes
> NeedDaemonReload=no
> JobTimeoutUSec=1min 30s
> ConditionTimestampMonotonic=0
> ConditionResult=no
> Transient=no
> *SysFSPath=/sys/devices/virtual/block/dm-0*
> 
> 
> I want to know, 
> 1) How systemd and LVM create above dependency of "/dev/rhel_host/root"
> ? How "/dev/rhel_host/root" gets SysFsPath
> "*/sys/devices/virtual/block/dm-0" ? *

The dm-0 is the actual kernel name of the device and the sysfs item is
created automatically by block layer as for any other block device when
it's created/activated - the kernel name is always used for that sysfs
path.

The /dev/rhel_host/root is just a symlink created in addition to that
(either by udev and driven by udev rule or by LVM directly, but udev is
used by default now and it's the preferred way).

Systemd has access to the list of device kernel names and their associated
symlinks via udev database that systemd reads. The .device systemd units
are created automatically by systemd based on incoming events.

It's possible to set the description via udev rule, but we're not doing this.
So the description you see is in the "systemctl show" output is the default
one added by systemd itself.

> 
> 2) Which is the udev rule/systemd file creates above dependency (seen by
> command "systemctl show dev-rhel_host-root.device").

/lib/udev/rules.d/11-dm-lvm.rules and this line exactly:

# Create symlinks for top-level devices only.
ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end"

That's for all LVs in general. The root LV is specific in a way that it's
activated in initramfs and hence it depends on how the initramfs is handled
in your distro. For example Fedora uses udev-driven dracut for the initramfs
which copies this rule into initramfs image and it activates the root LV directly,
not depending on lvmetad. But some distros may use lvmetad even in initramfs for
the root LV autoactivation (I think it's Arch Linux that does it this way at the
moment). All the /dev content is created by udev.

> 
> 3) How LVM root volume " /dev/rhel_host/root" gets mounted ? Does it
> handled by LVmetaD ?

Mount points are never handled by lvmetad. Lvmetad only handles LVM metadata
caching and LVM volume autoactivation (with the help of udev since lvmetad needs
to know when the underlying device - PV - appears.).

Systemd itself handles mounting - it either reads /etc/fstab and translates
it into .mount systemd units or it uses native .mount systemd unit if they
exist. Systemd then waits for the particular .device unit the .mount unit is
bound to and if the device is present, it mounts it...

> 
> Any suggestions/inputs would be welcome.
> 
> 
> Thanks and Regards,
> Vivek
> 
> 
> 
> 
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
> 


-- 
Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] How LVM root volumes gets mounted at boot time ?
  2014-07-28  8:22 ` Peter Rajnoha
@ 2014-08-07 18:20   ` Vivek Satpute
  2014-08-08  6:34     ` Peter Rajnoha
  0 siblings, 1 reply; 7+ messages in thread
From: Vivek Satpute @ 2014-08-07 18:20 UTC (permalink / raw)
  To: Peter Rajnoha; +Cc: LVM general discussion and development

[-- Attachment #1: Type: text/plain, Size: 5091 bytes --]

Thanks a lot Peter for replying.

I know that */sys/devices/virtual**/block/dm-0  *SysFsPath would get
created by block-layer when corresponding block device gets created.

Actually I am looking for how below dependencies is getting created for LVM
volume by systemd:

[root@host]# systemctl show dev-rhel_host-root.device
Id=dev-rhel_host-root.device
Names=dev-rhel_host-root.device

*Following=sys-devices-virtual-block-dm\x2d0.device*
[...]
*SysFSPath=/sys/devices/virtual/block/dm-0*

/dev/rhel_host/root (path of LVM volume) is actually a symbolic link
pointing to /dev/dm-0, then how systemd recognize that device
dev-rhel_host-root.device
follows *sys-devices-virtual-block-dm\x2d0.device ?*


Thanks,
Vivek


On Mon, Jul 28, 2014 at 1:52 PM, Peter Rajnoha <prajnoha@redhat.com> wrote:

> On 07/25/2014 10:50 PM, Vivek Satpute wrote:
> > Hi,
> >
> > I am seeing that LVM2 is integrated with systemd framework and so
> > accordingly there are many changes in the way how LVM rootfs volume get
> > mounted at boot-up time.
> >
> > For root LVM volume, LVM create virtual block device
> > "/dev/rhel_host/root". And systemd shows following description of this
> > device.
> >
> > [root@host vivek]# systemctl show dev-rhel_host-root.device
> > Id=dev-rhel_host-root.device
> > Names=dev-rhel_host-root.device
> > Following=sys-devices-virtual-block-dm\x2d0.device
> > Description=/dev/rhel_host/root
> > *LoadState=loaded*
> > *ActiveState=active*
> > *SubState=plugged*
> > InactiveExitTimestamp=Thu 2014-07-24 15:13:50 IST
> > InactiveExitTimestampMonotonic=17789280
> > ActiveEnterTimestamp=Thu 2014-07-24 15:13:50 IST
> > ActiveEnterTimestampMonotonic=17789280
> > ActiveExitTimestampMonotonic=0
> > InactiveEnterTimestampMonotonic=0
> > CanStart=no
> > CanStop=no
> > CanReload=no
> > CanIsolate=no
> > StopWhenUnneeded=no
> > RefuseManualStart=no
> > RefuseManualStop=no
> > AllowIsolate=no
> > DefaultDependencies=yes
> > OnFailureIsolate=no
> > IgnoreOnIsolate=yes
> > IgnoreOnSnapshot=yes
> > NeedDaemonReload=no
> > JobTimeoutUSec=1min 30s
> > ConditionTimestampMonotonic=0
> > ConditionResult=no
> > Transient=no
> > *SysFSPath=/sys/devices/virtual/block/dm-0*
> >
> >
> > I want to know,
> > 1) How systemd and LVM create above dependency of "/dev/rhel_host/root"
> > ? How "/dev/rhel_host/root" gets SysFsPath
> > "*/sys/devices/virtual/block/dm-0" ? *
>
> The dm-0 is the actual kernel name of the device and the sysfs item is
> created automatically by block layer as for any other block device when
> it's created/activated - the kernel name is always used for that sysfs
> path.
>
> The /dev/rhel_host/root is just a symlink created in addition to that
> (either by udev and driven by udev rule or by LVM directly, but udev is
> used by default now and it's the preferred way).
>
> Systemd has access to the list of device kernel names and their associated
> symlinks via udev database that systemd reads. The .device systemd units
> are created automatically by systemd based on incoming events.
>
> It's possible to set the description via udev rule, but we're not doing
> this.
> So the description you see is in the "systemctl show" output is the default
> one added by systemd itself.
>
> >
> > 2) Which is the udev rule/systemd file creates above dependency (seen by
> > command "systemctl show dev-rhel_host-root.device").
>
> /lib/udev/rules.d/11-dm-lvm.rules and this line exactly:
>
> # Create symlinks for top-level devices only.
> ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*",
> SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end"
>
> That's for all LVs in general. The root LV is specific in a way that it's
> activated in initramfs and hence it depends on how the initramfs is handled
> in your distro. For example Fedora uses udev-driven dracut for the
> initramfs
> which copies this rule into initramfs image and it activates the root LV
> directly,
> not depending on lvmetad. But some distros may use lvmetad even in
> initramfs for
> the root LV autoactivation (I think it's Arch Linux that does it this way
> at the
> moment). All the /dev content is created by udev.
>
> >
> > 3) How LVM root volume " /dev/rhel_host/root" gets mounted ? Does it
> > handled by LVmetaD ?
>
> Mount points are never handled by lvmetad. Lvmetad only handles LVM
> metadata
> caching and LVM volume autoactivation (with the help of udev since lvmetad
> needs
> to know when the underlying device - PV - appears.).
>
> Systemd itself handles mounting - it either reads /etc/fstab and translates
> it into .mount systemd units or it uses native .mount systemd unit if they
> exist. Systemd then waits for the particular .device unit the .mount unit
> is
> bound to and if the device is present, it mounts it...
>
> >
> > Any suggestions/inputs would be welcome.
> >
> >
> > Thanks and Regards,
> > Vivek
> >
> >
> >
> >
> > _______________________________________________
> > linux-lvm mailing list
> > linux-lvm@redhat.com
> > https://www.redhat.com/mailman/listinfo/linux-lvm
> > read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
> >
>
>
> --
> Peter
>

[-- Attachment #2: Type: text/html, Size: 7646 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] How LVM root volumes gets mounted at boot time ?
  2014-08-07 18:20   ` Vivek Satpute
@ 2014-08-08  6:34     ` Peter Rajnoha
  2014-08-08  8:33       ` Vivek Satpute
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Rajnoha @ 2014-08-08  6:34 UTC (permalink / raw)
  To: Vivek Satpute; +Cc: LVM general discussion and development

On 08/07/2014 08:20 PM, Vivek Satpute wrote:
> Thanks a lot Peter for replying.
> 
> I know that */sys/devices/virtual**/block/dm-0  *SysFsPath would get
> created by block-layer when corresponding block device gets created. 
> 
> Actually I am looking for how below dependencies is getting created for
> LVM volume by systemd:
> 
> [root@host]# systemctl show dev-rhel_host-root.device
> Id=dev-rhel_host-root.device
> Names=dev-rhel_host-root.device
> *Following=sys-devices-virtual-block-dm\x2d0.device
> *
> [...]
> *SysFSPath=/sys/devices/virtual/block/dm-0*
> *
> *
> /dev/rhel_host/root (path of LVM volume) is actually a symbolic link
> pointing to /dev/dm-0, then how systemd recognize that
> device dev-rhel_host-root.device
> follows *sys-devices-virtual-block-dm\x2d0.device ?*
> *

Systemd can read this information from udev events (or udev database records).
The information about all existing symlinks and their names, the dev node name
("kernel name") and related sysfs link is all recorded in udev database so systemd
just makes the .device unit out of this information.

-- 
Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] How LVM root volumes gets mounted at boot time ?
  2014-08-08  6:34     ` Peter Rajnoha
@ 2014-08-08  8:33       ` Vivek Satpute
  2014-08-08  8:38         ` Peter Rajnoha
  0 siblings, 1 reply; 7+ messages in thread
From: Vivek Satpute @ 2014-08-08  8:33 UTC (permalink / raw)
  To: Peter Rajnoha; +Cc: LVM general discussion and development

[-- Attachment #1: Type: text/plain, Size: 1302 bytes --]

Thanks a much Peter. This really helped a lot :-)


Regards


On Fri, Aug 8, 2014 at 12:04 PM, Peter Rajnoha <prajnoha@redhat.com> wrote:

> On 08/07/2014 08:20 PM, Vivek Satpute wrote:
> > Thanks a lot Peter for replying.
> >
> > I know that */sys/devices/virtual**/block/dm-0  *SysFsPath would get
> > created by block-layer when corresponding block device gets created.
> >
> > Actually I am looking for how below dependencies is getting created for
> > LVM volume by systemd:
> >
> > [root@host]# systemctl show dev-rhel_host-root.device
> > Id=dev-rhel_host-root.device
> > Names=dev-rhel_host-root.device
> > *Following=sys-devices-virtual-block-dm\x2d0.device
> > *
> > [...]
> > *SysFSPath=/sys/devices/virtual/block/dm-0*
> > *
> > *
> > /dev/rhel_host/root (path of LVM volume) is actually a symbolic link
> > pointing to /dev/dm-0, then how systemd recognize that
> > device dev-rhel_host-root.device
> > follows *sys-devices-virtual-block-dm\x2d0.device ?*
> > *
>
> Systemd can read this information from udev events (or udev database
> records).
> The information about all existing symlinks and their names, the dev node
> name
> ("kernel name") and related sysfs link is all recorded in udev database so
> systemd
> just makes the .device unit out of this information.
>
> --
> Peter
>

[-- Attachment #2: Type: text/html, Size: 1922 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] How LVM root volumes gets mounted at boot time ?
  2014-08-08  8:33       ` Vivek Satpute
@ 2014-08-08  8:38         ` Peter Rajnoha
  2014-08-14 18:19           ` Vivek Satpute
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Rajnoha @ 2014-08-08  8:38 UTC (permalink / raw)
  To: Vivek Satpute; +Cc: LVM general discussion and development

On 08/08/2014 10:33 AM, Vivek Satpute wrote:
> Thanks a much Peter. This really helped a lot :-)
> 

You're welcome.

BTW, if you want to see the contents of udev database, just call
"udevadm info --export-db" on cmd line. I think only one of
the paths from sysfs dir is mentioned there, but udev (and all clients
using udev via libudev) knows about all the other sysfs aliases for this
device.

-- 
Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [linux-lvm] How LVM root volumes gets mounted at boot time ?
  2014-08-08  8:38         ` Peter Rajnoha
@ 2014-08-14 18:19           ` Vivek Satpute
  0 siblings, 0 replies; 7+ messages in thread
From: Vivek Satpute @ 2014-08-14 18:19 UTC (permalink / raw)
  To: Peter Rajnoha; +Cc: LVM general discussion and development

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

Yea.. I "udevadm info" is quite helpful. Thanks a much Peter. Appreciate
your help.


Thanks and Regards,
Vivek Satpute


On Fri, Aug 8, 2014 at 2:08 PM, Peter Rajnoha <prajnoha@redhat.com> wrote:

> On 08/08/2014 10:33 AM, Vivek Satpute wrote:
> > Thanks a much Peter. This really helped a lot :-)
> >
>
> You're welcome.
>
> BTW, if you want to see the contents of udev database, just call
> "udevadm info --export-db" on cmd line. I think only one of
> the paths from sysfs dir is mentioned there, but udev (and all clients
> using udev via libudev) knows about all the other sysfs aliases for this
> device.
>
> --
> Peter
>

[-- Attachment #2: Type: text/html, Size: 1144 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-08-14 18:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 20:50 [linux-lvm] How LVM root volumes gets mounted at boot time ? Vivek Satpute
2014-07-28  8:22 ` Peter Rajnoha
2014-08-07 18:20   ` Vivek Satpute
2014-08-08  6:34     ` Peter Rajnoha
2014-08-08  8:33       ` Vivek Satpute
2014-08-08  8:38         ` Peter Rajnoha
2014-08-14 18:19           ` Vivek Satpute

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).