• Linux磁盘管理相关操作


    磁盘数据查询

    • df:查看文件系统的磁盘使用量
        df -h
        -a, --all             include dummy file systems
        -B, --block-size=SIZE  scale sizes by SIZE before printing them; e.g.,
                               '-BM' prints sizes in units of 1,048,576 bytes;
                               see SIZE format below
          --direct          show statistics for a file instead of mount point
          --total           produce a grand total
        -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)
        -H, --si              likewise, but use powers of 1000 not 1024
        -i, --inodes          list inode information instead of block usage
        -k                    like --block-size=1K
        -l, --local           limit listing to local file systems
          --no-sync         do not invoke sync before getting usage info (default)
          --output[=FIELD_LIST]  use the output format defined by FIELD_LIST,
                                   or print all fields if FIELD_LIST is omitted.
        -P, --portability     use the POSIX output format
          --sync            invoke sync before getting usage info
        -t, --type=TYPE       limit listing to file systems of type TYPE
        -T, --print-type      print file system type
        -x, --exclude-type=TYPE   limit listing to file systems not of type TYPE

     

    磁盘使用情况
    磁盘使用情况

     

    • fdisk:查看系统分区
        fdisk -l
        Usage:
             fdisk [options] <disk>    change partition table
             fdisk [options] -l <disk> list partition table(s)
             fdisk -s <partition>      give partition size(s) in blocks
        Options:
             -b <size>             sector size (512, 1024, 2048 or 4096)
             -c[=<mode>]           compatible mode: 'dos' or 'nondos' (default)
             -h                    print this help text
             -u[=<unit>]           display units: 'cylinders' or 'sectors' (default)
             -v                    print program version
             -C <number>           specify the number of cylinders
             -H <number>           specify the number of heads
             -S <number>           specify the number of sectors per track

     

    系统分区情况
    系统分区情况

     

    磁盘操作

    新增拓展分区

    1. 新增拓展磁盘
      VM新增拓展磁盘 图1
      VM新增拓展磁盘 图2

    2. 查看磁盘分区状态

        fdisk -l

     

    磁盘分区状态
    磁盘分区状态

     

    说明:
    第一块磁盘叫sda
    有两个分区 sda1和sda2
    s:接口,例如ssd,scsi,sata d代表disk磁盘 a:第一块 123:第几个分区

    1. 系统内新增一个分区sda3
        fdisk /dev/sda

     

    新增的分区情况
    新增的分区情况

     

     

    重启后的分区情况
    重启后的分区情况

     

    新增磁盘

    • 虚拟机新增硬盘:
      添加硬盘 图1
      添加硬盘 图2
      添加硬盘 图3
      添加硬盘 图4

    • 系统内添加磁盘

        fdisk -l
        fdisk /dev/sdb

     

    磁盘查看多出了一个磁盘:sdb
    磁盘查看多出了一个磁盘:sdb

    1. 进入命令行交互界面,通过m查看帮助信息
    2. 新增分区(n)
    3. 新增为主分区(p)
    4. 默认为第一个主分区(1)
    5. 分区偏移量设置(默认)
    6. 保存退出(w)
    7.重启系统
    8.格式化分区
    shell mkfs.ext4 /dev/sdb1
    磁盘新增
    磁盘新增完成

     

    • 磁盘分区挂载
      1. 创建要挂载的文件目录
          mkdir -p /opt/sdb1
      1. 将分区/dev/sdb1挂载到/opt/sdb1
          mount /dev/sdb1  /opt/sdb1
      1. 查看挂载情况
        磁盘挂载情况

      2. 卸载

          umount /opt
      卸载
    初心回归,时光已逝!
  • 相关阅读:
    今天一天看一天文档
    ImportError: No module named _md5解决方案
    Spelling Corrector & sphinx typo search
    linux下使用ipython的pylab模式时不显示图形的问题解决方案
    error: error in setup script: command 'build_exe' has no such option 'includefiles'
    【转】oracle之包的创建和应用
    ADO.NET 与 ORACLE
    SQL注入大全
    【转】oracle之循环语法
    ASP.NET 防止按钮多次提交解决方法
  • 原文地址:https://www.cnblogs.com/yin1361866686/p/11685282.html
Copyright © 2020-2023  润新知