近期处理一个磁盘扩容需求,虚拟化工程师扩容时直接将/dev/sdc磁盘进行了扩容,登录linux操作系统以后检查发现,/dev/sdc的盘上已经划分了3个主分区和1个扩展分区,并在扩展分区下划分了一个/dev/sdc5。这种情况意味着已经扩容到/dev/sdc磁盘上的容量没有办法创建新的分区使用更别说扩容文件系统了。本文将引导您完成扩容操作。
一、先决条件
1.正常的Linux操作系统,并使用lvm管理磁盘
2.在单一分区上已经划分了3主分区和1个扩展分区
3.扩容容量的磁盘已经无法创建新分区
二、解决方案
如果在虚拟化环境中,我们首选一定要记得做个快照。很多的时候,这个快照是你最后的机会。
1.扩容虚拟化磁盘
我们在虚拟化环境中,将/dev/sdc的盘从10G增大到12G并保存配置。
2.操作系统识别磁盘
重新扫描/dev/sdc的磁盘,并且正常识别到12G。
[root@shizhanxia.com ]# echo 1 > /sys/class/scsi_device/0\:0\:2\:0/device/rescan
3.卸载分区
卸载将分区/sdc5从分区/dev/sdc5上卸载,卸载命令为:
[root@shizhanxia.com ]# umount /sdc5
4.删除分区
我们需要删除并重新划分/dev/sdc4(扩展分区)以及扩展分区上划分的/dev/sdc5分区。
[root@shizhanxia.com ]# umount /sdc5
4.删除分区
我们需要删除并重新划分/dev/sdc4和sdc5分区
[root@shizhanxia.com ]# fdisk /dev/sdc #分区/dev/sdc 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): p #打印分区信息 Disk /dev/sdc: 12.9 GB, 12884901888 bytes, 25165824 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: 0x00076296 Device Boot Start End Blocks Id System /dev/sdc1 2048 4194303 2096128 8e Linux LVM /dev/sdc2 4194304 8388607 2097152 8e Linux LVM /dev/sdc3 8388608 12582911 2097152 8e Linux LVM /dev/sdc4 12582912 20971519 4194304 5 Extended /dev/sdc5 12584960 20971519 4193280 8e Linux LVM Command (m for help): d #删除分区 Partition number (1-5, default 5): 5 #删除分区5 Partition 5 is deleted Command (m for help): d #删除分区 Partition number (1-4, default 4): 4 #删除分区4 Partition 4 is deleted Command (m for help): n #创建分区 Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): e #创建扩展分区 Selected partition 4 #创建分区4 First sector (12582912-25165823, default 12582912): Using default value 12582912 Last sector, +sectors or +size{K,M,G} (12582912-25165823, default 25165823): Using default value 25165823 Partition 4 of type Extended and of size 6 GiB is set Command (m for help): n #创建分区 All primary partitions are in use Adding logical partition 5 First sector (12584960-25165823, default 12584960): Using default value 12584960 Last sector, +sectors or +size{K,M,G} (12584960-25165823, default 25165823): Using default value 25165823 Partition 5 of type Linux and of size 6 GiB is set 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: Device or resource busy. 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. End
扩展阅读
原创文章,作者:保哥,如若转载,请注明出处:https://www.shizhanxia.com/1560.html