我的服务器有 4 个主分区,其中的数据我无法删除,但我需要扩展硬盘,因为它空间不足。我已经增加了 vmdk 文件的大小,但当我尝试创建分区时,我收到了消息,You must delete some partition and add an extended partition first
但这就是问题所在,我无法删除分区...
root@webhost [~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 2.4G 0 loop /tmp
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 24.5G 0 part
│ ├─vg_linuxwebserver2-lv_root (dm-0) 253:0 0 97.5G 0 lvm /
│ └─vg_linuxwebserver2-lv_swap (dm-1) 253:1 0 2G 0 lvm [SWAP]
├─sda3 8:3 0 25G 0 part
│ ├─vg_linuxwebserver2-lv_root (dm-0) 253:0 0 97.5G 0 lvm /
│ └─vg_linuxwebserver2-lv_swap (dm-1) 253:1 0 2G 0 lvm [SWAP]
└─sda4 8:4 0 50G 0 part
└─vg_linuxwebserver2-lv_root (dm-0) 253:0 0 97.5G 0 lvm /
sr0 11:0 1 1024M 0 rom
root@webhost [~]# fdisk -l
Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000969eb
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 3264 25701376 8e Linux LVM
/dev/sda3 3264 6527 26213727+ 83 Linux
/dev/sda4 6528 13054 52428127+ 8e Linux LVM
Disk /dev/mapper/vg_linuxwebserver2-lv_root: 104.7 GB, 104689827840 bytes
255 heads, 63 sectors/track, 12727 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_linuxwebserver2-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
我可以使用 gparted 扩展例如 /dev/sda4 吗,同时记住它是 LVM 的一部分(我试图避免删除分区)?
谢谢
答案1
是的,您可以使用 gparted 来扩展分区 n.4,然后(假设您想使用所有可用空间来扩展逻辑卷)发出以下命令:
pvresize
lvresize /dev/mapper/vg_linuxwebserver2-lv_root -l+100%FREE
无论如何,我建议你打印一个扇区寻址的分区表(你可以使用切换到基于扇区的大小fdisk -u
,这样如果 gparted 无法调整分区大小,你可以轻松地通过以下方式重建它fdisk
您还可以使用命令对分区表进行二进制备份
dd if=/dev/sda of=ptable.bin bs=512 count=1