Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 50 lines (40 sloc) 1.866 kb
#!/usr/bin/python3.3 -S
import os, subprocess, urllib.parse, tempfile
unquote = urllib.parse.unquote
subprocess.check_call('mount -t proc proc /proc'.split())
subprocess.check_call('mount -t sysfs sysfs /sys'.split())
subprocess.check_call('mount -t tmpfs tmpfs /run'.split())
# Or set CONFIG_DEVTMPFS_MOUNT'mount -t devtmpfs devtmpfs /dev'.split())
# At least the Debian and Ubuntu package uses this
'mount -t hostfs -o /usr/lib/uml/modules hostfs /lib/modules'.split(),
uml_env = os.environ['UML_ENV']
uml_cmd = os.environ['UML_CMD']
uml_cmd = [unquote(arg) for arg in uml_cmd.split('+')]
uml_env = {unquote(var): unquote(val) for (var, val) in
(item.split('=', 1) for item in uml_env.split(';'))}
cwd = uml_env['PWD']
if 'UML_RWDIRS' in os.environ:
rw_dirs = os.environ['UML_RWDIRS']
rw_dirs = [unquote(arg) for arg in rw_dirs.split(':')]
for dn in rw_dirs:
tdn = tempfile.mkdtemp()
subprocess.check_call('mount -t tmpfs tmpfs --'.split() + [tdn])
if True:
# XXX Make this best-effort, some files may not be readable['cp', '-aT', '--', dn, tdn], stderr=subprocess.DEVNULL)
subprocess.check_call(['mount', '--move', '--', tdn, dn])
elif False:
# Requires overlayfs
'mount -t overlayfs overlayfs'.split()
+ ['-olowerdir={},upperdir={}'.format(dn, tdn), dn])
if 'UML_CLEARDIRS' in os.environ:
clear_dirs = os.environ['UML_CLEARDIRS']
clear_dirs = [unquote(arg) for arg in clear_dirs.split(':')]
for dn in clear_dirs:
subprocess.check_call('mount -t tmpfs tmpfs --'.split() + [dn])
subprocess.check_call(uml_cmd, cwd=cwd, env=uml_env)
subprocess.check_call('/sbin/halt -f'.split())
Jump to Line
Something went wrong with that request. Please try again.