在 Ubuntu 10.04 (VMWare Guest) 上扩展磁盘空间

Jas*_*son 6 linux ubuntu partition disk-space-utilization vmware-workstation

我需要在 VMWare Workstation 中调整 ubuntu 来宾的磁盘空间大小。在 vmware 工作站中使用扩展磁盘实用程序后,我需要做一些 linux 魔术来调整分区大小。我搜索并找到了很多关于调整大小的帖子。不幸的是,我并没有真正理解它。谁能帮我解决这个问题?

jclawson@ubuntu:~$ df

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/ubuntu-root
                       7583436   5678136   1520072  79% /
udev                   1030884       152   1030732   1% /dev
none                   1030884         0   1030884   0% /dev/shm
none                   1030884        72   1030812   1% /var/run
none                   1030884         0   1030884   0% /var/lock
none                   1030884         0   1030884   0% /lib/init/rw
/dev/sda5               233335     39274    181613  18% /boot
.host:/              244035580  96519316 147516264  40% /mnt/hgfs


root@ubuntu:~# lvs
LV     VG     Attr   LSize   Origin Snap%  Move Log Copy%  Convert
root   ubuntu -wi-ao   7.35G
swap_1 ubuntu -wi-ao 388.00M


root@ubuntu:~# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009bea5

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1013     8136891   8e  Linux LVM
/dev/sda2            1014        1044      249007+   5  Extended
/dev/sda5            1014        1044      248976   83  Linux
Run Code Online (Sandbox Code Playgroud)

我真的很感谢你的帮助。

Jas*_*son 7

好吧,经过一番折腾,我终于想出了怎么做。同样,不能使用 gparted。首先,您应该在 VMWare Workstation 中扩展磁盘的大小。启动到 livecd 并打开根终端:

我们需要从空闲的未使用空间中创建一个 LVM 类型的新主分区。

#fdisk /dev/sda
#Command (m for help): n
#Command (m for help): p
#Command (m for help): 3
#Command (m for help): w
Run Code Online (Sandbox Code Playgroud)

再次将虚拟机重新启动到 live cd

创建物理卷:

#pvcreate /dev/sda3
Run Code Online (Sandbox Code Playgroud)

将新卷添加到组中:

#vgextend ubuntu /dev/sda3
Run Code Online (Sandbox Code Playgroud)

找出您想要扩展到多少可用空间

#vgdisplay
Run Code Online (Sandbox Code Playgroud)

检查“Free PE/Size”等于什么并在下一个命令中使用该值

扩展lvm并将文件系统增长到新空间

#e2fsck -f /dev/ubuntu/root
#lvextend -L +12.6G /dev/ubuntu/root
#resize2fs /dev/ubuntu/root
Run Code Online (Sandbox Code Playgroud)

完毕!