[root@ecs-b656 test]# fdisk -l Disk /dev/xvda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000cc4ad Device Boot Start End Blocks Id System /dev/xvda1 * 2048 2050047 1024000 83 Linux /dev/xvda2 2050048 22530047 10240000 83 Linux /dev/xvda3 22530048 24578047 1024000 83 Linux /dev/xvda4 24578048 83886079 29654016 5 Extended /dev/xvda5 24580096 26628095 1024000 82 Linux swap / Solaris Disk /dev/xvdb: 10.7 GB, 10737418240 bytes, 20971520 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
执行以下命令,进入fdisk模式,开始对新增数据盘执行分区操作。
以新挂载的数据盘“/dev/xvdb”为例:
1
fdisk /dev/xvdb
回显类似如下信息:
1 2 3 4 5 6 7 8 9
[root@ecs-b656 test]# fdisk /dev/xvdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xb00005bd. Command (m for help): 输入“n”,按“Enter”。 输入“n”表示新增一个分区。
回显类似如下信息,表示磁盘有两种分区类型:
1 2 3 4 5 6 7
“p”表示主要分区。 “e”表示延伸分区。 Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended 输入“p”,按“Enter”。
以创建一个主要分区为例。
回显类似如下信息,“Partition number”表示主分区编号,可以选择1-4。
1 2 3 4
Select (default p): p Partition number (1-4, default 1): 输入主分区编号“1”,按“Enter”。 以分区编号选择“1”为例。
First sector (2048-20971519, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): 按“Enter”。 以选择默认截止磁柱编号20971519为例。
回显类似如下信息,表示分区完成,即为10GB的数据盘新建了1个分区。
1 2 3 4 5
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): Using default value 20971519 Partition 1 of type Linux and of size 10 GiB is set Command (m for help): 输入“p”,按“Enter”,查看新建分区的详细信息。
回显类似如下信息,表示新建分区“/dev/xvdb1”的详细信息。
1 2 3 4 5 6 7 8 9 10 11
Command (m for help): p Disk /dev/xvdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0xb00005bd Device Boot Start End Blocks Id System /dev/xvdb1 2048 20971519 10484736 83 Linux Command (m for help): 输入“w”,按“Enter”,将分区结果写入分区表中。
回显类似如下信息,表示分区创建完成。
1 2 3 4
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
[root@ecs-b656 test]# mkfs -t ext4 /dev/xvdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655360 inodes, 2621184 blocks 131059 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2151677952 80 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done