Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Change location of virtual disk in Virtual Box
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
philip
Guru
Guru


Joined: 10 Jun 2003
Posts: 465
Location: Sweden

PostPosted: Fri Jan 06, 2012 3:06 pm    Post subject: [SOLVED] Change location of virtual disk in Virtual Box Reply with quote

I have been using VirtualBox for W7 on my Gentoo machine, without any problems for quite some time.

I have given my virtual disk /mnt/w7/Windows_7.vdi a separate partition /dev/hda1 of size 26 GB. Now the size of the virtual disk has grown and I need more disk space. I have installed a new SATA SSD of size 120 GB an mounted it under /mnt/vb_w7/

My intention has been to move the virtual disk to the new SSD. I did the follwing steps to move the virtual disk:

1. cloned the virtual disk to the new location

Code:
# /opt/bin/VBoxManage clonehd /mnt/w7/Windows_7.vdi /mnt/vb_w7/Windows_7.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 0c0f2877-96e9-4455-8629-58957d70ee23


2. Released the old virtual disk, through the VB GUI

Code:
Menu -> Virtual Media Manager ->  Right Click -> Release


3. Choose the new location of the (cloned) virtual disk, through the VB GUI

Code:
Settings -> Storage -> Click on SATA Controller -> Right Click and Add Hard Disk -> Choose Existing disk -> brows to the new virtual disk location/mnt/vb_w7/Windows_7.vdi) -> Open


Here I get an error message from VirtualBox:

Quote:
"Failed to open the hard disk /mnt/vb_w7/Windows_7.vdi
The medium '/mnt/vb_w7/Windows_7.vdi' can't be used as requested device type.
Details:
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: Medium
Interface: IMedium
{9edda847-1279-4b0a-9af7-9d66251ccc18}
Callee:
IVirtualBox {d2de270c-1d4b-4c9e-843f-bbb9b47269ff}



I have done the steps according to the VB Manual. I have unfortunately no clue how to solve this.


When I examine the original virtual disk (/mnt/w7/Windows_7.vdi) and the cloned one (/mnt/vb_w7/Windows_7.vdi) the cloned one seems OK with the VBoxManage tool:

Code:
phils_pc philip # /opt/bin/VBoxManage showhdinfo /mnt/w7/Windows_7.vdi
UUID:                 5fce96ff-44d9-485d-93b1-c6d873a6ef90
Accessible:           yes
Logical size:         20480 MBytes
Current size on disk: 20480 MBytes
Type:                 normal (base)
Storage format:       VDI
Format variant:       fixed default
Location:             /mnt/w7/Windows_7.vdi


and

Code:
phils_pc philip # /opt/bin/VBoxManage showhdinfo /mnt/vb_w7/Windows_7.vdi
UUID:                 0c0f2877-96e9-4455-8629-58957d70ee23
Accessible:           yes
Logical size:         20480 MBytes
Current size on disk: 19668 MBytes
Type:                 normal (base)
Storage format:       VDI
Format variant:       dynamic default
Location:             /mnt/vb_w7/Windows_7.vdi


S O L V E D:

The problem was that the permissions for the virtual disk file was changed when cloning the disk.

Here are the complete sequence, in 6 steps, for a successful change of location for the virtual machine files and the virtual disk:

Original location /mnt/w7 (on /dev/hda1) and destination /mnt/vb_w7/ (on /dev/sda1)

Step 1:
Use the VBoxManage tool to clone the virtual disk in order to provide it a new UUID. Give the cloned disk a new name in the same step

Code:
/opt/bin/VBoxManage clonehd /mnt/w7/Windows_7.vdi /mnt/vb_w7/Win_7.vdi


Just copy the file to the new location does not work, because VirtualBox needs a unique UUID for the virtual disk file.
New UUID is: 14a33a14-cac3-4e5b-ae13-72f33be7181b

Step 2:
Modify the permission right to the file (virtual disk)

Code:
# chmod 777  /mnt/vb_w7/Win_7.vdi

in order for VirtualBox to recognize the file as a disk

Step 3:
Expand the capacity of the virtual disk to 100 GB (102400 MB)

Code:
# cp /mnt/w7/Windows\ 7/ /mnt/vb_w7/


Step 4:
Re-configure the virtual machine (named Window 7) to point to the new directory and to attach the cloned disk
In the VirtualBox GUI:

Code:
Menu -> Virtual Media Manager -> Right Click -> Release


and
Code:

Settings -> Storage -> Click on SATA Controller -> Right Click and Add Hard Disk -> Choose Existing disk -> brows to the new virtual disk location/mnt/vb_w7/Win_7.vdi) -> Open


Step 5:
Re-configure the virtual machin (named “Windows 7” in my case) to point to the new directory for the snapshots

Code:
General → Advanced → Snapshot folder → “/mnt/vb_w7/Windows 7”


A final check of the virtual disk size:

Code:
# /opt/bin/VBoxManage showhdinfo /mnt/vb_w7/Win_7.vdi
UUID:                 14a33a14-cac3-4e5b-ae13-72f33be7181b
Accessible:           yes
Logical size:         102400 MBytes
Current size on disk: 19669 MBytes
Type:                 normal (base)
Storage format:       VDI
Format variant:       dynamic default
Location:             /mnt/vb_w7/Win_7.vdi


Step 6:
Extend the hard disk space in W7

Start the virtual machine to boot into Windows 7 on the newly attached VDI.
Code:
 
Go to Start–>Control Panel–>Administrative Tools–>Computer Management In Computer Management–>Disk Management,
choose your system drive(Boot), right click on it and choose "Extend Volume"

_________________
/Phil
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum