新加一块磁盘,我的是sdb
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xce359e4e.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): (回车,默认将所有空间分配给第一个主分区)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): t(修改磁盘格式为LVM)
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
将新创建的主分区创建为物理卷
# pvcreate /dev/sdb1
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
查看根目录所属的卷组和逻辑卷
#df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 14G 1.8G 12G 13% /
将刚创建的物理卷/dev/sdb1添加到卷组中
# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
将卷组的50GB扩展给根所在的逻辑卷
# lvextend -L +50G /dev/mapper/centos-root
Logical volume lv_root successfully resized
激活修改的配置
# resize2fs /dev/mapper/centos-root
查看磁盘状态
# df -h
Linux resize2fs: Bad magic number in super-block错误的解决方法
执行resize2fs报错
# resize2fs /dev/mapper/centos-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-home 时
找不到有效的文件系统超级块
确认文件系统是xfs
# xfs_growfs /dev/mapper/centos-root
本文详细介绍了在Linux系统中如何扩展磁盘分区,创建物理卷,将其添加到卷组,并扩展逻辑卷。通过使用fdisk、pvcreate、vgextend、lvextend和resize2fs等命令,成功将新磁盘空间整合到根目录的文件系统中,解决了磁盘空间不足的问题。在过程中遇到了resize2fs的错误,通过确认文件系统类型为xfs并使用xfs_growfs命令解决了问题。
3894

被折叠的 条评论
为什么被折叠?



