| Host file access If you want to access files on the host machine from inside UML, you can treat it as a separate machine and either nfs mount directories from the host or copy files into the virtual machine with scp or rcp. However, since UML is running on the the host, it can access those files just like any other process and make them available inside the virtual machine without needing to use the network. This is now possible with the hostfs virtual filesystem. With it, you can mount a host directory into the UML filesystem and access the files contained in it just as you would on the host. Note that hostfs is currently not available on 2.5. The reason is that there was an fs.h rework early in 2.5 which required filesystem changes, and I haven't got around to updating hostfs to those changes. To begin with, make sure that hostfs is available inside the virtual machine with UML# cat /proc/filesystems hostfs should be listed. If it's not, either rebuild the kernel with hostfs configured into it or make sure that hostfs is built as a module and available inside the virtual machine, and insmod it. Now all you need to do is run mount: UML# mount none /mnt/host -t hostfs will mount the host's / on the virtual machine's /mnt/host. If you don't want to mount the host root directory, then you can specify a subdirectory to mount with the -o switch to mount: UML# mount none /mnt/home -t hostfs -o /home will mount the hosts's /home on the virtual machine's /mnt/home. hostfs command line options | There is a hostfs option available on the UML command line which can be used confine all hostfs mounts to a host directory hierarchy or to prevent a hostfs user from destroying data on the host. The format is hostfs=directory,options The only option available at present is 'append', which forces all files to be opened in append mode and disallows any deletion of files. To specify append mode without confining hostfs to a host directory, just leave out the directory name so that the argument begins with a comma: hostfs=,append hostfs as the root filesystem | It's possible to boot from a directory hierarchy on the host using hostfs rather than using the standard filesystem in a file. To start, you need that hierarchy. The easiest way is to loop mount an existing root_fs file: host# mount root_fs uml_root_dir -o loop You need to change the filesystem type of / in etc/fstab to be 'hostfs', so that line looks like this: none / hostfs defaults 1 1 Then you need to chown to yourself all the files in that directory that are owned by root. This worked for me: host# find . -uid 0 -exec chown jdike {} \; If you don't want to do that because that's a filesystem image that you boot as a disk, then run UML as root instead. Next, make sure that your UML kernel has hostfs compiled in, not as a module. Then run UML with the following arguments added to the command line: root=/dev/root rootflags=/path/to/uml/root rootfstype=hostfs UML should then boot as it does normally. If you need to build hostfs because it's not in your kernel, you have two choices: - Compiling hostfs into the kernel:
Reconfigure the kernel and set the 'Host filesystem' option under 'Processor features' to 'Y'. Recompile the kernel and reboot it. - Compiling hostfs as a module:
Reconfigure the kernel and set the 'Host filesystem' option under 'Processor features' to 'M'. Rebuild the kernel modules. hostfs will be in arch/um/fs/hostfs/hostfs.o. Install that in /lib/modules/`uname -r`/fs in the virtual machine, boot it up, and UML# insmod hostfs |