linux mount 硬盘挂载和卸载

时间:2021-02-28 20:09:10

Linux 挂载

[root@whp6 ~]# mount /dev/sdb5 /mnt/
[root@whp6 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G .1G 13G % /
tmpfs 931M 931M % /dev/shm
/dev/sda1 194M 28M 157M % /boot
/dev/sdb5 .0G 68M .9G % /mnt
[root@whp6 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda3 ext4 % /
tmpfs tmpfs % /dev/shm
/dev/sda1 ext4 % /boot
/dev/sdb5 ext4 % /mnt
[root@whp6 ~]#

备注:如果挂载到有文件的目录下 会遮挡原先文件 必须卸载挂载的硬盘 才能显示

[root@whp6 ~]# ls /home/
.txt wanghaipeng whp
[root@whp6 ~]# mount /dev/sdb1 /home/
[root@whp6 ~]# ls /home
lost+found
[root@whp6 ~]# umount /home
[root@whp6 ~]# ls /home
.txt wanghaipeng whp
[root@whp6 ~]#

Linux umount  卸载

[root@whp6 /]# mount LABEL=wanghaipeng /home/whp/
[root@whp6 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G .1G 13G % /
tmpfs 931M 931M % /dev/shm
/dev/sda1 194M 28M 157M % /boot
/dev/sdb5 .0G 68M .9G % /mnt
/dev/sdb1 .0G 74M .9G % /home/whp
[root@whp6 /]# umount -l /home/whp/
[root@whp6 /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 16G .1G 13G % /
tmpfs 931M 931M % /dev/shm
/dev/sda1 194M 28M 157M % /boot
/dev/sdb5 .0G 68M .9G % /mnt
[root@whp6 /]#