-2

I get this error when I was trying to install java in my virtual machine -- "vagrant no space left on device". My virtual machine is debian, and the computer is mac.

root@web1:~# df -h 
Filesystem             Size  Used Avail Use% Mounted on
/dev/sda1              9.2G  9.2G     0 100% /
udev                    10M     0   10M   0% /dev
tmpfs                  403M  5.4M  397M   2% /run
tmpfs                 1006M   12K 1006M   1% /dev/shm
tmpfs                  5.0M     0  5.0M   0% /run/lock
tmpfs                 1006M     0 1006M   0% /sys/fs/cgroup
home_vagrant_builtinx  465G  175G  290G  38% /home/vagrant/builtinx

So I found my vm instance debian-jessie-disk1.vmdk, and tried to resize it with command:

sudo VBoxManage modifyhd --resize 40000 'debian-jessie-disk1.vmdk'

It said this format is not supported. The I followed the steps at vagrant no space left on device, and cloned the disk to debian-jessie-disk1.vdi, and successfully resized the cloned disk.

I followed everything until steps: "create a new partition (again logged on as super user su -)"

My command line says pvs, pvcreate are not found commands, and I googled a bit about these commands, and didn't find something useful about how to install these packages.

Then I open "VM VirtualBox Manager" UI tool, and assign the new disk debian-jessie-disk1.vdi to virtual machine's storeage Controller, and remove the old one, and save.

Now the storage disk information screen says

Type(Format): Normal(VDI)
Virtual Size: 39.06 GB
Actual Size: 9.75 GB
Details: Dynamically allocated storage

However, I goto the VM, and do

root@web1:~# df -h 

The same result is returned. I think the space is somehow not freed. Do I miss something here? Thanks for your help :)

Community
  • 1
  • 1
smiletrl
  • 351
  • 4
  • 11

3 Answers3

0

pvcreate is a part of lvm2 (Logical volume management) you should try to install it, it brings some utilities to play with partitions. More info here https://wiki.debian.org/LVM

Victor Rocheron
  • 61
  • 1
  • 10
  • Thanks Victor! I was searching and viewing this page with my VPN connection and got 403 Forbidden error for this page. Since you referenced it again, so I disabled my VPN connection, and find the info I need. Thanks again. – smiletrl Nov 05 '16 at 01:16
0

You changed the size of the disk drive, but did resize neither the partition nor the filesystem on it. When you run fdisk in the VM on the disk drive, you will find free space after the last partition used.

You now have two choices from within your running guest system:

  1. Create an additional partition
  2. Resize the last existing partition

1. Create an additional partition

  1. Create an additional partition with fdisk
  2. Create a new filesystem of your choice on that partition using newfs, or mkfs*
  3. Create a mount point for the new filesystem
  4. Mount the new filesystem
  5. Move data from your overpopulated / to the new filesystem. Be sure not to move anything, that is required for your system to boot
  6. Add the new partition to /etc/fstab
  7. Optionally put symlinks, where the moved data originally was located.

You wrote about the pvs command in the linked article. That system used logical volume management and the new partition was simply added to the available volumes. However, to make use of it with LVM, you either have to create a new logical volume with a new filesystem on it or resize an existing logical volume and the filesystem on it.

2. Resize the last existing partition

  1. Using disk, change the last partition. Leave the first sector as it is and increase the last sector to fill the entire disk
  2. Re-size the filesystem on the partition. The may not work for all possible file systems and each film system requires its own tool. For XFS e.g you can use xfs_growfs.

Possible alternatives

  • Use a program like partition magic and hope, that it can handle your linux filesystem
  • Copy the entire content of the root partition to the new partition and change root afterwards. Make sure to not copy everything byte by byte, but use something like dump/restore, that can handle special files and stops at filesystem borders.

Most important: Be sure to have a valid backup before playing around with file systems. Backing up the virtual hard disk on the host system should be ok.

Mario Klebsch
  • 361
  • 2
  • 12
  • Thanks Mario. I picked your second "Resize the last existing partition". The steps might be slightly different, but the general idea is similar. Thanks for your help :) – smiletrl Nov 05 '16 at 01:47
0

So finally the steps I take (with help from other comments and friends) are:

1). check the current disks using following command, and find there're three partitions available: /dev/sda1 /dev/sda3 /dev/sda5. I think I added the extra partitions 3/5 when I was following other guides.

sudo fdisk -l

2). Remove swap spaces with following commands. I find only sda5 has swap created at /etc/fstab, so I comment that line out with the first command.

sudo nano /etc/fstab
sudo swapoff /dev/sda5

3). Delete all old partitions(This action is bold, and I was told by my colleague this is okay for Linux system) and create a new partition.

vagrant@web1:~$ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): d
... // delete all existing partitions.
Command (m for help): n
Command (m for help): w

4). Find the new partition I have created and resize the new partition to use full space in the disk drive.

df -h  || This command finds my new partition is /dev/sda1
sudo resize2fs /dev/sda1

5). Check whether the partition has used the full space.

df -h

I might have forgotten the reboot step here because I kept vagrant halt and vagrant up during this process to restart the virtual machine. Try to reboot the machine if things doesn't show correctly for you.

smiletrl
  • 351
  • 4
  • 11