Ubuntu LVM 未检测到分区大小调整

Ubuntu LVM 未检测到分区大小调整

我在 VirtualBox 中将 Ubuntu 15.04 作为客户操作系统,并使用 GParted LiveCD 调整了 VDI 驱动器及其内部分区的大小。GParted 正确看到了新大小(14.5 GB),但在 Ubuntu 内部它仍然是旧大小: 在此处输入图片描述

$ df -k
Filesystem                1K-blocks    Used Available Use% Mounted on
/dev/mapper/zion--vg-root   7331536 7115864         0 100% /
none                              4       0         4   0% /sys/fs/cgroup
udev                        1013420       4   1013416   1% /dev
tmpfs                        204912     448    204464   1% /run
none                           5120       0      5120   0% /run/lock
none                        1024556       0   1024556   0% /run/shm
none                         102400       0    102400   0% /run/user
/dev/sda1                    240972  136514     92017  60% /boot
overflow                       1024     140       884  14% /tmp

编辑

输出parted -l

Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 15.7GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  256MB   255MB   primary   ext2         boot
 2      257MB   15.7GB  15.5GB  extended
 5      257MB   15.7GB  15.5GB  logical                lvm


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/zion--vg-swap_1: 533MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End    Size   File system     Flags
 1      0.00B  533MB  533MB  linux-swap(v1)


Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/zion--vg-root: 7764MB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  7764MB  7764MB  ext4


Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Error: Can't have a partition outside the disk!

答案1

正如评论中指出的那样,问题在于我的卷是 LVM,而 GParted 不知道如何调整其大小。解决方案是在 GParted LiveCD 上启动,然后运行以下命令:

# to find the name of the volume, /dev/zion-vg/root here
$ sudo lvdisplay

#to extend the volume (started at 15G, but had to bring it down to 13.9G since it had not enough size)
$ sudo lvextend -L13.9G /dev/zion-vg/root 

#needed by resize2fs
$ sudo e2fsck -f /dev/zion-vg/root

#final resize
$ sudo resize2fs  /dev/zion-vg/root

相关内容