vagrant 设备上没有剩余空间 [英] vagrant no space left on device
问题描述
今天我开始在简单的操作上出错,比如在 vim
中创建小文件,bash 完成也开始抱怨.
Today I started getting errors on simple operations, like creating small files in vim
, the bash completion started to complain as well.
这是df -h
的结果:
vagrant@machine:/vagrant$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 40G 38G 249M 100% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 12K 2.0G 1% /dev
tmpfs 396M 396K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 0 2.0G 0% /run/shm
none 100M 0 100M 0% /run/user
overflow 1.0M 148K 876K 15% /tmp
192.168.50.1:/Users/nha/repo/assets 233G 141G 93G 61% /var/www/assets
vagrant 233G 141G 93G 61% /vagrant
那么显然 /
没有空间了?因为我在其他文件系统中有空间(或者我误读了什么),这不是很奇怪吗?
So apparently /
doesn`t have space anymore ? Isn't it weird since I have space in the other filesystems (or am I misreading something) ?
如何在我的虚拟机上获得更多空间?
How do I get more space on my vm ?
推荐答案
即使您的来宾操作系统上有空间,虚拟机也是有限的.为了增加磁盘的大小,需要几个步骤:
Even though you have space on your Guest OS, the VM is limited.There are couple of steps required in order to increase the size of your disk:
首先,vagrant halt
关闭你的虚拟机
调整磁盘大小
VBoxManage clonehd box-disk1.vmdk box-disk1.vdi --format vdi
VBoxManage modifyhd box-disk1.vdi --resize 50000
启动 Virtual box 并更改 VM 的配置以关联新磁盘
start Virtual box and change configuration of the VM to associate the new disk
使用 fdisk 调整磁盘大小
你需要用新的空间创建一个新的分区并分配它,所以首先启动VM并以超级用户身份登录
you need to create a new partition with the new space and allocate it, so first start the VM and logged on as super user
vagrant up && vagrant ssh
su -
命令(如我的实例所示)是
the command (as illustrated from my instance) are
[root@oracle ~]# fdisk /dev/sda
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): p
Disk /dev/sda: 52.4 GB, 52428800000 bytes
255 heads, 63 sectors/track, 6374 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: 0x00041a53
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2611 20663296 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2611-6374, default 2611):
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-6374, default 6374):
Using default value 6374
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@oracle ~]#
注意与您的配置相比,您可能需要更改/dev/sda
note you might need to change /dev/sda compare to your configuration
创建一个新分区(再次以超级用户su -
登录)
create a new partition (again logged on as super user su -
)
su -
[root@oracle ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 linux lvm2 a-- 19.70g 0
[root@oracle ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@oracle ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 linux lvm2 a-- 19.70g 0
/dev/sda3 lvm2 a-- 28.83g 28.83g
[root@oracle ~]# vgextend linux /dev/sda3
Volume group "linux" successfully extended
[root@oracle ~]# lvextend -l +100%FREE /dev/linux/root
[root@oracle ~]# resize2fs /dev/linux/home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/linux/home is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/linux/home to 7347200 (4k) blocks.
The filesystem on /dev/linux/home is now 7347200 blocks long.
这篇关于vagrant 设备上没有剩余空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!