LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 05-30-2017, 05:56 AM   #1
cianfa72
LQ Newbie
 
Registered: Dec 2016
Posts: 27

Rep: Reputation: Disabled
Smile How to check for mounted filesystems inside a lxc container


Hi,

I'm working on a lxc container supported via libvirt container driver.

From http://libvirt.org/drvlxc.html the container starts with special mounts, some of them re-mounted with new instances to provide container specific data (e.g. /dev and /proc re-mounted inside the container with new instances of tmpfs and proc filesystem respectively)

From inside the container how can I check if a mount point is actually re-mounted by libvirt driver or if it is just inherited from the host OS filesystem mounts ?

Code:
[host:~]$ 
[host:~]$ virsh -c lxc:/// start helloworld
Domain helloworld started

[host:~]$ 
[host:~]$ 
[host:~]$ 
[host:~]$ 
[host:~]$ virsh -c lxc:/// console helloworld
Connected to domain helloworld
Escape character is ^]
sh-3.2# 
sh-3.2# 
sh-3.2# 
sh-3.2# ls -la /proc/mounts 
lrwxrwxrwx 1 root root 11 May 30 10:48 /proc/mounts -> self/mounts
sh-3.2# 
sh-3.2# 
sh-3.2# 
sh-3.2# cat /proc/mounts         
rootfs / rootfs rw 0 0
devpts /dev/pts devpts rw,nosuid,relatime,gid=5,mode=620,ptmxmode=666 0 0
devfs /dev tmpfs rw,nosuid,relatime,size=64k,mode=755 0 0
/dev/mapper/panini_vol_grp-host_lv0 / ext4 rw,relatime,discard,data=ordered 0 0
none /var tmpfs rw,relatime,size=65536k 0 0
/dev/mapper/panini_vol_grp-host_data_log_lv0 /var/log ext4 rw,relatime,discard,data=ordered 0 0
none /var/run/lxc tmpfs rw,relatime,size=65536k 0 0
/proc net:[4026533018] proc rw,relatime 0 0
/proc net:[4026533120] proc rw,relatime 0 0
/proc net:[4026533206] proc rw,relatime 0 0
devpts /var/run/libvirt/lxc/helloworld.devpts devpts rw,nosuid,relatime,gid=5,mode=620,ptmxmode=666 0 0
devfs /var/run/libvirt/lxc/helloworld.dev tmpfs rw,nosuid,relatime,size=64k,mode=755 0 0
libvirt /var/run/libvirt/lxc/helloworld.fuse fuse rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other 0 0
none /tmp tmpfs rw,relatime,size=65536k 0 0
/dev/mapper/panini_vol_grp-host_data_scratch_lv0 /misc/scratch ext4 rw,relatime,discard,data=ordered 0 0
/dev/mapper/panini_vol_grp-host_data_config_lv0 /misc/config ext4 rw,relatime,discard,data=ordered 0 0
none /mnt tmpfs rw,relatime,size=512k 0 0
/dev/ram7 /mnt/ram7 ext3 rw,relatime,errors=continue,barrier=1,data=ordered 0 0
/dev/loop0 /lxc_rootfs/panini_vol_grp-calvados_lv0 ext4 rw,relatime,data=ordered 0 0
/dev/mapper/panini_vol_grp-uvf_lvcore /uvf_core ext4 rw,relatime,data=ordered 0 0
/dev/loop5 /lxc_rootfs/panini_vol_grp-xr_lv0 ext4 rw,relatime,data=ordered 0 0
/dev/loop9 /lxc_rootfs/panini_vol_grp-uvf_lv0 ext4 rw,relatime,data=ordered 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
proc /proc/sys proc ro,relatime 0 0
sysfs /sys sysfs ro,relatime 0 0
libvirt /proc/meminfo fuse rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other 0 0
tmpfs /dev/cgroup tmpfs rw,nosuid,nodev,noexec,relatime,size=64k,mode=755 0 0
cgroup /dev/cgroup/cpu cgroup rw,relatime,cpu 0 0
cgroup /dev/cgroup/cpuacct cgroup rw,relatime,cpuacct 0 0
cgroup /dev/cgroup/cpuset cgroup rw,relatime,cpuset 0 0
cgroup /dev/cgroup/memory cgroup rw,relatime,memory 0 0
cgroup /dev/cgroup/devices cgroup rw,relatime,devices 0 0
devpts /dev/ptmx devpts rw,nosuid,relatime,gid=5,mode=620,ptmxmode=666 0 0
/dev/mapper/panini_vol_grp-host_lv0 /etc/httpd ext4 rw,relatime,discard,data=ordered 0 0
/dev/mapper/panini_vol_grp-host_lv0 /var/www ext4 rw,relatime,discard,data=ordered 0 0
sh-3.2# 
sh-3.2# 
sh-3.2# cat /proc/self/mountinfo 
290 291 0:75 / /dev/pts rw,nosuid,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
291 305 0:76 / /dev rw,nosuid,relatime - tmpfs devfs rw,size=64k,mode=755
305 268 253:0 / / rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_lv0 rw,discard,data=ordered
320 305 0:19 / /var rw,relatime - tmpfs none rw,size=65536k
321 320 253:2 / /var/log rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_data_log_lv0 rw,discard,data=ordered
322 320 0:19 /run/lxc /var/run/lxc rw,relatime - tmpfs none rw,size=65536k
323 322 0:3 / /var/run/lxc/sysadmin/ns/net rw,relatime - proc /proc rw
324 322 0:3 / /var/run/lxc/default-sdr--1/ns/net rw,relatime - proc /proc rw
325 322 0:3 / /var/run/lxc/default-sdr__uvf--2/ns/net rw,relatime - proc /proc rw
326 320 0:75 / /var/run/libvirt/lxc/helloworld.devpts rw,nosuid,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
327 320 0:76 / /var/run/libvirt/lxc/helloworld.dev rw,nosuid,relatime - tmpfs devfs rw,size=64k,mode=755
328 320 0:77 / /var/run/libvirt/lxc/helloworld.fuse rw,nosuid,nodev,relatime - fuse libvirt rw,user_id=0,group_id=0,allow_other
329 305 0:20 / /tmp rw,relatime - tmpfs none rw,size=65536k
330 305 253:1 / /misc/scratch rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_data_scratch_lv0 rw,discard,data=ordered
331 305 253:3 / /misc/config rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_data_config_lv0 rw,discard,data=ordered
332 305 0:22 / /mnt rw,relatime - tmpfs none rw,size=512k
333 332 1:7 / /mnt/ram7 rw,relatime - ext3 /dev/ram7 rw,errors=continue,barrier=1,data=ordered
334 305 7:0 / /lxc_rootfs/panini_vol_grp-calvados_lv0 rw,relatime - ext4 /dev/loop0 rw,data=ordered
335 305 253:10 / /uvf_core rw,relatime - ext4 /dev/mapper/panini_vol_grp-uvf_lvcore rw,data=ordered
336 305 7:5 / /lxc_rootfs/panini_vol_grp-xr_lv0 rw,relatime - ext4 /dev/loop5 rw,data=ordered
337 305 7:9 / /lxc_rootfs/panini_vol_grp-uvf_lv0 rw,relatime - ext4 /dev/loop9 rw,data=ordered
306 305 0:79 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
307 306 0:79 /sys /proc/sys ro,relatime - proc proc rw
308 305 0:14 / /sys ro,relatime - sysfs sysfs rw
309 306 0:77 /meminfo /proc/meminfo rw,nosuid,nodev,relatime - fuse libvirt rw,user_id=0,group_id=0,allow_other
310 291 0:81 / /dev/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,size=64k,mode=755
311 310 0:27 /machine/helloworld.libvirt-lxc /dev/cgroup/cpu rw,relatime - cgroup cgroup rw,cpu
312 310 0:25 /machine/helloworld.libvirt-lxc /dev/cgroup/cpuacct rw,relatime - cgroup cgroup rw,cpuacct
313 310 0:26 /machine/helloworld.libvirt-lxc /dev/cgroup/cpuset rw,relatime - cgroup cgroup rw,cpuset
314 310 0:24 /machine/helloworld.libvirt-lxc /dev/cgroup/memory rw,relatime - cgroup cgroup rw,memory
315 310 0:23 /machine/helloworld.libvirt-lxc /dev/cgroup/devices rw,relatime - cgroup cgroup rw,devices
316 291 0:75 /ptmx /dev/ptmx rw,nosuid,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
317 305 253:0 /export/helloworld/config /etc/httpd rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_lv0 rw,discard,data=ordered
318 320 253:0 /export/helloworld/data /var/www rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_lv0 rw,discard,data=ordered
sh-3.2#
Thanks

Last edited by cianfa72; 05-30-2017 at 06:00 AM.
 
Old 05-30-2017, 06:35 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
I think you will not find any "inherited" mounts.
 
Old 05-30-2017, 06:57 AM   #3
cianfa72
LQ Newbie
 
Registered: Dec 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I think you will not find any "inherited" mounts.
Why? Quoting libvirt lxc driver documentation
Quote:
In the absence of any explicit configuration, the container will inherit the host OS filesystem mounts
The following entry (as seen inside the lxc container) is for the root (/) filesystem mount, I guess...
Code:
sh-3.2# cat /proc/self/mountinfo 
305 268 253:0 / / rw,relatime - ext4 /dev/mapper/panini_vol_grp-host_lv0 rw,discard,data=ordered
 
Old 05-30-2017, 07:12 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
I meant you will not know if that was inherited. Sorry. Only if you know the original mounts and you can compare.
 
Old 05-30-2017, 07:18 AM   #5
cianfa72
LQ Newbie
 
Registered: Dec 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I meant you will not know if that was inherited. Sorry. Only if you know the original mounts and you can compare.
Do you mean just comparing the actual content of the directory hierarchy under the mount point(s) ?
 
Old 05-30-2017, 07:33 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
executing mount inside and outside may give some hints, but /dev is local to the container, so not trivial.
you may try to use marker files which can be seen from outside and inside too.
 
Old 05-30-2017, 09:16 AM   #7
cianfa72
LQ Newbie
 
Registered: Dec 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Thanks for reply. A question related to the previous one...

In the content of /proc/self/mountinfo I'm not sure to fully understand the meaning of first pathname. For instance in this entry
Code:
309 306 0:77 /meminfo /proc/meminfo rw,nosuid,nodev,relatime - fuse libvirt rw,user_id=0,group_id=0,allow_other
What is the exact meaning of /meminfo there ?

Last edited by cianfa72; 05-30-2017 at 09:38 AM.
 
Old 05-30-2017, 11:03 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
see man proc and look for mountinfo
 
Old 05-31-2017, 01:56 AM   #9
cianfa72
LQ Newbie
 
Registered: Dec 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
see man proc and look for mountinfo
Sure, I read it....and I've the following doubt

Quote:
/proc/[pid]/mountinfo (since Linux 2.6.26)
This file contains information about mount points. It contains lines of the form:

36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
(1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)

The numbers in parentheses are labels for the descriptions below:

(1) mount ID: unique identifier of the mount (may be reused after umount(2)).

(2) parent ID: ID of parent mount (or of self for the top of the mount tree).

(3) major:minor: value of st_dev for files on filesystem (see stat(2)).

(4) root: root of the mount within the filesystem.

(5) mount point: mount point relative to the process's root.
As you can see (4) point to "root of the mount within the filesystem" but neverthless to me is unclear which root does it refer to ?
 
Old 05-31-2017, 02:17 AM   #10
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
in general root of the filesystem where the mount point created. But meminfo is a very special case, see the link you posted: http://libvirt.org/drvlxc.html
Code:
/proc/meminfo a FUSE backed file reflecting memory limits of the container
probably it has no real "parent", it is only a virtual file.
 
Old 05-31-2017, 02:56 AM   #11
cianfa72
LQ Newbie
 
Registered: Dec 2016
Posts: 27

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
in general root of the filesystem where the mount point created.
just to be sure I understand correctly: we know a mount point (directory) is created in a filesystem (basically it is "created" either physically on a disk or in memory (RAM) in case of virtual filesystem - e.g. a tmpfs filesystem). Now this filesystem is mounted in the system's "directory tree" and its root has a pathname in that "directory tree" of course.

Thus, are you referring to that pathname (starting from /) in the sentence "in general root of the filesystem where the mount point created" ?

thanks in advance !
 
Old 05-31-2017, 03:21 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039

Rep: Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347Reputation: 7347
if I understand it well, yes.
 
  


Reply

Tags
container, filesystem, lxc, mount point



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXC Container: sound Not working charlie101 Linux - Virtualization and Cloud 11 04-14-2020 01:15 AM
LXer: Inside the Open Container Project: How Docker plans to unite the container market LXer Syndicated Linux News 0 06-23-2015 04:30 AM
How to use Local ISO for LXC Container? sunveer Linux - Software 0 10-04-2013 04:44 AM
[SOLVED] Outputting X display from inside an LXC Container charlie101 Linux - Virtualization and Cloud 1 02-04-2013 09:41 PM
How to end a Linux Container (LXC) from within? Skaperen Linux - Virtualization and Cloud 0 06-14-2011 09:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 01:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration