19 systemd filesystem mount automount
to add user to sudoers in Centos
[root@localhost ~]# usermod -aG wheel bit
[bit@localhost ~]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Sep 9 22:05:18 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=64f8607e-7764-4841-bd8b-3196bbea8223 /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
[bit@localhost ~]$
[root@localhost ~]# usermod -aG wheel bit
================================
[bit@localhost ~]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Sep 9 22:05:18 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root / xfs defaults 0 0
UUID=64f8607e-7764-4841-bd8b-3196bbea8223 /boot xfs defaults 0 0
/dev/mapper/cl-swap swap swap defaults 0 0
[bit@localhost ~]$
=======================================
on systemd system you can mount filesystem via
1)/etc/fstab
2)systemd
=======================================
[bit@localhost system]$ pwd
/usr/lib/systemd/system
[bit@localhost system]$
[bit@localhost system]$ cat tmp.mount
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Temporary Directory
Documentation=man:hier(7)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=tmpfs <<device
Where=/tmp <<directory
Type=tmpfs
Options=mode=1777,strictatime
# Make 'systemctl enable tmp.mount' work:
[Install]
WantedBy=local-fs.target
===============================
lvs — report information about logical volumes
[root@localhost ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root cl -wi-ao---- 36.99g
swap cl -wi-ao---- 2.00g
===============================
create mount folder
[root@localhost system]# mkdir /lvdisk
create mount folder
[root@localhost system]# mkdir /lvdisk
create lvdisk.mount file
[root@localhost system]# cat lvdisk.mount
[Unit]
Description = my test mount
[Mount]
What = /dev/sda1
Where = /lvdisk
Type = xfs
[Install]
WantedBy = graphical.target
[root@localhost system]# mount | grep lvdisk
/dev/sda1 on /lvdisk type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@localhost system]# umount /lvdisk
[root@localhost system]# mount | grep lvdisk
[root@localhost system]# systemctl start lvdisk.mount
[root@localhost system]# systemctl status lvdisk.mount
● lvdisk.mount - my test mount
Loaded: loaded (/etc/systemd/system/lvdisk.mount; enabled; vendor preset: disabled)
Active: active (mounted) since Sat 2017-09-16 14:18:04 EDT; 7s ago
Where: /lvdisk
What: /dev/sda1
Process: 10268 ExecMount=/bin/mount /dev/sda1 /lvdisk -t xfs (code=exited, status=0/SUCCESS)
Sep 16 14:18:04 localhost.localdomain systemd[1]: Mounting my test mount...
Sep 16 14:18:04 localhost.localdomain systemd[1]: Mounted my test mount.
[root@localhost system]#
to ensure mount keep active after reboot:
[root@localhost system]# systemctl enable lvdisk.mount
Created symlink from /etc/systemd/system/graphical.target.wants/lvdisk.mount to /etc/systemd/system/lvdisk.mount.
====================================
automount
For automount we create the same mount file but we don't want it to be mounted.
we want mounting if some activity is on mount directory
automount
For automount we create the same mount file but we don't want it to be mounted.
we want mounting if some activity is on mount directory
before configuring automount, we have to stop lvdisk.mount
systemctl disable/stop lvdisk.mount
systemctl disable/stop lvdisk.mount
[bit@localhost system]$ sudo vim lvdisk.automount
[bit@localhost system]$ cat lvdisk.automount
[Unit]
Description = lvdisk automount
[Automount]
Where = /lvdisk
[Install]
WantedBy = graphical.target
[bit@localhost system]$
lvdisk.automount must be the same name as lvdisk.automount
[bit@localhost system]$ cat lvdisk.mount
[Unit]
Description = my test mount
[Mount]
What = /dev/sda1
Where = /lvdisk
Type = xfs
[Install]
WantedBy = graphical.target
[bit@localhost system]$
[bit@localhost system]$ cat lvdisk.automount
[Unit]
Description = lvdisk automount
[Automount]
Where = /lvdisk
[Install]
WantedBy = graphical.target
[bit@localhost system]$
lvdisk.automount must be the same name as lvdisk.automount
[bit@localhost system]$ cat lvdisk.mount
[Unit]
Description = my test mount
[Mount]
What = /dev/sda1
Where = /lvdisk
Type = xfs
[Install]
WantedBy = graphical.target
[bit@localhost system]$
=====================================
[bit@localhost system]$ systemctl enable lvdisk.automount
Created symlink from /etc/systemd/system/graphical.target.wants/lvdisk.automount to /etc/systemd/system/lvdisk.automount.
[bit@localhost system]$ systemctl start lvdisk.automount
[bit@localhost system]$ systemctl status lvdisk.automount
● lvdisk.automount - lvdisk automount
Loaded: loaded (/etc/systemd/system/lvdisk.automount; enabled; vendor preset: disabled)
Active: active (waiting) since Sun 2017-09-17 09:08:58 EDT; 8s ago
Where: /lvdisk
Sep 17 09:08:58 localhost.localdomain systemd[1]: Set up automount lvdisk automount.
Sep 17 09:08:58 localhost.localdomain systemd[1]: Starting lvdisk automount.
[bit@localhost system]$ systemctl status lvdisk.mount
● lvdisk.mount - my test mount
Loaded: loaded (/etc/systemd/system/lvdisk.mount; disabled; vendor preset: disabled)
Active: inactive (dead)
Where: /lvdisk
What: /dev/sda1
Sep 17 08:43:27 localhost.localdomain systemd[1]: Mounting my test mount...
Sep 17 08:43:27 localhost.localdomain systemd[1]: Mounted my test mount.
Sep 17 08:49:41 localhost.localdomain systemd[1]: Unmounting my test mount...
Sep 17 08:49:42 localhost.localdomain systemd[1]: Unmounted my test mount.
[bit@localhost system]$
======================
[bit@localhost system]$ mount | grep lvdisk
systemd-1 on /lvdisk type autofs (rw,relatime,fd=54,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
[bit@localhost system]$ cd /lvdisk/
[bit@localhost lvdisk]$ systemctl status lvdisk.mount
● lvdisk.mount - my test mount
Loaded: loaded (/etc/systemd/system/lvdisk.mount; disabled; vendor preset: disabled)
Active: active (mounted) since Sun 2017-09-17 09:11:32 EDT; 3s ago
Where: /lvdisk
What: /dev/sda1
Process: 4164 ExecMount=/bin/mount /dev/sda1 /lvdisk -t xfs (code=exited, status=0/SUCCESS)
Sep 17 09:11:32 localhost.localdomain systemd[1]: Mounting my test mount...
Sep 17 09:11:32 localhost.localdomain systemd[1]: Mounted my test mount.
[bit@localhost lvdisk]$
[bit@localhost system]$ mount | grep lvdisk
systemd-1 on /lvdisk type autofs (rw,relatime,fd=54,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
[bit@localhost system]$ cd /lvdisk/
[bit@localhost lvdisk]$ systemctl status lvdisk.mount
● lvdisk.mount - my test mount
Loaded: loaded (/etc/systemd/system/lvdisk.mount; disabled; vendor preset: disabled)
Active: active (mounted) since Sun 2017-09-17 09:11:32 EDT; 3s ago
Where: /lvdisk
What: /dev/sda1
Process: 4164 ExecMount=/bin/mount /dev/sda1 /lvdisk -t xfs (code=exited, status=0/SUCCESS)
Sep 17 09:11:32 localhost.localdomain systemd[1]: Mounting my test mount...
Sep 17 09:11:32 localhost.localdomain systemd[1]: Mounted my test mount.
[bit@localhost lvdisk]$
Comments
Post a Comment