It’s been a while since I last had to run Windows on my laptop; back then I used Ext2 Installable File System For Windows to access data on my Linux-formated partitions.
In the meantime a few things have changed: Windows 7 and Ubuntu formating ext3 with a inode size of 256 – none of these are supported by ext3 ifs.
Ext2read supports Windows 7 (as well as ext4 and LVM2) but it’s more like a file browser and does not support assigning drive letters to Linux filesystems and since my /home is formatted with XFS it does not help me anyway.
Instead of going through reformatting the filesystems I wanted to access from Windows, I decided to build a virtual file server instead; that way I can access any filesystem type supported by Linux.
This guide will work with other versions of Windows (and other OS’es as well), there are no ties to Virtualbox and the Linux version used can be anyone you like.
Installing Virtualbox is a straight forward deal, accept the defaults and you are good to go. Once installed, it’s a good idea to record the IP of the host-only network adaptor, because you are going to use it later.
Start Virtualbox (if you have used the default installer settings, it should be started already), go to “File” and then “Preferences”, select “Network” and double-click the “Virtual Host-Only Ethernet Adapter” – The IP address of the adapter is right there.
Configure the virtual machine
Simply press “New” and walk through the wizard. Select Linux as operating system and either 32 or 64 bit Ubuntu depending on what you plan to install – The defaults should be fine.
This is where it becomes a bit tricky. We need to access a raw disk and this is a bit tricky. Apparently only administrator can access disks directly and Virtualbox has no way of asking UAC for privilege escalation.
To possible solutions: 1) is to run Virtualbox and needed commands as administrator 2) Disable UAC. Personally I went for option 2.
Mapping the raw disk
In order to access the raw disk (or disk partition) from inside the virtual machine, we need to map it to a virtual disk file (VDI).
Open a command prompt (remember to use “run as administrator” if you have not disabled UAC) and run these commands
First, let’s figure out which partition(s) you wish to access
> cd "\Program Files\Oracle\VirtualBox"
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands listpartitions -rawdisk \\.\PhysicalDrive0
Number Type StartCHS EndCHS Size (MiB) Start (Sect)
1 0x07 0 /32 /33 1023/254/63 35000 2048
2 0x83 1023/254/63 1023/254/63 25000 71682048
5 0x82 1023/254/63 1023/254/63 4800 122884096
6 0x83 1023/254/63 1023/254/63 412137 132716544
In my example, I only wish to access partition 6 (normally mounted as /home in Linux); now let’s map it
RAW host disk access VMDK file \path\to\filename.vdi created successfully.
Open VirtualBox again (if you have UAC enabled, open VirtualBox as administrator; for some reason this screws up the USB stuff in VirtualBox) – click the virtual machine, and then “storage”, select the SATA device and click “add harddisk”, click “Use existing disk” and then browse to your VDI that you create before.
Adding a second network interface
To ease administration, we’ll add a second, host-only network interface card to the VM
- Select the virtual machine
- Scroll the right window down, and click network
- Click tab “Adapter 2″, enable it and select “Attached to: Host-only Adapter”
After downloading Ubuntu, use the downloaded ISO in VirtualBox and boot the Ubuntu installer. Choose your language and keymap in the boot loader and then select “Install Ubuntu Server”.
The installation will now be on it’s merry way.
- Add a user for you
- Enter proxy details
- Configure updates (since this is a “background server” I recommend automatic)
- Software selection: Select at least “Samba server” and “OpenSSH server”
- Configure grub-pc: Enter /dev/sda as destination
- Configure system clock (normally not UTC)
Finishing setting up the virtual machine
When the machine has first booted, log in as the user you created during installation.
Configure host-only network
Edit the file /etc/network/interfaces and add
iface eth1 inet static
address 192.168.56.10 # substitute this with one matching your network settings, recorded earlier
and then run the command sudo ifup eth1 – You are now able to ssh into you virtual machine, using the IP address entered.
Samba is the standard Windows interoperability suite of programs for Linux and Unix.
Why use it to have the Linux server act as a fileserver for the Windows host, allowing us to access files on the disks attached to the VM and, since it’s using standard Windows protocols, we will be able to map the shares on the VM to drive letters on the Windows host.
Luckily Samba just works, out of the box. The only things I changed, in /etc/samba/smb.conf was
read only = no
valid users = %S
the rest of the parameters for [homes] was left as is.
Auto-starting the virtual machine
Program/script: “C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe”
Arguments: -s VMName -v
Start in: “C:\Program Files\Oracle\VirtualBox
That should be it. You could install Vbox Additions, but unless you plan on accessing data on the Windows host from the VM, there is no need.