美文网首页
Linux磁盘分区-centos7

Linux磁盘分区-centos7

作者: 传奇FA | 来源:发表于2019-04-25 21:12 被阅读0次

    1. 磁盘查看的一些命令:

    lsblk
    lsblk  -o name,uuid,fstype,mountpoint
    df -hT
    fdisk -l
    

    2. 分区挂载步骤:

    2.1. 分区(后面具体讲)

    fdisk /dev/vdb
    

    2.2. 对分区进行格式化

    xfs格式化:

    mkfs.xfs -f -n ftype=1 /dev/vdb3
    

    ext4格式化:

    mkfs.ext4 /dev/vdb1
    

    2.3. 挂载

    mount /dev/vdb1 /mnt/disk1
    
    mount /dev/vdb3 /var/lib/docker
    

    2.4. 编辑/etc/fstab,加入下面内容

    vi /etc/fstab
    
    /dev/vdb1 /mnt/disk1 ext4 defaults 0 0
    
    /dev/vdb3 /var/lib/docker xfs defaults,uquota,pquota 0 0
    

    在/etc/fstab中第一列的“/dev/vdb3”等同于"UUID=<uuid>"

    2.5. 重新挂载 /etc/fstab 里面的内容

    mount -a
    

    \color{red}{编辑/etc/fstab后先用mount -a 看看有没有报错,目标磁盘有没有挂载,正常后才可重启系统}

    3. 对vdb磁盘进行分区

    [root@test4 ~]# fdisk /dev/vdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel. Changes will remain in memory only,
    until you decide to write them. After that, of course, the previous
    content won't be recoverable.
    The number of cylinders for this disk is set to 2597.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1 ) software that runs at boot time (e.g., old versions of LILO)
    2 ) booting and partitioning software from other OSs
    (e.g., DOS FDISK, OS/2 FDISK)
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

    Command (m for help): m  //输出帮助信息
      Command action
      a toggle a bootable flag  //设置启动分区
      b edit bsd disklabel  //编辑分区标签
      c toggle the dos compatibility flag
      d delete a partition  //删除一个分区
      l list known partition types  //列出分区类型
      m print this menu  //输出帮助信息
      n add a new partition  //建立一个新的分区
      o create a new empty DOS partition table  //创建一个新的空白DOS分区表
      p print the partition table  //打印分区表
      q quit without saving changes  //退出不保存设置
      s create a new empty Sun disklabel
      t change a partition's system id  //改变分区的ID
      u change display/entry units  //改变显示的单位
      v verify the partition table  //检查验证分区表
      w write table to disk and exit  //保存分区表
      x extra functionality (experts only)
    Command (m for help):n
    Command action
      e extended  //e是扩展分区
      p primary partition (1-4)  //p是主分区
    p
    Partition number (1-4): 1  //定义分区号 --主分区最多只能有四个
    First cylinder (1-2597, default 1): 1  //分区开始柱面
    Last cylinder or +size or +sizeM or +sizeK (1-2597, default 2597): +100G  //分区结束柱面,或者分区大小

    Command (m for help): w  //保存刚才的配置信息。
    The partition table has been altered!

    Calling ioctl() to re-read partition table.

    WARNING: Re-reading the partition table failed with error 22: 无效的参数.
    The kernel still uses the old table.
    The new table will be used at the next reboot.
    Syncing disks.

    相关文章

      网友评论

          本文标题:Linux磁盘分区-centos7

          本文链接:https://www.haomeiwen.com/subject/fletnqtx.html