首页 > 系统服务 > 详细

Linux磁盘管理相关操作.md

时间:2019-10-16 14:27:35      阅读:68      评论:0      收藏:0      [点我收藏+]

磁盘数据查询

  • 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. 新增拓展磁盘
    技术分享图片
    技术分享图片

  2. 查看磁盘分区状态

    fdisk -l

 

技术分享图片
磁盘分区状态

 

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

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

 

技术分享图片
新增的分区情况

 

 

技术分享图片
重启后的分区情况

 

新增磁盘

  • 虚拟机新增硬盘:
    技术分享图片
    技术分享图片
    技术分享图片
    技术分享图片

  • 系统内添加磁盘

    fdisk -l
    fdisk /dev/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
    技术分享图片

Linux磁盘管理相关操作.md

原文:https://www.cnblogs.com/yin1361866686/p/11685282.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!