扩展系统盘的分区和文件系统(Linux) fdisk /dev/vda Welcome to fdisk (utillinux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): 步骤 3 输入“n”,按“Enter”,开始新建分区。 回显类似如下信息: Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended 表示磁盘有两种分区类型: “p”表示主分区。 “e”表示扩展分区。 说明 磁盘使用MBR分区形式,最多可以创建4个主分区,或者3个主分区加1个扩展分区,扩展分区不可以直接使用,需要划分成若干个逻辑分区才可以使用。 磁盘使用GPT分区形式时,没有主分区、扩展分区以及逻辑分区之分。 步骤 4 以创建一个主要分区为例,输入“p”,按“Enter”,开始创建一个主分区。 回显类似如下信息: Select (default p): p Partition number (24, default 2): 步骤 5 以分区编号选择“2”为例,输入分区编号“2”,按“Enter”。 回显类似如下信息: Partition number (24, default 2): 2 First sector (83886080167772159, default 83886080): 步骤 6 输入新分区的起始磁柱值,以使用默认起始磁柱值为例,按“Enter”。 系统会自动提示分区可用空间的起始磁柱值和截止磁柱值,可以在该区间内自定义,或者使用默认值。起始磁柱值必须小于分区的截止磁柱值。 回显类似如下信息: First sector (83886080167772159, default 83886080): Using default value 83886080 Last sector, +sectors or +size{K,M,G} (83886080167772159,default 167772159): 步骤 7 输入新分区的截止磁柱值,以使用默认截止磁柱值为例,按“Enter”。 系统会自动提示分区可用空间的起始磁柱值和截止磁柱值,可以在该区间内自定义,或者使用默认值。起始磁柱值必须小于分区的截止磁柱值。 回显类似如下信息: Last sector, +sectors or +size{K,M,G} (83886080167772159, default 167772159): Using default value 167772159 Partition 2 of type Linux and of size 40 GiB is set Command (m for help): 步骤 8 输入“p”,按“Enter”,查看新建分区。 回显类似如下信息: Command (m for help): p Disk /dev/vda: 85.9 GB, 85899345920 bytes, 167772160 sectors Units sectors of 1 512 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x0008d18f Device Boot Start End Blocks Id System /dev/vda1 2048 83886079 41942016 83 Linux /dev/vda2 83886080 167772159 41943040 83 Linux Command (m for help): 步骤 9 输入“w”,按“Enter”,将分区结果写入分区表中。 回显类似如下信息: > Command (m for help): w > The partition table has been altered! > > Calling ioctl() to reread partition table. > > WARNING: Rereading the partition table failed with error 16: Device or resource busy. > The kernel still uses the old table. The new table will be used at > the next reboot or after you run partprobe(8) or kpartx(8) > Syncing disks. 表示分区创建完成。 说明 如果之前分区操作有误,请输入“q”,则会退出fdisk分区工具,之前的分区结果将不会被保留。 步骤 10 执行以下命令,将新的分区表变更同步至操作系统。 partprobe 步骤 11 执行以下命令,设置新建分区文件系统格式。 mkfs t 文件系统 磁盘分区 ext文件系统命令示例: 以“ext4” 文件格式为例: mkfs t ext4 /dev/vda2 回显类似如下信息: [root@ecs2220 ~]