/usr/share/doc/user-mode-linux-doc/html/UserModeLinux-HOWTO-9.html is in user-mode-linux-doc 20060501-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
<TITLE>User Mode Linux HOWTO : Host file access</TITLE>
<LINK HREF="UserModeLinux-HOWTO-10.html" REL=next>
<LINK HREF="UserModeLinux-HOWTO-8.html" REL=previous>
<LINK HREF="UserModeLinux-HOWTO.html#toc9" REL=contents>
</HEAD>
<BODY>
<A HREF="UserModeLinux-HOWTO-10.html">Next</A>
<A HREF="UserModeLinux-HOWTO-8.html">Previous</A>
<A HREF="UserModeLinux-HOWTO.html#toc9">Contents</A>
<HR>
<H2><A NAME="hostfs"></A> <A NAME="s9">9.</A> <A HREF="UserModeLinux-HOWTO.html#toc9">Host file access</A></H2>
<P>
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.</P>
<P>
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.</P>
<P>
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.</P>
<H2><A NAME="ss9.1">9.1</A> <A HREF="UserModeLinux-HOWTO.html#toc9.1">Using hostfs</A>
</H2>
<P>To begin with, make sure that hostfs is available inside the virtual
machine with
<BLOCKQUOTE><CODE>
<PRE>
UML# cat /proc/filesystems
</PRE>
</CODE></BLOCKQUOTE>
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.</P>
<P>
Now all you need to do is run mount:
<BLOCKQUOTE><CODE>
<PRE>
UML# mount none /mnt/host -t hostfs
</PRE>
</CODE></BLOCKQUOTE>
will mount the host's / on the virtual machine's /mnt/host.</P>
<P>
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:
<BLOCKQUOTE><CODE>
<PRE>
UML# mount none /mnt/home -t hostfs -o /home
</PRE>
</CODE></BLOCKQUOTE>
will mount the hosts's /home on the virtual machine's /mnt/home.</P>
<H2><A NAME="ss9.2">9.2</A> <A HREF="UserModeLinux-HOWTO.html#toc9.2">hostfs command line options</A>
</H2>
<P>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
<BLOCKQUOTE><CODE>
<PRE>
hostfs=directory,options
</PRE>
</CODE></BLOCKQUOTE>
The only option available at present is 'append', which forces all
files to be opened in append mode and disallows any deletion of files.</P>
<P>
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:
<BLOCKQUOTE><CODE>
<PRE>
hostfs=,append
</PRE>
</CODE></BLOCKQUOTE>
</P>
<H2><A NAME="ss9.3">9.3</A> <A HREF="UserModeLinux-HOWTO.html#toc9.3">hostfs as the root filesystem</A>
</H2>
<P>It's possible to boot from a directory hierarchy on the host using hostfs
rather than using the standard filesystem in a file.</P>
<P> To start, you need that hierarchy. The easiest way is to loop mount an
existing root_fs file:
<BLOCKQUOTE><CODE>
<PRE>
host# mount root_fs uml_root_dir -o loop
</PRE>
</CODE></BLOCKQUOTE>
You need to change the filesystem type of / in etc/fstab to be 'hostfs', so
that line looks like this:
<BLOCKQUOTE><CODE>
<PRE>
none / hostfs defaults 1 1
</PRE>
</CODE></BLOCKQUOTE>
Then you need to chown to yourself all the files in that directory that are
owned by root. This worked for me:
<BLOCKQUOTE><CODE>
<PRE>
host# find . -uid 0 -exec chown jdike {} \;
</PRE>
</CODE></BLOCKQUOTE>
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.</P>
<P>
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:
<BLOCKQUOTE><CODE>
<PRE>
root=/dev/root rootflags=/path/to/uml/root rootfstype=hostfs
</PRE>
</CODE></BLOCKQUOTE>
UML should then boot as it does normally.</P>
<H2><A NAME="ss9.4">9.4</A> <A HREF="UserModeLinux-HOWTO.html#toc9.4">Building hostfs</A>
</H2>
<P>If you need to build hostfs because it's not in your kernel, you have
two choices:</P>
<P>
<UL>
<LI>Compiling hostfs into the kernel: <P>
Reconfigure the kernel and set the 'Host filesystem' option under
'Processor features' to 'Y'. Recompile the kernel and reboot it.</P>
</LI>
<LI>Compiling hostfs as a module: <P>
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
<BLOCKQUOTE><CODE>
<PRE>
UML# insmod hostfs
</PRE>
</CODE></BLOCKQUOTE>
</P>
</LI>
</UL>
</P>
<HR>
<A HREF="UserModeLinux-HOWTO-10.html">Next</A>
<A HREF="UserModeLinux-HOWTO-8.html">Previous</A>
<A HREF="UserModeLinux-HOWTO.html#toc9">Contents</A>
</BODY>
</HTML>
|