Filesystems
使用 LVM 永久掛載目錄
我成功地將一個目錄掛載到另一個路徑:
[michael@vps ~]$ mkdir /home/michael/devicefilexxx [michael@vps ~]$ mkdir /home/michael/mountpointxxx [michael@vps ~]$ sudo mount --bind /home/michael/devicefilexxx /home/michael/mountpointxxx
我看看它的樣子:
[michael@vps ~]$ cat /etc/mtab | grep xxx /dev/mapper/centos-root /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0
好吧,掛載點看起來是正確的,但不是設備。我將設備指定為
/home/michael/devicefilexxx
,而不是/dev/mapper/centos-root
。所以我看的更深一點:[michael@vps ~]$ mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,size=1009596k,nr_inodes=252399,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) configfs on /sys/kernel/config type configfs (rw,relatime) /dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) mqueue on /dev/mqueue type mqueue (rw,relatime) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime) debugfs on /sys/kernel/debug type debugfs (rw,relatime) /dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota) tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=204060k,mode=700,uid=1000,gid=1000) /dev/mapper/centos-root on /home/michael/mountpointxxx type xfs (rw,relatime,attr2,inode64,noquota)
嗯,兩個設備在同一個掛載點?所以,我看看我的
/etc/fstab
:[michael@vps ~]$ cat /etc/fstab # # /etc/fstab # Created by anaconda on Fri Apr 8 14:15:42 2016 # # 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/centos-root / xfs defaults 1 1 UUID=362355d4-e5da-44de-bf5c-5ce92cf43888 /boot xfs defaults 1 2 /dev/mapper/centos-swap swap swap defaults 0 0
如果我希望在機器重新啟動後保持掛載,當然我不想將以下內容添加到
/etc/stab
:/dev/mapper/centos-root /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0
也許如下,但我猶豫這樣做,因為它與
/etc/mtab
告訴我的不同:/home/michael/devicefilexxx /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0
如何永久掛載目錄/文件?另外,請解釋如何
/dev/mapper/centos-root
有兩個明顯不同的安裝點,因此必須安裝到不同的設備上。編輯。備份資訊:
[michael@vps ~]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 80G 0 disk ├─sda1 8:1 0 500M 0 part /boot └─sda2 8:2 0 79.5G 0 part ├─centos-swap 253:0 0 2G 0 lvm [SWAP] └─centos-root 253:1 0 77.5G 0 lvm / sr0 11:0 1 1024M 0 rom [michael@lsblk ~]$
讓我嘗試一下
/dev/mapper/centos-root
,您在 Linux 中使用的就是所謂的邏輯捲管理。這就像您的文件系統的包裝器,與普通分區相比,它易於調整。您有三個主要的掛載點,從 /etc/fstab 中可以看到 root:
/
,swap
和/boot
所以啟動的東西是在,並在
/boot
交換。文件系統的所有其他部分都在 中找到,並且映射到.RAM``swap``/``dev/mapper/centos-root
我的是:
NAME FSTYPE LABEL UUID MOUNTPOINT sda |-sda1 xfs f86877f2-5099-483f-a56b-24a772cf4863 /boot `-sda2 LVM2_member uw2D4k-IsO3-0u2N-dKLz-utuC-tDn8-zwtaDT |-centos-root xfs e3faa70d-fc88-4951-8122-789e21a519f7 / |-centos-swap swap 95eaf3bb-7b78-418d-b14d-74206d89b3d9 [SWAP] |-centos-var xfs c35276a4-f8e2-4982-91fe-b0cd205601ff /var `-centos-home xfs c09e81c2-32e9-4ebd-a59b-caf57971a069 /home
正如你所看到的,我和你的名字相同,但我也創建了其他分區來映射到我的 CentOS 的不同區域。
我的
/etc/fstab
:/dev/mapper/centos-root / xfs defaults 0 0 UUID=f86877f2-5099-483f-a56b-24a772cf4863 /boot xfs defaults 0 0 /dev/mapper/centos-home /home xfs defaults 0 0 /dev/mapper/centos-var /var xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0
長話短說,您創建的掛載位於
/
根分區中,因此它將映射到/dev/mapper/centos-root
. 這就是它應該成為的樣子。要永久掛載這些文件夾,請將此行添加到您的
/etc/fstab
文件中。當然,要備份原件,以防萬一出錯。/home/michael/devicefilexxx /home/michael/mountpointxxx none bind 0 0
要查看更詳細的掛載點架構,請使用以下命令:
findmnt