1、执行以下命令,查看新增数据盘。一般是/dev/vdb
执行命令查看磁盘信息:fdisk -l
[root@ecs-test-0001 ~]# fdisk -l Disk /dev/vda: 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: 0x000bcb4e Device Boot Start End Blocks Id System /dev/vda1 * 2048 83886079 41942016 83 Linux Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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
表示当前的云服务器有两块磁盘,“/dev/vda”是系统盘,“/dev/vdb”是新增数据盘。
2、执行以下命令,进入fdisk分区工具,开始对新增数据盘执行分区操作。
fdisk /dev/vdb
回显类似如下信息:[root@ecs-test-0001 ~]# fdisk /dev/vdb 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 0x38717fc1. Command (m for help):
3、输入“n”,按“Enter”,开始新建分区。
回显类似如下信息:Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended
4、以创建一个主要分区为例,输入“p”,按“Enter”,开始创建一个主分区。
Select (default p): p Partition number (1-4, default 1):
5、以分区编号选择“1”为例,输入主分区编号“1”,按“Enter”。
Partition number (1-4, default 1): 1 First sector (2048-209715199, default 2048):
6、以选择默认起始磁柱值2048为例,按“Enter”。
First sector (2048-209715199, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
7、以选择默认按“Enter”。
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): Using default value 209715199 Partition 1 of type Linux and of size 100 GiB is set Command (m for help):
8、输入“p”,按“Enter”,查看新建分区的详细信息。
Command (m for help): p Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x38717fc1 Device Boot Start End Blocks Id System /dev/vdb1 2048 209715199 104856576 83 Linux Command (m for help):
9、输入“w”,按“Enter”,将分区结果写入分区表中。
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.10、执行以下命令,将新的分区表变更同步至操作系统。
partprobe
11、格式化磁盘
[root@ecs-test-0001 ~]# mkfs -t ext4 /dev/vdb1 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 6553600 inodes, 26214144 blocks 1310707 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2174746624 800 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, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done10、执行完后,就可以愉快的挂载了。执行以下命令,新建挂载目录。
mkdir 挂载目录
以新建挂载目录“/mnt/sdc”为例:
mkdir /mnt/sdc
mount 磁盘分区 挂载目录
以挂载新建分区“/dev/vdb1”至“/mnt/sdc”为例:
mount /dev/vdb1 /mnt/sdc
[root@ecs-test-0001 ~]# df -TH Filesystem Type Size Used Avail Use% Mounted on /dev/vda1 ext4 43G 1.9G 39G 5% / devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs tmpfs 2.0G 9.1M 2.0G 1% /run tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup tmpfs tmpfs 398M 0 398M 0% /run/user/0 /dev/vdb1 ext4 106G 63M 101G 1% /mnt/sdc11、以上就完成了