操作分区
sudo fdisk /dev/vdb
结果:
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd0711abb
Device Boot Start End Blocks Id System
/dev/vdb1 1 41610 20971408+ 83 Linux
/dev/vdb2 41611 110960 34952400 83 Linux
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (110961-208050, default 110961):
Using default value 110961
Last cylinder, +cylinders or +size{K,M,G} (110961-208050, default 208050):
Using default value 208050
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 16: 设备或资源忙.
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.
告诉内核刷新分区
sudo partx -v -a /dev/vdb
结果:
device /dev/vdb: start 0 size 209715200
gpt: 0 slices
dos: 4 slices
# 1: 63- 41942879 ( 41942817 sectors, 21474 MB)
# 2: 41942880-111847679 ( 69904800 sectors, 35791 MB)
# 3: 111847680-209714399 ( 97866720 sectors, 50107 MB)
# 4: 0- -1 ( 0 sectors, 0 MB)
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
added partition 3
查询分区
fdisk -l
结果:
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00020f78
Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41940992 83 Linux
Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd0711abb
Device Boot Start End Blocks Id System
/dev/vdb1 1 41610 20971408+ 83 Linux
/dev/vdb2 41611 110960 34952400 83 Linux
/dev/vdb3 110961 208050 48933360 83 Linux
格式化分区
sudo mkfs.ext4 /dev/vdb3
结果:
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3063808 inodes, 12233340 blocks
611667 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
374 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
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
新建目录
sudo make /data
挂载分区
sudo mount -t ext4 /dev/vdb3 /data
服务器启动自动挂载
vim /etc/fstab
/dev/vdb3 /data ext4 defaults 0 0