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
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
05-30-2017, 05:56 AM
#1
LQ Newbie
Registered: Dec 2016
Posts: 27
Rep:
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 .
05-30-2017, 06:35 AM
#2
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039
I think you will not find any "inherited" mounts.
05-30-2017, 06:57 AM
#3
LQ Newbie
Registered: Dec 2016
Posts: 27
Original Poster
Rep:
Quote:
Originally Posted by
pan64
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
05-30-2017, 07:12 AM
#4
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039
I meant you will not know if that was inherited. Sorry. Only if you know the original mounts and you can compare.
05-30-2017, 07:18 AM
#5
LQ Newbie
Registered: Dec 2016
Posts: 27
Original Poster
Rep:
Quote:
Originally Posted by
pan64
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) ?
05-30-2017, 07:33 AM
#6
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039
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.
05-30-2017, 09:16 AM
#7
LQ Newbie
Registered: Dec 2016
Posts: 27
Original Poster
Rep:
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 .
05-30-2017, 11:03 AM
#8
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039
see man proc and look for mountinfo
05-31-2017, 01:56 AM
#9
LQ Newbie
Registered: Dec 2016
Posts: 27
Original Poster
Rep:
Quote:
Originally Posted by
pan64
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 ?
05-31-2017, 02:17 AM
#10
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039
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.
05-31-2017, 02:56 AM
#11
LQ Newbie
Registered: Dec 2016
Posts: 27
Original Poster
Rep:
Quote:
Originally Posted by
pan64
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 !
05-31-2017, 03:21 AM
#12
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,039
if I understand it well, yes.
All times are GMT -5. The time now is 01:56 AM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News