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

From ReactOS Wiki
Jump to: navigation, search
Line 11: Line 11:
 
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.
 
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>
 
<code>
ImDisk Virtual Disk Driver
+
imdisk -a -t vm -m #: -f C:\Users\encoded\.VirtualBox\HardDisks\reactos.vdi
 
 
imdisk -a -t type -m mountpoint [-n] [-o opt1[,opt2 ...]] [-f|-F file]
 
      [-s size] [-b offset] [-S sectorsize] [-u unit] [-x sectors/track]
 
      [-y tracks/cylinder] [-p "format-parameters"]
 
imdisk -d [-u unit | -m mountpoint]
 
imdisk -l [-u unit | -m mountpoint]
 
imdisk -e [-s size] [-o opt1[,opt2 ...]] [-u unit | -m mountpoint]
 
 
 
-a      Attach a virtual disk. This will configure and attach a virtual disk
 
        with the parameters specified and attach it to the system.
 
 
 
-d      Detach a virtual disk from the system and release all resources.
 
 
 
-e      Edit an existing virtual disk.
 
 
 
        Along with the -s parameter extends the size of an existing virtual
 
        disk. Note that even if the disk can be extended successfully, the
 
        existing filesystem on it can only be extended to fill the new size
 
        without re-formatting if you are running Windows 2000 or later and the
 
        current filesystem is NTFS.
 
 
 
        Along with the -o parameter changes media characteristics for an
 
        existing virtual disk. Options that can be changed on existing virtual
 
        disks are those specifying wether or not the media of the virtual disk
 
        should be writable and/or removable.
 
 
 
-t type
 
        Select the backingstore for the virtual disk.
 
 
 
vm      Storage for this type of virtual disk is allocated from virtual memory
 
        in the system process. If a file is specified with -f that file is
 
        is loaded into the memory allocated for the disk image.
 
 
 
file    A file specified with -f file becomes the backingstore for this
 
        virtual disk.
 
 
 
proxy  The actual backingstore for this type of virtual disk is controlled by
 
        an ImDisk storage server accessed by the driver on this machine by
 
        sending storage I/O request through a named pipe specified with -f.
 
 
 
-f file or -F file
 
        Filename to use as backingstore for the file type virtual disk, to
 
        initialize a vm type virtual disk or name of a named pipe for I/O
 
        client/server communication for proxy type virtual disks. For proxy
 
        type virtual disks "file" may be a COM port or a remote server
 
        address if the -o options includes "ip" or "comm".
 
 
 
        Instead of using -f to specify 'DOS-style' paths, such as
 
        C:\dir\image.bin or \\server\share\image.bin, you can use -F to
 
        specify 'NT-style' native paths, such as
 
        \Device\Harddisk0\Partition1\image.bin. This makes it possible to
 
        specify files on disks or communication devices that currently have no
 
        drive letters assigned.
 
 
 
-l      List configured devices. If given with -u or -m, display details about
 
        that particular device.
 
 
 
-n      When printing ImDisk device names, print only the unit number without
 
        the \Device\ImDisk prefix.
 
 
 
-s size
 
        Size of the virtual disk. Size is number of bytes unless suffixed with
 
        a b, k, m, g, t, K, M, G or T which denotes number of 512-byte blocks,
 
        thousand bytes, million bytes, billion bytes, trillion bytes,
 
        kilobytes, megabytes, gigabytes and terabytes respectively. The suffix
 
        can also be % to indicate percentage of free physical memory which
 
        could be useful when creating vm type virtual disks. It is optional to
 
        specify a size unless the file to use for a file type virtual disk does
 
        not already exist or when a vm type virtual disk is created without
 
        specifying an initialization image file using the -f or -F. If size is
 
        specified when creating a file type virtual disk, the size of the file
 
        used as backingstore for the virtual disk is adjusted to the new size
 
        specified with this size option.
 
 
 
        The size can be a negative value to indicate the size of free physical
 
        memory minus this size. If you e.g. type -400M the size of the virtual
 
        disk will be the amount of free physical memory minus 400 MB.
 
 
 
-b offset
 
        Specifies an offset in an image file where the virtual disk begins. All
 
        offsets of I/O operations on the virtual disk will be relative to this
 
        offset. This parameter is particularily useful when mounting a specific
 
        partition in an image file that contains an image of a complete hard
 
        disk, not just one partition. This parameter has no effect when
 
        creating a blank vm type virtual disk. When creating a vm type virtual
 
        disk with a pre-load image file specified with -f or -F paramters, the
 
        -b parameter specifies an offset in the image file where the image to
 
        be loaded into the vm type virtual disk begins.
 
 
 
-S sectorsize
 
        Sectorsize to use for the virtual disk device. Default value is 512
 
        bytes except for CD-ROM/DVD-ROM style devices where 2048 bytes is used
 
        by default.
 
 
 
-x sectors/track
 
        See the description of the -y option below.
 
 
 
-y tracks/cylinder
 
        The -x and -y options can be used to specify a synthetic geometry.
 
        This is useful for constructing bootable images for later download to
 
        physical devices. Default values depends on the device-type specified
 
        with the -o option. If the 'fd' option is specified the default values
 
        are based on the virtual disk size, e.g. a 1440K image gets 2
 
        tracks/cylinder and 18 sectors/track.
 
 
 
-p "format-parameters"
 
        If -p is specified the 'format' command is invoked to create a
 
        filesystem when the new virtual disk has been created.
 
        "format-parameters" must be a parameter string enclosed within
 
        double-quotes. The string is added to the command line that starts
 
        'format'. You usually specify something like "/fs:ntfs /q /y", that
 
        is, create an NTFS filesystem with quick formatting and without user
 
        interaction.
 
 
 
-o option
 
        Set or reset options.
 
 
 
ro      Creates a read-only virtual disk. For vm type virtual disks, this
 
        option can only be used if the -f option is also specified.
 
 
 
rw      Specifies that the virtual disk should be read/writable. This is the
 
        default setting. It can be used with the -e parameter to set an
 
        existing read-only virtual disk writable.
 
 
 
rem    Specifies that the device should be created with removable media
 
        characteristics. This changes the device properties returned by the
 
        driver to the system. For example, this changes how some filesystems
 
        cache write operations.
 
 
 
fix    Specifies that the media characteristics of the virtual disk should be
 
        fixed media, as opposed to removable media specified with the rem
 
        option. Fixed media is the default setting. The fix option can be used
 
        with the -e parameter to set an existing removable virtual disk as
 
        fixed.
 
 
 
        Note that virtual floppy or CD/DVD-ROM drives are always read-only and
 
        removable devices and that can not be changed.
 
 
 
cd      Creates a virtual CD-ROM/DVD-ROM. This is the default if the file
 
        name specified with the -f option ends with either .iso or .bin
 
        extensions.
 
 
 
fd      Creates a virtual floppy disk. This is the default if the size of the
 
        virtual disk is any of 160K, 180K, 320K, 360K, 640K, 720K, 820K, 1200K,
 
        1440K, 1680K, 1722K, 2880K, 123264K or 234752K.
 
 
 
hd      Creates a virtual fixed disk partition. This is the default unless
 
        file extension or size match the criterias for defaulting to the cd or
 
        fd options.
 
 
 
ip      Can only be used with proxy-type virtual disks. With this option, the
 
        user-mode service component is initialized to connect to an ImDisk
 
        storage server using TCP/IP. With this option, the -f switch specifies
 
        the remote host optionally followed by a colon and a port number to
 
        connect to.
 
 
 
comm    Can only be used with proxy-type virtual disks. With this option, the
 
        user-mode service component is initialized to connect to an ImDisk
 
        storage server through a COM port. With this option, the -f switch
 
        specifies the COM port to connect to, optionally followed by a colon,
 
        a space, and then a device settings string with the same syntax as the
 
        MODE command.
 
 
 
-u unit
 
        Along with -a, request a specific unit number for the ImDisk device
 
        instead of automatic allocation. Along with -d or -l specifies the
 
        unit number of the virtual disk to remove or query.
 
 
 
-m mountpoint
 
        Specifies a drive letter or mount point for the new virtual disk, the
 
        virtual disk to query or the virtual disk to remove. When creating a
 
        new virtual disk you can specify #: as mountpoint in which case the
 
        first unused drive letter is automatically used.
 
 
</code>
 
</code>
 
== VMware Disk Mount ==
 
== VMware Disk Mount ==

Revision as of 20:17, 28 November 2009

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.

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\encoded\.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.
  • Start Command Prompt.
  • Move to the installation directory (e.g. C:\Program Files\VMware\VMware DiskMount Utility\)
  • 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 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

http://linuxcommand.org/man_pages/losetup8.html