|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#######
#
# E-scripts on chrooting to another linux system.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
# (find-eev-quick-intro)
# http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/chroot.e>
# or at <http://angg.twu.net/e/chroot.e.html>.
# See also <http://angg.twu.net/emacs.html>,
# <http://angg.twu.net/.emacs[.html]>,
# <http://angg.twu.net/.zshrc[.html]>,
# <http://angg.twu.net/escripts.html>,
# and <http://angg.twu.net/>.
#
#######
# «.rootstrap» (to "rootstrap")
# «.loop-debootstrap» (to "loop-debootstrap")
# «.inittab» (to "inittab")
# «.invoking» (to "invoking")
# «.kernel-patch-skas» (to "kernel-patch-skas")
# «.kernel-patch-uml» (to "kernel-patch-uml")
#####
#
# stopping the servers on the host
# 2004dec24
#
#####
# Most chrooted systems will try to launch daemons like smtpd or httpd
# at startup, and they'll try to use ports that are already being used
# by daemons running at the host... maybe there are runlevels where
# all these daemons are down.
# Someone at #debian suggested runlevel 1. Maybe it would be better to
# set up one of unused runlevels (5, 6?) for "host with daemons
# shutted down, allowed full chroots".
nmap 127.0.0.1
# (find-fline "/etc/rc0.d/")
# (find-fline "/etc/rc2.d/")
#####
#
# deboostrap on an ext2 filesystem on a loop device
# 2004oct06
#
#####
# «loop-debootstrap» (to ".loop-debootstrap")
#*
# Create a sparse 1G file and make an ext2 filesystem on it.
# User-mode-linux doesn't like this very much. Use the alternative below.
#
umount /tmp/sarge/proc
umount /tmp/sarge/dev/pts
umount /tmp/sarge
rmdir /tmp/sarge
rm -v /tmp/sarge.img
# Create a sparse 1G image
python =(<<'%%%'
image = open("/tmp/sarge.img", 'w')
image.truncate(1024 * 1048576L)
image.close()
%%%)
mke2fs -F /tmp/sarge.img
mkdir /tmp/sarge
mount -o loop /tmp/sarge.img /tmp/sarge
#*
# Alternative: create a sparse 1G file but use it as a HD image
umount /tmp/sarge/proc
umount /tmp/sarge/dev/pts
umount /tmp/sarge
rmdir /tmp/sarge
rm -v /tmp/sarge.hdimg
python =(<<'%%%'
image = open("/tmp/sarge.hdimg", 'w')
image.truncate(1024 * 1048576L)
image.close()
%%%)
# (find-man "fdisk")
# (find-man "losetup")
echo "u!n!p!1!63!2097151!p!w!q!" | tr '!' '\n' > $EEG
eeg fdisk /tmp/sarge.hdimg
losetup -o $[63*512] /dev/loop1 /tmp/sarge.hdimg
mke2fs -F /dev/loop1
losetup -d /dev/loop1
umount /tmp/sarge
mkdir /tmp/sarge
mount -o loop,offset=$[63*512] /tmp/sarge.hdimg /tmp/sarge
#*
# (find-es "livecd" "var-www-vcarchives")
# (find-man "8 debootstrap")
debootstrap sarge /tmp/sarge http://127.0.0.1/vcarchives/
# (find-fline "/tmp/sarge/")
#*
cat > /tmp/sarge/etc/apt/sources.list <<'%%%'
deb http://127.0.0.1/vcarchives sarge main
%%%
mount -t proc sargeproc /tmp/sarge/proc
mount -t devpts sargedevpts /tmp/sarge/dev/pts
mount -t devfs sargedevfs /tmp/sarge/dev
# chroot /tmp/sarge /bin/sh
chroot /tmp/sarge /usr/bin/apt-get update
chroot /tmp/sarge /usr/bin/apt-get install umlrun-uml zsh
umount /tmp/sarge/dev
umount /tmp/sarge/dev/pts
umount /tmp/sarge/proc
#*
#####
#
# fixing the inittab
# 2004oct07
#
#####
# «inittab» (to ".inittab")
#*
mount -o loop,offset=$[63*512] /tmp/sarge.hdimg /tmp/sarge
#*
cd /tmp/sarge/etc
if [[ ! -e inittab.orig ]]; then
mv -v inittab inittab.orig
fi
# (find-man "5 inittab")
# (find-man "8 getty")
# (find-k24confvar "CONFIG_DEVFS_FS")
cat > inittab <<'%%%'
id:2:initdefault:
si::sysinit:/etc/init.d/rcS
~~:S:wait:/sbin/sulogin
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
z6:6:respawn:/sbin/sulogin
#
1:2345:respawn:/sbin/getty 38400 ttys/0
# 1:2345:respawn:/sbin/getty 38400 tty1
# 2:23:respawn:/sbin/getty 38400 tty2
%%%
#*
umount /tmp/sarge
#*
#####
#
# invoking user-mode-linux
# 2004oct07
#
#####
# «invoking» (to ".invoking")
#*
linux root=/dev/root ubd0=/tmp/sarge.hdimg con=xterm con1=xterm con2=xterm
#*
linux root=/dev/root ubd0=/tmp/sarge.hdimg con=xterm con0=fd:0,fd:1
#*
linux root=/dev/root ubd0=/tmp/sarge.hdimg con=xterm con1=fd:0,fd:1
#*
linux ubd0=/tmp/sarge.hdimg con=null ssl=null con1=fd:0,fd:1
#*
linux ubd0=/tmp/sarge.hdimg con=xterm con0=fd:0,fd:1 con1=fd:0,fd:1
#*
# asyd's command line:
linux con=null con0=fd:1,fd:0 eth0=tuntap,tap0 umid=asyd ubd0=postfix.cow
# (find-fline-ov "/tmp/UserModeLinux-HOWTO.txt" " 3.2. Logging in")
# (find-fline-ov "/tmp/UserModeLinux-HOWTO.txt" "will not run on 2G/2G hosts")
# (find-fline-ov "/tmp/UserModeLinux-HOWTO.txt" "device=xterm")
# (find-fline-ov "/tmp/UserModeLinux-HOWTO.txt" "con0=fd:0,fd:1 con=pts")
#*
linux root=/dev/root ubd0=/tmp/sarge.hdimg
#*
linux ubd0=/tmp/sarge.hdimg
#*
irc.usermodelinux.org
#uml
# (find-man "1 linux")
# (find-man "1 linux" "root=/dev/root rootflags=/")
# (find-man "1 linux" "ubd0=/tmp/chroot")
# (find-sh "linux --help")
#*
umlrun /bin/ls
#*
function umlkill () { sudo kill $(cat ~/.uml/*/pid); rm -Rfv ~/.uml/* }
#*
# (find-fline-ov "/tmp/UserModeLinux-HOWTO.txt")
# (find-fline-ov "/tmp/UserModeLinux-HOWTO.txt" " 3.2. Logging in")
# IRC question:
a question about user-mode-linux... I've created an hd image in
/tmp/sarge.hdimg, an ext2 filesystem inside it, mounted it on
/tmp/sarge, initialized it with debootstrap, added umlrun-uml, etc,
and now user-mode-linux seems to run happily when I do "linux
root=/dev/root ubd0=/tmp/sarge.hdimg con=xterm"... but how do I run a
shell inside the uml?
do I need the skas patch in the host kernel?
# http://www.megahosted.com/~en/papers/uml-debian-mini.html
#####
#
# kernel-patch-skas
# 2004oct07
#
#####
# «kernel-patch-skas» (to ".kernel-patch-skas")
# (find-status "kernel-patch-skas")
# (find-vldifile "kernel-patch-skas.list")
# (find-udfile "kernel-patch-skas/")
# (find-kpatchesfile "diffs/skas/")
#####
#
# kernel-patch-uml
# 2004oct07
#
#####
# «kernel-patch-uml» (to ".kernel-patch-uml")
# (find-status "kernel-patch-uml")
# (find-vldifile "kernel-patch-uml.list")
# (find-udfile "kernel-patch-uml/")
# (find-kpatchesfile "diffs/uml/uml-patch-2.4.26-3.gz")
# (find-kpatchesfile "diffs/uml/uml-patch-2.4.26-3.gz" "root_fs")
# (find-kpatchesfile "diffs/uml/uml-patch-2.6.8.1-1.gz")
# (find-kpatchesfile "all/unpatch/uml")
# (find-kpatchesfile "all/apply/uml")
#####
#
# umlrun
# 2004oct07
#
#####
# (find-status "umlrun-uml")
# (find-vldifile "umlrun-uml.list")
# (find-udfile "umlrun-uml/")
# (find-status "umlrun")
# (find-vldifile "umlrun.list")
# (find-udfile "umlrun/")
#####
#
# the /dev/anon patch
# 2004oct07
#
#####
# See the bottom of:
# http://user-mode-linux.sourceforge.net/dl-sf.html
# Local Variables:
# coding: utf-8-unix
# End: