咨询热线:4006-75-4006
售前:9:00-23:30 备案:9:00-18:00 技术:7*24h
GPT分区扩容——以ext4文件系统为例
欢迎来到蓝队云技术小课堂,每天分享一个技术小知识。今天主要介绍gpt分区如何扩容
扩容已有GPT分区
parted命令主要用于 GPT分区表的操作
• GPT:GPT 分区表支持更大的硬盘容量。它使用64位的逻辑块地址,因此可以支持超过2 TB的硬盘容量
分区后扩容
以ext4文件系统为例
/dev/sdf1有10G。将数据盘容量扩大至20G,将新增的10G划分至已有的/dev/sdf1内
df -Th
parted /dev/sdf
(parted) print
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)?
Fix/Ignore/Cancel? Fix #若界面提示Fix/Ignore/Cancel?和Fix/Ignore?,均输入Fix即可
Warning: Not all of the space available to /dev/sdf appears to be used, you can fix the GPT to use all of the space (an extra 20971520
blocks) or continue with the current setting?
Fix/Ignore? Fix
Model: VMware Virtual disk (scsi)
Disk /dev/sdf: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 10.7GB 10.7GB ext4 primary
(parted) rm 1 #删除1分区
(parted) mkpart primary 1049kB 100% #原分区的起始扇区为1049kB,且要将扩容后的总容量全部分配给该分区
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdf: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 21.5GB 21.5GB ext4 primary
(parted) quit #退出
Information: You may need to update /etc/fstab.
[root@localhost ~]# resize2fs /dev/sdf1
resize2fs 1.42.9 (28-Dec-2013)
Please run 'e2fsck -f /dev/sdf1' first.
[root@localhost ~]# e2fsck -f /dev/sdf1 #检测磁盘
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdf1: 11/655360 files (0.0% non-contiguous), 83137/2620928 blocks
[root@localhost ~]# resize2fs /dev/sdf1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/sdf1 to 5242368 (4k) blocks.
The filesystem on /dev/sdf1 is now 5242368 blocks long.
[root@localhost ~]# mount /dev/sdf1 /aaa
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 20M 1.9G 2% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 53G 3.2G 50G 6% /
/dev/sda1 xfs 797M 151M 647M 19% /boot
tmpfs tmpfs 378M 0 378M 0% /run/user/0
/dev/mapper/vgdata-lvdata ext4 689G 69M 658G 1% /data
/dev/sdf1 ext4 20G 44M 19G 1% /aaa
蓝队云是专业的云计算及网络安全服务商,提供云服务器、域名注册、负载均衡、SSL证书等专业的产品及服务。官网上拥有完善的技术支持库可供参考,大家可自行查阅,更多技术问题,可以直接咨询。同时,蓝队云整理了运维必备的工具包免费分享给大家使用,需要的朋友可以直接咨询。
更多技术知识,蓝队云期待与你一起探索。