LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 02-15-2009, 08:49 AM   #1
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 14.10
Posts: 275

Rep: Reputation: 25
Transferring virtual Linux install to physical drive


I have a Linux installation inside a VirtualBox VM (VDI file) that I would like to transfer to a physical hard disk. What would be the best way to do this? Could I mount the physical hard drive as a shared folder and use the dd command (booting the VM from a LiveCD) to transfer it? Note, both the VDI and the physical drive are the same size. Any ideas/advice would be appreciated.
 
Old 02-15-2009, 02:24 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
The problem with the mounting is that you normally use dd on a raw-device,
not on a file-system. For the transfer you could use dd & netcat, or tar &
netcat ....
 
Old 02-16-2009, 12:03 PM   #3
Mark_667
Member
 
Registered: Aug 2005
Location: Manchester, England
Distribution: Ubuntu 14.10
Posts: 275

Original Poster
Rep: Reputation: 25
How would you use netcat to help do this? Also, what about allowing raw disk access to the destination volume? Potentially dangerous-I know but would it work better? Are there any other ways anyone would recommend?
 
Old 02-16-2009, 01:46 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
That (raw device) is exactly what you'd be doing with netcat and dd ...

E.g.
http://www.rajeevnet.com/hacks_hints...s_cloning.html
for a how-to (there's heaps - search google for "netcat dd clone").

Cheers,
Tink
 
Old 02-16-2009, 04:48 PM   #5
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
Note this method will only work if you have a static .vdi VirtualBox drive image; if you are using a dynamic .vdi drive, I'm still in the process of figuring out how to mount them. But if you happen to have a static .vdi drive, I think probably the easiest way to transfer your VirtualBox OS to a partition would be to mount it, and then copy its entire file system to its new partition with "cp -ax" to preserve all the proper permissions/ownerships of all files. Most VirtualBox .vdi files just have 3 sectors of VirtualBox header info at the beginning, and then the rest is the HDD image. So to mount a static .vdi file, you can usually do:
Code:
losetup -f --show -o $((512*3)) ~/.VirtualBox/HardDisks/HDD_image.vdi
That will also return the loop device that the .vdi file gets associated with, for example "/dev/loop0". And then to see the partitions in that image:
Code:
fdisk -lu /dev/loop0
Using the above command, find the sector offset of the partition you want to mount, say for example the starting sector is 63, then do:
Code:
mount -o loop,offset=$((512*63)) /dev/loop0 /mnt
And that will mount your VirtualBox OS partition on /mnt. After that, it's just a matter of copying the file system to its new partition:
Code:
cp -ax /mnt/* /path_to_mounted_destination_partition/
And lastly, if you do:
Code:
blkid -c /dev/null
It will show you the UUID of your mounted VirtualBox partition, and you can transfer that UUID to the new partition with:
Code:
tune2fs -U <VirtualBox partition UUID> /dev/<new partition device>
You will probably have to modify /boot/grub/menu.lst and possibly /etc/fstab for the OS on the new partition, but that should be about all it takes. Let me know if you decide to give this method a try and how it goes.

Last edited by CJS; 02-17-2009 at 07:11 PM.
 
  


Reply

Tags
box, physical, vdi, virtual


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Physical Linux install to virtual machine linuxroks88 Linux - Server 1 12-20-2008 07:01 PM
how can i run 3 linux virtual machines without going out of physical memory asterik123 General 7 04-14-2007 06:51 PM
Physical to Virtual procedure for Linux emperor_black Linux - Software 1 11-29-2006 05:19 PM
Redhat 8.0 stalls on transferring install image to hard drive cgkitab Linux - Distributions 7 10-19-2002 06:37 PM


All times are GMT -5. The time now is 02:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration