GPT分区不能使用gropwpart进行扩容分区,需要删除源有GPT分区,再次新建分区
1、查看当前分区状态
代码语言:javascript
复制#查看分区是否是GPT
[root@master ~]# fdisk -lu
Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000c5246
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999 83 Linux
Disk /dev/vdb: 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: 0x6d99bbf5
Device Boot Start End Blocks Id System
/dev/vdb1 2048 83886079 41942016 83 Linux
# Disk label type 字段显示是dos,说明是MBR分区,需要将其修改为GPT分区
2、修改MBR至GPT分区
代码语言:javascript
复制#当前分区已经挂载,且有数据
[root@master ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs 1.8G 636K 1.8G 1% /run
tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/vda1 40G 6.5G 33G 17% /
tmpfs 365M 0 365M 0% /run/user/0
overlay 40G 6.5G 33G 17% /var/lib/docker/overlay2/d767eb758bc331212ea9654d5fd69a82a8745f6571c190c0c453614a73152b67/merged
/dev/vdb1 40G 49M 38G 1% /mnt
#卸载磁盘并删除分区
[root@master ~]# umount /dev/vdb1
[root@master ~]# 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.
Command (m for help): d
Partition 1 is deleted
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#转换为GPT
[root@master ~]# parted /dev/vdb
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/vdb will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
(parted) mkpart primary 1 100%
(parted) align-check optimal 1
1 aligned
(parted) print
Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 42.9GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 42.9GB 42.9GB ext4 primary
(parted) quit
Information: You may need to update /etc/fstab.
[root@master ~]# blkid
/dev/vda1: UUID="a92951e2-d169-405d-8eb9-64983497ed65" TYPE="ext4"
/dev/vdb1: UUID="e46bb349-da83-4a7a-be05-e3a28b71bdcc" TYPE="ext4"
[root@master ~]# mkfs.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
2621440 inodes, 10485248 blocks
524262 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 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
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@master ~]# mount /dev/vdb1 /mnt
[root@master ~]# ls /mnt
lost found
[root@master ~]# umount /dev/vdb1
3、扩容云盘
代码语言:javascript
复制[root@master ~]# fdisk -lu
Disk /dev/vda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000c5246
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999 83 Linux
Disk /dev/vdb: 64.4 GB, 64424509440 bytes, 125829120 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: 0x00000000
Device Boot Start End Blocks Id System
/dev/vdb1 1 83886079 41943039 ee GPT
[root@master ~]# parted /dev/vdb
GNU Parted 3.1
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) rm 1
Error: The backup GPT table is not at the end of the disk, as it should be.
This might mean that another operating system believes the disk is smaller.
Fix, by moving the backup to the end (and removing the old backup)?
parted: invalid token: 1
Fix/Ignore/Cancel? F
Warning: Not all of the space available to /dev/vdb appears to be used, you can
fix the GPT to use all of the space (an extra 41943040 blocks) or continue with
the current setting?
Fix/Ignore? F
Partition number? 1
(parted) mkpart primary 1 100%
(parted) align-check optimal 1
1 aligned
(parted) quit
Information: You may need to update /etc/fstab.
[root@master ~]# mount /dev/vdb1 /mnt
[root@master ~]# resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vdb1 is mounted on /mnt; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 8
The filesystem on /dev/vdb1 is now 15728128 blocks long.
[root@master ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs tmpfs 1.8G 540K 1.8G 1% /run
tmpfs tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/vda1 ext4 40G 6.5G 33G 17% /
tmpfs tmpfs 365M 0 365M 0% /run/user/0
/dev/vdb1 ext4 59G 52M 57G 1% /mnt