zoukankan      html  css  js  c++  java
  • mount的几个选项

    一、mount -o noatime
    表示在读文件时不去更改文件的access time属性了,所以该选项会提升mount操作的执行效率。

    二、mount --bind:等同于 -o bind
    可用于挂载文件到另一文件,或目录到另一目录,便于测试只读文件系统或不想覆盖的文件等。
    假设我们要改的文件是/etc/hosts,可按下面的步骤操作:

    1. 把新的hosts文件放在/tmp下
    2. sudo mount --bind /tmp/hosts /etc/hosts
    

    测试完成了执行 sudo umount /etc/hosts 断开绑定。
    如果我需要在/etc下面增加一个exports文件怎么办?原来没有这个文件,不能直接bind。

    有两个方法:

    方法1:绑定整个/etc目录,绑定前先复制/etc
    # cp -a /etc /tmp #此处使用tar方法拷贝更好
    # mount --bind /tmp/etc /etc
    此时的/etc目录是可写的,所做修改不会应用到原来的/etc目录,可以放心测试。
    
    方法2:挂载ramfs到/etc,同样要先复制/etc
    挂载ramfs
    # mkdir /tmp/etc
    # mount -t ramfs none /tmp/etc
    
    复制/etc,这里我们不能用cp -a,改用tar
    # cd /etc
    # tar cf - . |(cd /tmp/etc; tar xf -)
    # cd /
    
    覆盖/etc
    # mount --move /tmp/etc /etc #ubuntu 16.04上操作不成功
    测试完了记着 umount /etc
    

     
    三、mount --move:等同于 -o move
    例如:mount --move mountpoint newdir
    第一个参数必须是一个挂载点,该选项表示将挂载点转移,先释放原挂载点,然后挂载到新挂载点newdir。
    不过很奇怪的是在ubuntu 16.04上一直未实验成功。提示:

    mount: bad option. Note that moving a mount residing under a shared
           mount is unsupported.
    
           In some cases useful info is found in syslog - try
           dmesg | tail or so.
    

     
    四、通过两个示例了解tar进行拷贝

    # tar cf - . |(cd /tmp/etc; tar xf -) #表示将当前目录下所有文件打包,然后解压到/tmp/etc下
    # tar -C /tmp/cproot -cvf - . | tar -C /mnt -xvf -  #表示将/tmp/cproot目录下所有文件打包,然后解压到/mnt下
    

    拷贝系统文件时经常使用该方法,而不是cp -a

    五、mount经常使用方法如下

    1. mount iso

    sudo mount -o loop a.iso /mnt/iso
    

    2. 挂载fat32到linux下

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

    3. 挂载之后,访问里面乱码的解决

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

    4. 为什么mount上去以后分区普通用户不可写?
    mount时加上 –o umask=000 即可:

    sudo 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-addr>/share /mnt/share
    
  • 相关阅读:
    WPF Attached event
    WPF Progressbar
    IDisposable
    CommandTarget属性
    观察者模式
    DesignerSerializationVisibility, Browsable,Category Attribute
    CVS使用手册
    Javascript原型的简单理解
    由插件独特的处理器产生页面
    教训
  • 原文地址:https://www.cnblogs.com/wzc0066/p/6862195.html
Copyright © 2011-2022 走看看