linux mount一个目录到另一个目录

 

从linux内核2.4.0之后mount支持mount --bind 一个目录到另一个目录linux

好比:oop

[root@localhost wind]# mkdir test1 test2 dir3spa

mount --bind test1 test2code

把test1挂载到test2,若是test2目录有内容将被遮住(dir2目录的内容同样存在。就好像窗帘把窗户遮住同样。窗户始终存在,只是被遮住而已,等umount了,原来dir2目录的内容就显示出来了)it

要取消挂载使用umount便可io

并非使用mount --move dir1 dir2  class

mount --move是把dir1移到dir2,若是使用mount --move dir1 dir2将报错test

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

       missing codepage or other errorioc

       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

相关文章
相关标签/搜索