欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

Linux mount挂载和卸载硬盘脚本分享

程序员文章站 2022-11-13 20:05:09
linux 挂载 [root@whp6 ~]# mount /dev/sdb5 /mnt/ [root@whp6 ~]# df -h filesystem s...

linux 挂载

[root@whp6 ~]# mount /dev/sdb5 /mnt/
[root@whp6 ~]# df -h
filesystem size used avail use% mounted on
/dev/sda3 16g 2.1g 13g 14% /
tmpfs 931m 0 931m 0% /dev/shm
/dev/sda1 194m 28m 157m 16% /boot
/dev/sdb5 2.0g 68m 1.9g 4% /mnt
[root@whp6 ~]# df -t
filesystem type 1k-blocks used available use% mounted on
/dev/sda3 ext4 16311208 2134352 13348288 14% /
tmpfs tmpfs 953276 0 953276 0% /dev/shm
/dev/sda1 ext4 198337 28320 159777 16% /boot
/dev/sdb5 ext4 2071384 68632 1897528 4% /mnt
[root@whp6 ~]#

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

[root@whp6 ~]# ls /home/
1.txt 2 22 wanghaipeng whp
[root@whp6 ~]# mount /dev/sdb1 /home/
[root@whp6 ~]# ls /home
lost+found
[root@whp6 ~]# umount /home
[root@whp6 ~]# ls /home
1.txt 2 22 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 2.1g 13g 14% /
tmpfs 931m 0 931m 0% /dev/shm
/dev/sda1 194m 28m 157m 16% /boot
/dev/sdb5 2.0g 68m 1.9g 4% /mnt
/dev/sdb1 2.0g 74m 1.9g 4% /home/whp
[root@whp6 /]# umount -l /home/whp/
[root@whp6 /]# df -h
filesystem size used avail use% mounted on
/dev/sda3 16g 2.1g 13g 14% /
tmpfs 931m 0 931m 0% /dev/shm
/dev/sda1 194m 28m 157m 16% /boot
/dev/sdb5 2.0g 68m 1.9g 4% /mnt
[root@whp6 /]#

以上所述是小编给大家介绍的linux mount挂载和卸载硬盘,希望对大家有所帮助