How to Rebuild a Virtual Machine from Existing VDI Disks (The Easy Way)

Have you ever found yourself with a folder full of Virtual Disk Images (.vdi files) but no Virtual Machine configuration file (.vbox) to run them? Whether your host operating system crashed, you are migrating environments to a new laptop, or you are restoring a backup from cold storage, spinning up a machine from pre-existing virtual disks can feel daunting—especially when there are multiple data disks involved.

In this guide, we will look at exactly how to construct a new VM shell and map your existing virtual disks correctly without losing data or messing up your boot order.

The Real-World Use Case: Simulating Production Storage

While this process works for a simple single-disk backup, the ultimate use case for this technique is managing advanced multi-disk database environments.

Consider a professional enterprise architecture lab, such as an Oracle Exadata Storage Cell simulator or an Oracle RAC (Real Application Clusters) node. In these high-performance environments, the architecture is strictly separated:

  • The OS Disk: One disk containing the base operating system (e.g., Oracle Linux 6.x or 7.x) and the cluster software framework.
  • The ASM Storage Disks: A massive array of secondary disks dedicated entirely to Oracle Automatic Storage Management (ASM) disk groups and high-speed flash grids.

If your VirtualBox manager profile gets wiped, you don’t want to re-install the operating system or lose hours re-configuring complex ASM disk signatures. You need to map the existing infrastructure to a brand-new VM shell cleanly. Here is exactly how to do it.

Step-by-Step Guide: Building the VM Shell and Attaching Disks

Step 1: Create the “Blank” Virtual Machine Shell

First, we need to create a hardware profile container for our operating system.

  1. Open Oracle VirtualBox and click the blue New button.
  2. Configure the basic identity:
    • Name: Give it a meaningful name (e.g., MyCell2).
    • Folder: Choose the directory where your existing VDI files live to keep your files organized.
    • ISO Image: Leave this Blank / Not selected (we are not installing an OS from scratch).
    • Type & Version: Select your matching OS profile (e.g., Linux and Oracle Linux 64-bit).
  3. Click Next.
  4. Hardware: Allocate your required RAM and vCPUs based on your host system’s limits, then click Next.
  5. Virtual Hard Disk: This is the crucial step. Select the radio button that says Do Not Add a Virtual Hard Disk.
  6. Click Finish.

Step 2: Register and Attach the Boot Operating System

Now we have an empty hardware chassis. Let’s install our pre-configured boot drive.

  1. Select your new VM from the list and click Settings (the gear icon).
  2. Navigate to the Storage tab on the left menu.
  3. Under the Storage Devices tree, highlight the default storage controller (usually Controller: SATA).
  4. Tip: If there is an empty virtual optical disc drive listed under it, select it and click the Remove icon at the bottom to clean up your tree.
  5. Click on the Controller line, then click the Adds hard disk icon (the small hard drive with a green plus sign).
  6. In the hard disk manager window, click Add, browse to your folder, select your boot operating system disk (e.g., mycell2.vdi), and click Open.
  7. Highlight it in the list and click Choose.

⚠️ Critical Check: Ensure this primary operating system disk is assigned to the very first port on your controller (e.g., Port 0). The virtual motherboard looks here first to find the master boot record.

Step 3: Mapping the Mass Storage (ASM/Data Disks)

If you only have one or two data disks, you can repeat the process above by clicking Adds hard disk, registering them, and choosing them one by one.

However, if you are running a heavy storage simulation with 12 database disks and 6 flash disks (18 total ASM disks), clicking through the GUI will take forever. Instead, save your settings, close VirtualBox, and use the power of the command line to attach them instantly.

Open a terminal or PowerShell window, navigate to your VDI folder, and run these quick loops to map the disks sequentially:

For Windows (PowerShell):

PowerShell

# Instantly attach ASM data disks 01 through 12
for ($i=1; $i -le 12; $i++) {
$num = $i.ToString("00")
VBoxManage storageattach "MyCell2" --storagectl "SATA" --port $i --device 0 --type hdd --medium "disk$num.vdi"
}
# Instantly attach ASM flash disks 01 through 06 to the remaining ports
for ($i=1; $i -le 6; $i++) {
$num = $i.ToString("00")
$port = $i + 12
VBoxManage storageattach "MyCell2" --storagectl "SATA" --port $port --device 0 --type hdd --medium "flash$num.vdi"
}

For Linux / macOS (Bash):

Bash

# Attach ASM data disks 01 through 12
for i in {01..12}; do
VBoxManage storageattach "MyCell2" --storagectl "SATA" --port $((10#$i)) --device 0 --type hdd --medium "disk$i.vdi"
done
# Attach ASM flash disks 01 through 06
for i in {01..06}; do
port=$((10#$i + 12))
VBoxManage storageattach "MyCell2" --storagectl "SATA" --port $port --device 0 --type hdd --medium "flash$i.vdi"
done

Step 4: Fire It Up!

Once the scripts finish running, reopen your VirtualBox GUI. Go to the storage settings of MyCell2, and you will see all 19 disks cleanly mapped to sequential ports.

Double-check your Network settings to make sure your host-only or internal private networks match your old cluster requirements, then hit Start. Your operating system will boot up smoothly, auto-scan the device paths (/dev/sd*), find your existing ASM disk group headers, and mount your volumes perfectly without a single byte of data loss.

Leave a Reply