linux下分区- mount的使用

    xiaoxiao2021-03-25  202

    在Linux中,我们通过mount命令将格式化好的磁盘分区挂载到一个目录上。

    mount  /dev/sda3(要挂载的分区)   /mnt(挂载点)

    常用参数:

    不带参数的mount命令会显示所有已挂载的文件系统。$ mount

             -t  指定文件系统的类型

             -o 指定挂载选项

                       ro,rw        以只读或读写形式挂载,默认是rw

                       sync          代表不使用缓存,而是对所有操作直接写入磁盘(防止断电等异常情况引起数据丢失)

                       async        代表使用缓存,默认是async

                       noatime   代表每次访问文件时不更新文件的访问时间(accesstime)

                       atime        代表每次访问文件时更新文件的访问时间

                       remount  重新挂载文件系统

    umount:命令umount用来卸载已挂载的文件系统,相当于windows中u盘弹出

                      umount  文件分区/挂载点

                      umount/dev/sda3  ==    umount /mnt

    如果出现device is busy报错,则表示该文件系统正在被使用,无法卸载,可以使用以下命令查看使用文件系统的进程

                      $ fuser–m /mnt

    也可以使用命令lsof查看正在被使用的文件:list open file

                      $ lsof /mnt

    Example:

    $ umount /dev/sdb1

    $ mount /dev/sdb1 /mnt

    $ cd /mnt

    $ umount /dev/sdb1  卸载不掉,推出/mnt目录即可

     

    自动挂载:配置文件/etc/fstab用来定义需要自动挂载的文件系统,fstab中每一行代表一个挂载配置,格式如下:

    /dev/sdb3                  /mnt                   ext4                    defaults             0 0    (之间用Tab隔开进行对齐)

    需要挂载的设备     挂载点              文件系统         挂载选项         dump,fsck相关选项

     

    要挂载的设备也可以使用LABEL进行识别,使用LABEL=LINUXCAST取代/dev/sdb3

    $ mount –a命令会挂载所有fstab中定义的自动挂载项。

     

    Linux下用e2label命令来设定分区的label,其用法很简单:(查看或修改我们的卷标)

     

    e2label 分区 [新label]

     

    如果后面指定新label则为分区设定新label;如果后面不指定label,则显示分区的当前label。

     

    $ man e2label

    Name: e2label – change the label on anext2/ext3/ext4 file system

    $ e2label device [new label]

    E2label will display or change the file systemlabel on the ext2,ext3,or ext4 file system located on device.

    If the optional argument new-label is notpresent, e2label will simply display the current file system label. If  the  optional  argument  new-label  is present,then e2label will set the file system label to be new-label.

    $ mount -L LabelCast/mnt/test  (labelLabelCast的分区挂载到/mnt/test) 

    fstab中根据label来挂载: $ LABEL= LabelCast  /mnt/test ext3 defaults 1 1 

    转载请注明原文地址: https://ju.6miu.com/read-10398.html

    最新回复(0)