Difference between revisions of "Transfer files from the host OS to the virtual drive"

From ReactOS Wiki
Jump to: navigation, search
(First write.. somebody do the VMware diskmount app too..)
 
 
(36 intermediate revisions by 14 users not shown)
Line 1: Line 1:
'''Intro.'''
+
Many users prefer to test ReactOS under emulators and virtualization software like QEMU or VMware, but for testing their software they will need to copy their files into the .iso images and add them into proper directories which can become a difficult job. A way around this is to mount the virtual hard drives as disk drives attached to the system itself (an alternative way might be to have a machine with FTP or HTTP server and use ReactOS ftp or iexplore to receive files).
Many users prefer to test ReactOS under emulators and virtualizers like QEMU or VMware. But for testing their software they will need to copy their files into the .iso images and add them into proper directories which can become a difficult job. A way around this is to mount the virtual hard drives as disk drives attached to the system itself. Which can be easily done using [http://chitchat.at.infoseek.co.jp/vmware/vdk.html VDK].
 
VDK (Virtual Disk Driver) can mount vmdk and raw format virtual drives which are supported by QEMU and VMware.
 
  
----
+
== In Windows==
  
*'''Getting the driver (VDK).'''
+
===ImDisk Virtual Disk Driver ===
You can download VDK from [http://chitchat.at.infoseek.co.jp/vmware/vdk.html here]. At the time of writing of this HOWTO the latest version is version 3.2 .
+
 
Download the .zip file and extract it to your desired folder using your favourite archiver. Suppose it is C:\VDK
+
[http://www.ltr-data.se/opencode.html#ImDisk Web Site]
( '''NOTE:''' All suppositions are meant for the tutorial only. You can use the desired locations.)
+
 
 +
ImDisk is a virtual disk driver for Windows NT/2000/XP/2003/Vista/2008. It can use one or more disk image files to create virtual hard disk, floppy or CD/DVD drives .The install package installs a console-mode control program called imdisk.exe and a Control Panel applet. After install is finished, type imdisk without parameters for syntax help or double click the ImDisk icon in the Control Panel. It also adds a menu item in Windows Explorer so that you can right-click on a file to mount it as a virtual disk drive. Users of mdconfig in FreeBSD will probably be familiar with the command line syntax of imdisk.exe. The driver, service and control program can be uninstalled using the Add/Remove programs applet in the Control Panel. No reboot is required for installing or uninstalling.
 +
 
 +
The install package also contains a user-mode helper service that enables the virtual disk driver to forward I/O requests to other computers on the network. This makes it possible to boot a machine with NTFS partitions with a *nix Live-CD and use the included  devio tool to let ImDisk on another computer running Windows on the network mount the NTFS partition on the machine you booted with the *nix Live-CD. This way you can recover information and even run chkdsk on drives on machines where Windows does not boot.
 +
 
 +
Simple mount example,
 +
 
 +
<code>
 +
imdisk -a -t vm -m #: -f C:\Users\%USERNAME%\.VirtualBox\HardDisks\Reactos.vdi
 +
</code>
 +
 
 +
=== VMware Disk Mount ===
 +
 
 +
*VMware Disk Mount Utility is easier to use but will work only with .vmdk files.(Official VMware virtual disk file format.)
 +
*[http://www.vmware.com/download/eula/diskmount_ws_v55.html Download] and install(*) the tool which is available at the [http://www.vmware.com VMware website]. It is part of [http://communities.vmware.com/community/vmtn/developer/forums/vddk Virtual Disk Development Kit (VDDK)].
 +
* Installation: To obtain the VMware disk mount utility, go to the VMware disk mount download website and accept the end user license agreement. After saying “Accept” to the EULA, you will be asked to save the setup file. Run this file and proceed with installation.
 +
*Start Command Prompt.
 +
*Move to the installation directory (e.g. C:\Program Files\VMware\VMware DiskMount Utility\ or "C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin")
 +
*'''Mounting the virtual drive.'''
 +
Issue the following command,
 +
vmware-mount z: C:\ReactOS\ReactOS.vmdk
 +
 
 +
What it does,
 +
vmware-mount - Starts the mount application.
 +
z:          - Drive letter for the mounted drive. (You can use any free drive letter.)
 +
...(Path)    - Path to the virtual disk drive.
 +
'''NOTE:'''  - The path above is an example. Use the path where you have saved your .vmdk file.
 +
 
 +
==== Unmounting the virtual drive ====
 +
 
 +
To unmount the virtual drive issue the following command,
 +
vmware-mount z: /d
  
*'''Setting up the driver.'''
 
**Open the command prompt and move to the folder where you have extracted VDK using cd command. eg. C:\VDK
 
**To install the driver itself ( vdk.sys ).
 
Issue the following command with the command prompt in the same directory,
 
vdk install
 
 
What it does,
 
What it does,
  vdk    - Starts the application.
+
  vmware-mount - Starts the mount application.
  install - Asks vdk to install the driver.
+
  z:          - Drive letter for the virtual drive to be unmounted.
 +
/d          - Unmounts the drive.
  
----
+
*More information on other options can be found in the '''VMware mount documentation'''.
  
*'''To start the driver.'''
+
===VDK===
Even though the driver is installed , it is'nt running.To start it issue the following command,
+
*VDK (Virtual Disk Driver) can mount vmdk and raw format virtual drives which are supported by QEMU and VMware.
 +
 
 +
==== Getting the driver (VDK) ====
 +
 
 +
You can download VDK from [http://web.archive.org/web/20071024105145/http://chitchat.at.infoseek.co.jp/vmware/vdk.html here] ([http://oss.netfarm.it/win32/ x64 here]). At the time of writing of this HOWTO the latest version is version 3.2. Download the .zip file and extract it to your desired folder using your favourite archiver.
 +
 
 +
==== Setup the driver ====
 +
 
 +
*Open the command prompt and move to the folder where you have extracted VDK using <code>cd</code> command (e.g. C:\VDK).
 +
*Issue the following command with the command prompt in the same directory,
 +
vdk install /auto
 +
 
 +
/AUTO Configures the driver to start at the system startup (Note: this option does not start the driver after installation is completed). By default the driver has to be started manually.
 +
 
 +
The Virtual Disk kernel-mode Driver (vdk.sys) is copied to %SYSTEMROOT%\system32, you may need administrator privileges to install the driver.
 +
 
 +
==== Start the Driver ====
 +
 
 +
Even though the driver is installed, it may not be actually running. To start it issue the following command,
 
  vdk start
 
  vdk start
What it does,
 
vdk    - Starts the application.
 
start  - Starts the driver (vdk.sys) itself.
 
  
----
+
If the driver is not already installed, this command attempts to install it with the default options. It is recommended that you use <code>vdk install /auto</code> so that you do not have to manually start the driver every time.
 +
 
 +
==== Mounting the virtual drive ====
 +
 
 +
SYNTAX:
 +
  VDK.EXE OPEN disk# image [/RW | /WB | /UNDO] [/P:part#] [/L:drive]
  
*'''Mounting the virtual drive.'''
+
OPTIONS:
Again, suppose you have the virtual drive in C:\ReactOS\ReactOS.vmdk or ReactOS.img (raw) .
+
  disk#    Specifies the virtual disk number. This must be the first parameter. '*' means the first available disk, and if all existing disk is busy a new virtual disk is created.
In the vdk directory issue the following command,
+
  image    Specifies the path to the disk image file. This must be the second parameter.
vdk open * C:\ReactOS\ReactOS.vmdk /rw
+
  /RW      Open the image in Read-Write mode.
 +
  /WB      Open the image in Write-Block mode.
 +
  /UNDO    Creates a REDO log for the image and open in Read-Write mode.
 +
  /P:part#  Specifies a partition number to set a drive letter. Drive letters can be set/removed later with LINK/ULINK commands. By default, drive letters are assigned to all mountable partitions.
 +
  /L:drive  Specifies drive letters to assign to partitions.By default, the first available drive letter is used.
  
What it is doing,
+
Only one of /RW, /WB and /UNDO can be used at a time.
vdk  - Starts the application.
+
When none of these is specified, the image is opened in Read-Only mode.
open - Initiates the command to mount the virtual drive.
 
*    - Mounts the virtual drive to the first available drive letter.
 
.... - It is followed by the path to the virtual drive. ( ReactOS.vmdk or ReactOS.img)
 
/rw  - This option mounts the drive with read as well as write support.
 
  
*Then the drive is properly mounted. And you can copy the required files as usual.
+
*Example of Vdk usage
 +
In the vdk directory issue the following command,
 +
vdk open * C:\ReactOS\ReactOS.vmdk /rw
  
----
+
==== Unmounting the virtual drive ====
  
*'''Unmounting the virtual drive.'''
+
Once you are done using the virtual drive it needs to be unmounted. This is done by issuing the following command,
Once done the virtual drive needs to be unmounted. It will save the files to the virtual hard disk eg.ReactOS.vmdk or ReactOS.img . This is done by issuing the following command in the vdk directory,
 
 
  vdk close *  
 
  vdk close *  
  
What it does,
+
Failure to do this will result in the drive being locked and usable to VMware or QEMU.
vdk  - Starts the application itself.
 
close - Initiates unmount.
 
*    - Unmounts all mounted virtual drives.
 
 
 
* Once this is done the files will be available in the virtual hard drive.
 
  
----
+
==== Stopping the driver ====
  
*'''Stoping the driver.'''
 
 
If you want you can stop the driver using,
 
If you want you can stop the driver using,
 
  vdk stop
 
  vdk stop
  
----
 
 
More details and options are available in the '''Readme.txt''' in the previously downloaded .zip file.
 
More details and options are available in the '''Readme.txt''' in the previously downloaded .zip file.
  
----
+
== Linux ==
 +
 
 +
=== Mounting a VirtualBox (.vdi) image ===
 +
* Receipt 1, Using ''qemu-nbd'' of '''qemu-kvm''' package + ''nbd'':
 +
[http://bethesignal.org/blog/2011/01/05/how-to-mount-virtualbox-vdi-image/ How to mount a VirtualBox VDI image]
 +
 
 +
Note: Requires qemu version >= 0.14 to be able mount the disk partitions, reactos' first partition here will be /dev/nbd0p1 with FAT.
 +
<pre>
 +
modprobe nbd
 +
#mount whole device
 +
qemu-nbd -c /dev/nbd0 ./ReactOS.vdi
 +
##it is possible to do: fdisk /dev/nbd0
 +
#but use only first partition:
 +
mount -t vfat /dev/nbd0p1 /mnt/ros
 +
 
 +
#unmount devices:
 +
umount /mnt/ros
 +
qemu-nbd -d /dev/nbd0
 +
</pre>
 +
* Receipt 2, Using vdfuse:
 +
[http://www.ubuntugeek.com/how-to-mount-virtualbox-drive-image-vdi-in-ubuntu-12-1012-04.html How to mount VirtualBox drive image (vdi) in Ubuntu 12.10/12.04]
 +
Based on '''virtualbox-fuse''' package
 +
 
 +
Or, using '''libguestfs''' / '''libguestfs-mount''' packages for rpm-based Linuces:
 +
 
 +
[http://forums.opensuse.org/english/get-technical-help-here/virtualization/469942-mounting-virtual-box-machine-images-host.html Mounting Virtual Box Machine Images on a Host]
 +
 
 +
* Receipt no.3, trick with vdi format, minimal requirements: mount using loop device:
 +
[http://www.mimamau.de/stuff/mount_vdi_linux.htm How to mount VirtualBox VDI image files on Linux]
 +
<pre>OFFSET1=`VBoxManage internalcommands dumphdinfo ./ReactOS.vdi |grep "offData="|sed "s#.*offData=\([0-9]\+\)#\1#"`
 +
OFFSET=$((32256+$OFFSET1))
 +
mount ./ReactOS.vdi /mnt/ros -o loop,offset=$OFFSET
 +
</pre>
 +
 
 +
Here magic number 32256 is 63*512, i.e. offset of first partition start on hard disk (historically and normally offset of 63 sectors = offset of partition from start of corresponding [http://en.wikipedia.org/wiki/Master_boot_record MBR] or, in other case of extended partition [http://en.wikipedia.org/wiki/Volume_Boot_Record VBR]). Debugging the [[FreeLoader]] may require changes on boot record and it is accessible through offset 0 instead this magic 63*512.
 +
 
 +
=== Mounting a QEMU image ===
 +
 
 +
Most Linux distributions allow you to mount virtual disk images using the <code>mount</code> command. Ubuntu is used in this example, but it should work in most distributions.
 +
 
 +
For most of these actions you will need root access, so use the <code>sudo</code> command. You will need to enter a password for this.
 +
First you need to create a mounting directory,
 +
sudo mkdir /media/ReactOS
 +
 
 +
Then, make sure your virtual image file is in RAW format. I created my image in QEMU Launcher, where you can select this format. If your image is in QCOW format, you can use the following command to convert to RAW,
 +
qemu-img convert <image-file> -O raw <image-file.raw>
 +
 
 +
After this is done, you can mount the image,
 +
sudo mount -o loop,offset=32256 <image-file> /media/ReactOS -t vfat
 +
 
 +
When you are done using the image file, you can unmount it easily by using,
 +
sudo umount /media/ReactOS
 +
 
 +
* '''http://linuxcommand.org/man_pages/losetup8.html'''
 +
 
 +
==See also==
 +
* [[Using shared folders]]
 +
* [[Using NFS]]
 +
 
 +
* [http://www.vladan.fr/mounting-your-vmdk-disks-directly-to-your-windows-box-how-to/ Stepwise Instructions on installation and running VMware Workstation 5.5 Disk Mount Utility]
 +
 
 +
[[Category:Tutorial]]

Latest revision as of 07:57, 3 August 2017

Many users prefer to test ReactOS under emulators and virtualization software like QEMU or VMware, but for testing their software they will need to copy their files into the .iso images and add them into proper directories which can become a difficult job. A way around this is to mount the virtual hard drives as disk drives attached to the system itself (an alternative way might be to have a machine with FTP or HTTP server and use ReactOS ftp or iexplore to receive files).

In Windows

ImDisk Virtual Disk Driver

Web Site

ImDisk is a virtual disk driver for Windows NT/2000/XP/2003/Vista/2008. It can use one or more disk image files to create virtual hard disk, floppy or CD/DVD drives .The install package installs a console-mode control program called imdisk.exe and a Control Panel applet. After install is finished, type imdisk without parameters for syntax help or double click the ImDisk icon in the Control Panel. It also adds a menu item in Windows Explorer so that you can right-click on a file to mount it as a virtual disk drive. Users of mdconfig in FreeBSD will probably be familiar with the command line syntax of imdisk.exe. The driver, service and control program can be uninstalled using the Add/Remove programs applet in the Control Panel. No reboot is required for installing or uninstalling.

The install package also contains a user-mode helper service that enables the virtual disk driver to forward I/O requests to other computers on the network. This makes it possible to boot a machine with NTFS partitions with a *nix Live-CD and use the included devio tool to let ImDisk on another computer running Windows on the network mount the NTFS partition on the machine you booted with the *nix Live-CD. This way you can recover information and even run chkdsk on drives on machines where Windows does not boot.

Simple mount example,

imdisk -a -t vm -m #: -f C:\Users\%USERNAME%\.VirtualBox\HardDisks\Reactos.vdi

VMware Disk Mount

  • VMware Disk Mount Utility is easier to use but will work only with .vmdk files.(Official VMware virtual disk file format.)
  • Download and install(*) the tool which is available at the VMware website. It is part of Virtual Disk Development Kit (VDDK).
  • Installation: To obtain the VMware disk mount utility, go to the VMware disk mount download website and accept the end user license agreement. After saying “Accept” to the EULA, you will be asked to save the setup file. Run this file and proceed with installation.
  • Start Command Prompt.
  • Move to the installation directory (e.g. C:\Program Files\VMware\VMware DiskMount Utility\ or "C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin")
  • Mounting the virtual drive.

Issue the following command,

vmware-mount z: C:\ReactOS\ReactOS.vmdk

What it does,

vmware-mount - Starts the mount application.
z:           - Drive letter for the mounted drive. (You can use any free drive letter.)
...(Path)    - Path to the virtual disk drive. 
NOTE:  - The path above is an example. Use the path where you have saved your .vmdk file.

Unmounting the virtual drive

To unmount the virtual drive issue the following command,

vmware-mount z: /d

What it does,

vmware-mount - Starts the mount application.
z:           - Drive letter for the virtual drive to be unmounted.
/d           - Unmounts the drive.
  • More information on other options can be found in the VMware mount documentation.

VDK

  • VDK (Virtual Disk Driver) can mount vmdk and raw format virtual drives which are supported by QEMU and VMware.

Getting the driver (VDK)

You can download VDK from here (x64 here). At the time of writing of this HOWTO the latest version is version 3.2. Download the .zip file and extract it to your desired folder using your favourite archiver.

Setup the driver

  • Open the command prompt and move to the folder where you have extracted VDK using cd command (e.g. C:\VDK).
  • Issue the following command with the command prompt in the same directory,
vdk install /auto

/AUTO Configures the driver to start at the system startup (Note: this option does not start the driver after installation is completed). By default the driver has to be started manually.

The Virtual Disk kernel-mode Driver (vdk.sys) is copied to %SYSTEMROOT%\system32, you may need administrator privileges to install the driver.

Start the Driver

Even though the driver is installed, it may not be actually running. To start it issue the following command,

vdk start

If the driver is not already installed, this command attempts to install it with the default options. It is recommended that you use vdk install /auto so that you do not have to manually start the driver every time.

Mounting the virtual drive

SYNTAX:

 VDK.EXE OPEN disk# image [/RW | /WB | /UNDO] [/P:part#] [/L:drive]

OPTIONS:

 disk#     Specifies the virtual disk number. This must be the first parameter. '*' means the first available disk, and if all existing disk is busy a new virtual disk is created.
 image     Specifies the path to the disk image file. This must be the second parameter.
 /RW       Open the image in Read-Write mode.
 /WB       Open the image in Write-Block mode.
 /UNDO     Creates a REDO log for the image and open in Read-Write mode.
 /P:part#  Specifies a partition number to set a drive letter. Drive letters can be set/removed later with LINK/ULINK commands. By default, drive letters are assigned to all mountable partitions.
 /L:drive  Specifies drive letters to assign to partitions.By default, the first available drive letter is used.

Only one of /RW, /WB and /UNDO can be used at a time. When none of these is specified, the image is opened in Read-Only mode.

  • Example of Vdk usage

In the vdk directory issue the following command,

vdk open * C:\ReactOS\ReactOS.vmdk /rw

Unmounting the virtual drive

Once you are done using the virtual drive it needs to be unmounted. This is done by issuing the following command,

vdk close * 

Failure to do this will result in the drive being locked and usable to VMware or QEMU.

Stopping the driver

If you want you can stop the driver using,

vdk stop

More details and options are available in the Readme.txt in the previously downloaded .zip file.

Linux

Mounting a VirtualBox (.vdi) image

  • Receipt 1, Using qemu-nbd of qemu-kvm package + nbd:

How to mount a VirtualBox VDI image

Note: Requires qemu version >= 0.14 to be able mount the disk partitions, reactos' first partition here will be /dev/nbd0p1 with FAT.

modprobe nbd
#mount whole device
qemu-nbd -c /dev/nbd0 ./ReactOS.vdi 
##it is possible to do: fdisk /dev/nbd0
#but use only first partition:
mount -t vfat /dev/nbd0p1 /mnt/ros

#unmount devices:
umount /mnt/ros
qemu-nbd -d /dev/nbd0
  • Receipt 2, Using vdfuse:

How to mount VirtualBox drive image (vdi) in Ubuntu 12.10/12.04 Based on virtualbox-fuse package

Or, using libguestfs / libguestfs-mount packages for rpm-based Linuces:

Mounting Virtual Box Machine Images on a Host

  • Receipt no.3, trick with vdi format, minimal requirements: mount using loop device:

How to mount VirtualBox VDI image files on Linux

OFFSET1=`VBoxManage internalcommands dumphdinfo ./ReactOS.vdi |grep "offData="|sed "s#.*offData=\([0-9]\+\)#\1#"`
OFFSET=$((32256+$OFFSET1))
mount ./ReactOS.vdi /mnt/ros -o loop,offset=$OFFSET

Here magic number 32256 is 63*512, i.e. offset of first partition start on hard disk (historically and normally offset of 63 sectors = offset of partition from start of corresponding MBR or, in other case of extended partition VBR). Debugging the FreeLoader may require changes on boot record and it is accessible through offset 0 instead this magic 63*512.

Mounting a QEMU image

Most Linux distributions allow you to mount virtual disk images using the mount command. Ubuntu is used in this example, but it should work in most distributions.

For most of these actions you will need root access, so use the sudo command. You will need to enter a password for this. First you need to create a mounting directory,

sudo mkdir /media/ReactOS

Then, make sure your virtual image file is in RAW format. I created my image in QEMU Launcher, where you can select this format. If your image is in QCOW format, you can use the following command to convert to RAW,

qemu-img convert <image-file> -O raw <image-file.raw>

After this is done, you can mount the image,

sudo mount -o loop,offset=32256 <image-file> /media/ReactOS -t vfat

When you are done using the image file, you can unmount it easily by using,

sudo umount /media/ReactOS

See also