1. 使用df 命令查看文件系统及相关挂载点信息
[[email protected] ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vol0-root 51224128 3019100 48205028 6% / devtmpfs 492436 0 492436 0% /dev tmpfs 501716 0 501716 0% /dev/shm tmpfs 501716 7156 494560 2% /run tmpfs 501716 0 501716 0% /sys/fs/cgroup /dev/sda1 508588 104312 404276 21% /boot /dev/mapper/vol0-home 520876 26432 494444 6% /home =》该目录下存在挂载
2. 使用df命令,以m为单位显示每个分区的使用情况,使用参数 -h
[[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vol0-root 49G 2.9G 46G 6% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 0 490M 0% /dev/shm tmpfs 490M 7.0M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sda1 497M 102M 395M 21% /boot /dev/mapper/vol0-home 509M 26M 483M 6% /home
3. 显示/home目录下文件系统的使用情况
[[email protected] ~]# du -h /home/ 0 /home/student/.mozilla/extensions 0 /home/student/.mozilla/plugins 0 /home/student/.mozilla 12K /home/student 12K /home/
4. 卸载/home目录下所挂载的分区,并确认/home目录下无其他挂载信息
[[email protected] ~]# umount /home [[email protected] ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vol0-root 51224128 3019072 48205056 6% / devtmpfs 492436 0 492436 0% /dev tmpfs 501716 0 501716 0% /dev/shm tmpfs 501716 7156 494560 2% /run tmpfs 501716 0 501716 0% /sys/fs/cgroup /dev/sda1 508588 104312 404276 21% /boot
5. 使用命令“blkid”来确认/dev/mapper/vol0-home 这个分区(逻辑卷)的 UUID 为 UUID="b2b0fb94-f1db-4a93-b8a2-6f0154d62d4c"
[[email protected] ~]# blkid /dev/sda1: UUID="30d646b2-467f-4b88-9926-17fb27048de8" TYPE="xfs" /dev/sda2: UUID="GKLqXe-Fuk1-RDwV-3prF-JwSS-XDCr-WV2HYQ" TYPE="LVM2_member" /dev/sr0: UUID="2015-10-30-11-11-49-00" LABEL="RHEL-7.2 Server.x86_64" TYPE="iso9660" PTTYPE="dos" /dev/mapper/vol0-swap: UUID="85631ad3-b3e1-4ff9-98ef-ff0b0f964c4a" TYPE="swap" /dev/mapper/vol0-root: UUID="0f81a0f6-a0db-4033-9cff-bbef6eed28bd" TYPE="xfs" /dev/mapper/vol0-home: UUID="b2b0fb94-f1db-4a93-b8a2-6f0154d62d4c" TYPE="xfs" [[email protected] ~]#
6. 使用uuid作为挂载源,将/dev/mapper/vol0-home 挂载到/home 目录 ,并确认是否已挂载
[[email protected] ~]# mount UUID="b2b0fb94-f1db-4a93-b8a2-6f0154d62d4c" /home [[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vol0-root 49G 2.9G 46G 6% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 0 490M 0% /dev/shm tmpfs 490M 7.0M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sda1 497M 102M 395M 21% /boot /dev/mapper/vol0-home 509M 26M 483M 6% /home
7. 使用普通用户远程连接目标系统,查看是否有挂载点信息
[student@server101 ~]$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/vol0-root 51224128 3019300 48204828 6% / devtmpfs 492436 0 492436 0% /dev tmpfs 501716 0 501716 0% /dev/shm tmpfs 501716 7192 494524 2% /run tmpfs 501716 0 501716 0% /sys/fs/cgroup /dev/sda1 508588 104312 404276 21% /boot /dev/mapper/vol0-home 520876 26460 494416 6% /home
8 此时使用root用户对/home进行卸载提示不成功,因为有其他用户在使用中
[root@server101 ~]# umount /home umount: /home: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
9. 使用 lsof 命令检查哪个进程、哪个用户正在使用/home 目录 ,确认到是student用户正在使用中
[[email protected] ~]# lsof /home COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME bash 2176 student cwd DIR 253,2 4096 131 /home/student
10. 使用 fuser 命令,关闭对/home/student 目录使用的相关进程
[[email protected] ~]# fuser -k /home/student /home/student: 2176c [[email protected] ~]$ Connection to 192.168.0.101 closed.
11. 再次卸载系统的/home目录,并使用df命令进行查看
[[email protected] ~]# umount /home [[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vol0-root 49G 2.9G 46G 6% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 0 490M 0% /dev/shm tmpfs 490M 7.0M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/sda1 497M 102M 395M 21% /boot
12. 系统重启
[[email protected] ~]# reboot
13 待重启后,再次登录 系统(使用 root),确认/home 目录又被挂载了原来那个分区, 说明 mount 和 umount 命令的挂载状态是临时的
[[email protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vol0-root 49G 2.9G 46G 6% / devtmpfs 481M 0 481M 0% /dev tmpfs 490M 0 490M 0% /dev/shm tmpfs 490M 7.0M 483M 2% /run tmpfs 490M 0 490M 0% /sys/fs/cgroup /dev/mapper/vol0-home 509M 26M 483M 6% /home /dev/sda1 497M 102M 395M 21% /boot
时间: 2024-11-05 18:30:07