[root@ecshost~ ]# fdisk -u /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 0x3e60020e. Command (m for help): p Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x3e60020e Device Boot Start End Blocks Id System Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set Command (m for help): p Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x3e60020e Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
如果出现/dev/vdb1的相关信息,表示新分区已创建完成。
[root@ecshost~ ]# fdisk -lu /dev/vdb Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x3e60020e Device Boot Start End Blocks Id System /dev/vdb1 2048 41943039 20970496 83 Linux
5.在新分区上创建一个文件系统。
根据您的需求运行以下任一命令,创建一个ext4文件系统。
[root@ecshost~ ]# mkfs -t ext4 /dev/vdb1
mke2fs 1.43.5 (04-Aug-2017)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: 884e1a06-1481-43d6-b1a3-8bccaa03****
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
6》向/etc/fstab写入新分区信息,启动开机自动挂载分区。
echo "/dev/vdb1 /var/www ext4 defaults 0 1” >> /etc/fstab
第一字段:分区设备文件名或UUID(硬盘通用唯一识别码 可通过dumpe2fs 分区设备文件名 查看)
第二字段:挂载点
第三字段:文件系统名称
第四字段:挂载参数
第五字段:指定分区是否被dump备份,0代表不备份,1代表每天备份,2代表不定期备份
第六字段:指定分区是否被fsck检测,0代表不检测,其它数字代表检测的优先级,1的优先级比2高
7>运行cat /etc/fstab
命令查看/etc/fstab中的新分区信息。
8> 运行mount /dev/vdb1 /var/www
命令挂载文件系统。然后用df -h查看。
9》重启服务器查看自动加载情况