• 一天一个 Linux 命令(32):umount命令


    一天一个 Linux 命令(32):umount命令

    Linux下的umount命令用于卸除文件系统。umount可卸除目前挂在Linux目录中的文件系统。mount是挂载,整好相反。

    二、格式说明

    umount [-hV]
    umount -a [options]
    umount [options] <source> | <directory>
    umount [参数] [文件系统]
    
    
    Usage:
     umount [-hV]
     umount -a [options]
     umount [options] <source> | <directory>
    
    Options:
     -a, --all               unmount all filesystems
     -A, --all-targets       unmount all mountpoins for the given device
                             in the current namespace
     -c, --no-canonicalize   don't canonicalize paths
     -d, --detach-loop       if mounted loop device, also free this loop device
         --fake              dry run; skip the umount(2) syscall
     -f, --force             force unmount (in case of an unreachable NFS system)
     -i, --internal-only     don't call the umount.<type> helpers
     -n, --no-mtab           don't write to /etc/mtab
     -l, --lazy              detach the filesystem now, and cleanup all later
     -O, --test-opts <list>  limit the set of filesystems (use with -a)
     -R, --recursive         recursively unmount a target with all its children
     -r, --read-only         In case unmounting fails, try to remount read-only
     -t, --types <list>      limit the set of filesystem types
     -v, --verbose           say what is being done
    
     -h, --help     display this help and exit
     -V, --version  output version information and exit
    

    三、选项说明

    -a	卸载/etc/mtab中记录的所有文件系统
    -f  强制卸载(比如在无法访问NFS系统的情况下)
    -h	显示帮助
    -n	卸载时不要将信息存入/etc/mtab文件中
    -l  分离文件系统,稍后进行清除
    -r	若无法成功卸载,则尝试以只读的方式重新挂入文件系统
    -t	文件系统类型:仅卸载选项中所指定的文件系统
    -v	执行时显示详细的信息
    -V	显示版本信息
    

    四、命令功能

    卸除目前挂在Linux目录中的文件系统。

    五、常见用法

    5.1 分别通过设备名和挂载点卸载文件系统,同时输出详细信息

    #通过设备名卸载  
    # umount -v /dev/vda1
    /dev/vda1 umounted  
    
    #通过挂载点卸载
    # umount -v /data     
    /data umounted
    
    #如果设备正忙,卸载即告失败。卸载失败的常见原因是,某个打开的shell当前目录为挂载点里的某个目录
    #umount -v /data 
    #umount: /data: device is busy  
    
    #当有别的程序正在访问挂载的文件时,也会提示卸载失败,通过 lsof  /data  查看是哪个进程占用了/data,使用kill -9 $pid,然后再卸载
    

    5.2 卸载前检查占用该挂载文件的程序并迅速kill掉

    #umount -l /data
    
    

    说明:-l : 卸载前检查占用该挂载文件的程序并迅速kill掉,以达到快速卸载的目的

    5.3 强制卸载

    umount -lf /data
    

     

  • 相关阅读:
    <<卸甲笔记>>-基础语法对比
    <<卸甲笔记>>-Oracle线下迁移到PPAS
    How to use PEM of PPAS
    PPAS Migration Toolkit document
    PostgreSQL中数据库,表,等对象的oid与对象名的对应关系
    使用pgstatspack分析PostgreSQL数据库性能
    Postgres Plus Advanced Server installation
    Ways to access Oracle Database in PostgreSQL
    Some settings of PostgreSQL
    nginx内置变量
  • 原文地址:https://www.cnblogs.com/joshua317/p/15439551.html
Copyright © 2020-2023  润新知