1

Recently I lost everything on my PC and reinstalled Windows. But I have my old Ubuntu virtual machine's .vdi file.

Can I make a virtual machine with that .vdi file? If so, how?

Dan
  • 13,119

2 Answers2

8

If you are using VirtualBox, then it is not too difficult to take a VDI and use it anywhere. Here's how:

  • copy your .vdi file to a directory where VirtualBox will be able to access it
  • run VirtualBox and create a new virtual machine
  • choose Ubuntu Linux as the operating system and click "Next"
  • under the "Virtual Hard Disk" option, choose "Use existing hard disk". This will open the "Virtual Media Manager".
  • in the Virtual Media Manager, click the "Add" button and select the .vdi file that you copied, then click "Next"
  • configure the rest of the virtual machine as you would like it to be
  • start the virtual machine

So long as the .vdi file has not been corrupted, it will work just fine.

matigo
  • 22,138
  • 7
  • 45
  • 75
4

Convert VDI File to Full Install

You also have the option to convert a .vdi file to an .img file and flash that to HDD or USB.

  • Log into Ubuntu.

  • Open VirtualBox

  • cd to folder that contains ubuntu.vdi and run:

VBoxManage clonemedium --format RAW ubuntu.vdi ubuntu.img

This will create the Ubuntu image file

Install Image File to target drive

Caution: The target drive will be overwritten.

  • Use Gnome-Disks, Etcher, Rufus, dd or mkusb when you want to restore or clone the image to another HDD or USB drive.

For using Etcher or Rufus to flash an image to HDD see: https://askubuntu.com/a/1333112/43926

C.S.Cameron
  • 19,519
  • with this can't I make a new virtual machine – Aesha Amoli Apr 27 '21 at 09:39
  • @Aesha Amoli: This answer is to give you an option to be able to run your old virtual machine from a USB or from a HDD. matigo's answer is the one you asked for, mine is just an option. – C.S.Cameron Apr 27 '21 at 09:47
  • ohk then i have to live boot it and get all deleted files, am i right? btw 'VBoxManage clonemedium --format RAW ubuntu.vdi ubuntu.img' isn't working on cmd – Aesha Amoli Apr 27 '21 at 10:04
  • Are you running it from within the folder that has the .vdi file? "ubuntu.img" should be changed to the name of your image file – C.S.Cameron Apr 27 '21 at 10:44