跑步df -h
回报:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 3.9G 3.7G 1.8M 100% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 396M 880K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 76K 2.0G 1% /run/shm
none 100M 48K 100M 1% /run/user
由于某种原因,Ubuntu 说我只有 4GB 硬盘空间,但在 VirtualBox 中的“存储”>“控制器:SATA”下,它说我有 Ubuntu.vdi(正常,11.72 GB)。
我resize2fs
也尝试过运行,结果返回:
sudo resize2fs /dev/sda1
resize2fs 1.42.9 (4-Feb-2014)
The filesystem is already 1048320 blocks long. Nothing to do!
运行 fdisk 返回:
sudo fdisk -l
Disk /dev/sda: 12.6 GB, 12582912000 bytes
255 heads, 63 sectors/track, 1529 cylinders, total 24576000 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 identifier: 0x000ac43a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 8388607 4193280 83 Linux
/dev/sda2 8390654 16775167 4192257 5 Extended
/dev/sda5 8390656 16775167 4192256 82 Linux swap / Solaris
如何增加虚拟机的磁盘空间?
答案1
VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB
按照这里提到的方式运行如何增加虚拟机的硬盘大小?是第一步。然后必须调整分区大小。这样做并不简单,我能找到的最佳且有效的说明如下:
http://logicmason.com/2012/growing-a-hard-drive-partition-in-a-virtualbox-ubuntu-guest/
基本上将 GParted.iso 作为 Controller:IDE 加载,以便它在启动时启动。然后,在其 UI 中,您可以重新分配磁盘空间并移动分区。退出 GParted 并启动 Ubuntu,运行df-h
返回:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 12G 3.7G 7.3G 34% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 12K 2.0G 1% /dev
tmpfs 396M 872K 395M 1% /run
none 5.0M 4.0K 5.0M 1% /run/lock
none 2.0G 76K 2.0G 1% /run/shm
none 100M 28K 100M 1% /run/user
/dev/sr0 222M 222M 0 100% /media/cameron/GParted-live