我需要在现有磁盘(/dev/vda,20G)上创建另一个分区(/dev/vda2)。
umount /mnt/
resize2fs /dev/vda1 10G
df -h
...
/dev/vda1 9.8G 7.8G 1.5G 85% /mnt
所以这边没问题,但是fdisk不行:
fdisk -l /dev/vda
Disk /dev/vda: 20 GiB, 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
Disklabel type: gpt
Disk identifier: XXX
Device Start End Sectors Size Type
/dev/vda1 4096 41943006 41938911 20G Linux filesystem
/dev/vda15 2048 4095 2048 1M BIOS boot
/dev/vda1 仍被视为 20G。
但是, tune2fs 是正确的:
tune2fs -l /dev/vda1
tune2fs 1.43.4 (31-Jan-2017)
Filesystem volume name: DOROOT
Last mounted on: /mnt
Filesystem UUID: XXX
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 652800
Block count: 2621440
Reserved block count: 129948
Free blocks: 510232
Free inodes: 438179
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1023
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8160
Inode blocks per group: 510
Flex block group size: 16
Filesystem created: Fri Oct 21 16:17:46 2016
Last mount time: Thu Nov 23 17:35:09 2017
Last write time: Thu Nov 23 17:42:31 2017
Mount count: 1
Maximum mount count: -1
Last checked: Thu Nov 23 17:31:54 2017
Check interval: 0 (<none>)
Lifetime writes: 456 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: XXX
Journal backup: inode blocks
块数 * 块大小为 10G 那么 fdisk 会发生什么?剩下的10G怎么分区?
您必须删除分区并创建一个新分区。
显示分区信息:
删除分区:
创建一个新分区:
显示分区信息:
当您确定更改正确时,请使用 w 选项写入更改。
检查文件系统: