Skip to content

VirtualBox Disk Recovery

robnagler edited this page Sep 6, 2022 · 2 revisions

See also Vagrant for more recovery options.

If your Vagrant VirtualBox VM can no longer boot, you can recover the files from the hard drive by following these steps:

In this example, the "v2" VM would no longer boot, but the "v" VM was OK.

Select "Settings" for the good "v" VM in VirtualBox, then select Storage:

Select "Adds a new storage controller": AHCI (SATA) Select "Adds a hard disk" Hover over the files and find the one which matches the bad VM's disk.

Save settings and boot the good VM using vssh. Use the "df" command to see the name of the disk which is already mounted. Use lsblk to see the available disks and find the name of the old hard drive. Then mount it in /mnt/old and you can recover your data in the /home/vagrant directory.

$ sudo su -
# df | grep /dev/sd
/dev/sdc1                  41021664 33500312   5407868  87% /

# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   40G  0 disk
└─sda1            8:1    0   40G  0 part
sdb               8:16   0  100G  0 disk
└─docker-docker 253:0    0  100G  0 lvm  /srv/docker
sdc               8:32   0   40G  0 disk
└─sdc1            8:33   0   40G  0 part /

# mkdir /mnt/old
# mount /dev/sda1 /mnt/old
# cd /mnt/old/home/vagrant/