linux mount一個目錄到另外一個目錄


 

從linux內核2.4.0以后mount支持mount --bind 一個目錄到另外一個目錄

比如:

[root@localhost wind]# mkdir test1 test2 dir3

mount --bind test1 test2

把test1掛載到test2,如果test2目錄有內容將被遮住(dir2目錄的內容一樣存在。就好像窗簾把窗戶遮住一樣。窗戶始終存在,只是被遮住而已,等umount了,原來dir2目錄的內容就顯示出來了)

要取消掛載使用umount即可

並不是使用mount --move dir1 dir2  

mount --move是把dir1移到dir2,如果使用mount --move dir1 dir2將報錯

mount: wrong fs type, bad option, bad superblock on dir1,

       missing codepage or other error

       In some cases useful info is found in syslog - try

       dmesg | tail  or so

使用mount --move dir1 dir3就把dir1掛載到dir3(先umount dir1+再mount dir1到dir3),同時dir2的內容顯示出來,dir3的原來內容被dir1的遮住

如果在開機的時候自動掛載,可以在/etc/fstab里面增加以下內容

dir1   dir2    none    bind   0   0

mount經常使用方法如下:

1.mount iso

mount -o loop a.iso /mnt/iso

2.掛載fat32到linux下

mount -t vat /dev/sda1 /mnt/xp

3.掛載之后,訪問里面亂碼的解決

mount –o iocharset=gb2312 codepage=936 /dev/hda5 /mnt/hda5

4.為什么mount上去以后分區普通用戶不可寫?

mount時加上 –o umask=000 即可:

# mount –o umask=000, iocharset=cp936 /dev/hda5 /mnt/hda5
5.如何掛載samba 分區?

# mkdir /mnt/share

# mount -t smbfs -o username=root,password=abc,codepage=936,iocharset=gb2312 //IP/share /mnt/share

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM