Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
#######
#
# E-scripts on qemu (and virtualbox).
#
# 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.
#
# 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/qemu.e>
#           or at <http://angg.twu.net/e/qemu.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/>.
#
#######




# «.simple-test»		(to "simple-test")
# «.qemu-debian-br-cdd»		(to "qemu-debian-br-cdd")
# «.create-hd-image»		(to "create-hd-image")
# «.linux.img-to-sarge.hdimg»	(to "linux.img-to-sarge.hdimg")
# «.swap-files»			(to "swap-files")
# «.patch-linux-qemu-fast»	(to "patch-linux-qemu-fast")
# «.rom-bug»			(to "rom-bug")
# «.tun-tap»			(to "tun-tap")
# «.fake-qemu-ifup»		(to "fake-qemu-ifup")
# «.qemu-0.8.2»			(to "qemu-0.8.2")
# «.qemu-net»			(to "qemu-net")
# «.qemu-arm»			(to "qemu-arm")
# «.virtualbox-2015»		(to "virtualbox-2015")
# «.virtualbox»			(to "virtualbox")


# (find-zsh "acse -i qemu")
# (find-dpkg-l "qemu")

# (find-status   "qemu")
# (find-vldifile "qemu.list")
# (find-udfile   "qemu/")

# (find-man "1 qemu")
# (find-man "1 qemu" "-append")
# (find-man "1 qemu-fast")
# (find-man "1 qemu-i386")
# (find-man "1 qemu-mkcow")
# (find-udfile "qemu/README.Debian")
# (find-udw3m  "qemu/qemu-doc.html")
# (find-udw3m  "qemu/qemu-tech.html")


# (find-fline "/etc/" "qemu")



#####
#
# A simple test
# 2004dec02
#
#####

# «simple-test»  (to ".simple-test")
# http://fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz

#*
# Unpack Fabrice Bellard's linux.img and bzImage-2.4.21
#
umount /tmp/linux-test/linux
rm -Rv /tmp/linux-test/
tar -C /tmp/ \
  -xvzf $S/http/fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz

#*
# The simplest test (needs X)
#
cd /tmp/linux-test/
qemu -m 64 -user-net \
  -kernel bzImage-2.4.21 \
  -append "root=/dev/hda" linux.img

#*



#####
#
# Booting from an ISO of a Debian installation CD, installing on an HD image
# 2004dec02
#
#####

# From <http://mov.osiris.com.br/qemu.txt>:
#   qemu -cdrom /dev/cdrom -hda hd_virtual
#   qemu -cdrom /dev/cdrom -boot d hd_virtual
# (find-man "1 qemu")
# (find-man "1 qemu" "-boot")
#
# The text also suggests this, that I don't understand well:
#   echo 1024 > /proc/sys/dev/rtc/max-user-freq
# (find-fline "/proc/sys/dev/rtc/")
# (find-k24file "drivers/char/rtc.c")
# (find-k24file "drivers/char/rtc.c" "max-user-freq")
# (find-k24confvar "CONFIG_RTC")

# «qemu-debian-br-cdd»  (to ".qemu-debian-br-cdd")
#*
CDIMAGEDIR=$S/http/www.postgresql.org.br/~otavio/debian-br-cdd/1.0_pre4
CDIMAGE=$CDIMAGEDIR/sarge-i386-1.raw

# Create an empty HD image as a sparse 1G file
#
python =(<<'%%%'
image = open("/tmp/br-cdd.hdimg", "w")
image.truncate(1024 * 1048576L)
image.close()
%%%)

qemu -cdrom $CDIMAGE -hda /tmp/br-cdd.hdimg -boot d

#*
# Note: the emulated installation above took about 2 hours in my
# 750MHz i586, and at some point it said that the installation was
# finished and that the system would be rebooted (or something like
# that); then it gave a progress bar with some last things that were
# being done, and qemu (version 0.6.0) aborted with:
#
#   (qemu) BIOS panic at rombios.c, line 1558
#
# Saving that hdimg to ~/tmp:

cp -v --sparse=always /tmp/br-cdd.hdimg ~/tmp/br-cdd.hdimg

#*
# (find-man "1 qemu-mkcow")
# (find-man "1 qemu")
# (find-sh "unhtml < /usr/share/doc/qemu/qemu-doc.html" "9000")
cd /tmp/
qemu-mkcow -f br-cdd.hdimg br-cdd.cow

CDIMAGEDIR=$S/http/www.postgresql.org.br/~otavio/debian-br-cdd/1.0_pre4
CDIMAGE=$CDIMAGEDIR/sarge-i386-1.raw

qemu -cdrom $CDIMAGE -hda /tmp/br-cdd.cow -boot c

#*

Losing too many ticks!
TSC cannot be used as a timesource.
Possible reasons for this are:
  You're running with Speedstep,






#####
#
# Create and partition an HD image
# 2004nov01
#
#####

# «create-hd-image»  (to ".create-hd-image")
#*
# Create a sparse 1G file and use it as a HD image
# You'll need to be root for the mounts, umounts, and losetups

umount /tmp/sarge/proc
umount /tmp/sarge/dev/pts
umount /tmp/sarge
rmdir  /tmp/sarge
rm -v  /tmp/sarge.hdimg

# Create a sparse 1G file
#
python =(<<'%%%'
image = open("/tmp/sarge.hdimg", 'w')
image.truncate(1024 * 1048576L)
image.close()
%%%)

# Partition it (create a single partition on it, as big as possible)
# (find-man "fdisk")
#
# echo u:n:p:1:63:2097151:p:w:q: | tr : \\n > $EEG
echo u:n:p:1:63::p:w:q: | tr : \\n > $EEG
eeg fdisk /tmp/sarge.hdimg

# (find-man "losetup")
losetup -o $[63*512] /dev/loop7 /tmp/sarge.hdimg
mke2fs -F /dev/loop7
losetup -d /dev/loop7

umount /tmp/sarge
mkdir  /tmp/sarge
mount -o loop,offset=$[63*512] /tmp/sarge.hdimg /tmp/sarge

#*




#####
#
# copy qemu's linux.img to sarge.hdimg
# 2004nov01
#
#####

# «linux.img-to-sarge.hdimg»  (to ".linux.img-to-sarge.hdimg")
#*
umount /tmp/linux-test/linuximg
rm -Rv /tmp/linux-test/
tar -C /tmp/ \
  -xvzf $S/http/fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz
cd  /tmp/linux-test/

#*
cd     /tmp/linux-test/
umount /tmp/linux-test/linuximg
rm -Rv /tmp/linux-test/linuximg/
mkdir  /tmp/linux-test/linuximg/
mount -o ro,loop /tmp/linux-test/linux.img /tmp/linux-test/linuximg/
cd     /tmp/linux-test/linuximg/

#*
cd     /tmp/linux-test/linuximg/ && \
cp -av * /tmp/sarge/

#*




#####
#
# swap files for linux
# 2004nov01
#
#####

# «swap-files»  (to ".swap-files")
#*
swapoff   /tmp/swapfile
rm -v     /tmp/swapfile

#*
# (find-man "1 dd")
# (find-man "8 mkswap")
# (find-man "8 mkswap" "dd if=/dev/zero")

dd bs=1M count=512 if=/dev/zero of=/tmp/swapfile
chmod 600 /tmp/swapfile
mkswap    /tmp/swapfile
swapon    /tmp/swapfile
cat /proc/swaps

#*



#####
#
# patching the Linux kernel for qemu-fast
# 2004dec02
#
#####

# «patch-linux-qemu-fast»  (to ".patch-linux-qemu-fast")
# (find-udw3m  "qemu/qemu-doc.html")
# (find-sh "unhtml < /usr/share/doc/qemu/qemu-doc.html" "9000")
# (find-k24file "include/asm/page.h"    "#define __PAGE_OFFSET")
# (find-k24file "include/asm/fixmap.h"  "#define FIXADDR_TOP")
# (find-k24file "arch/i386/vmlinux.lds" ". = 0x")
# (find-angg ".zshrc" "mydiff")
#*
cd ~/bigsrc/kernel-source-2.4.26/

patch -p0 include/asm/page.h <<'%%%'
81c81
< #define __PAGE_OFFSET		(0xC0000000)
---
> #define __PAGE_OFFSET		(0x90000000)
%%%

patch -p0 arch/i386/vmlinux.lds <<'%%%'
9c9
<   . = 0xC0000000 + 0x100000;
---
>   . = 0x90000000 + 0x100000;
%%%

patch -p0 include/asm/fixmap.h <<'%%%'
104c104
< #define FIXADDR_TOP	(0xffffe000UL)
---
> #define FIXADDR_TOP	(0xa7ffe000UL)
%%%

# Not tested
#*





#####
#
# qemu bug
# 2004dec23
#
#####

# «rom-bug»  (to ".rom-bug")
# Bug: sarge's qemu doesn't work with the current (sarge's) bochs bioses.
# Bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=281202
# Currently installed versions: (find-dpkg-l)
# Solution: download sid's versions of bochsbios and vgabios from
#     http://ftp.debian.org/debian/pool/main/b/bochs/
# and http://ftp.debian.org/debian/pool/main/v/vgabios/
# and install them by hand.
#*
cd $S/http/ftp.debian.org/debian/pool/main/
dpkg -i b/bochs/bochsbios_2.1.1+20041109-2_all.deb \
        v/vgabios/vgabios_0.4c+20041014-1_all.deb
#*




#####
#
# notes about TUN/TAP
# 2004dec24
#
#####

# «tun-tap»  (to ".tun-tap")
# (find-udw3m "qemu/qemu-doc.html")
# (find-udw3m "qemu/qemu-doc.html" "Using tun/tap network interface")
# (find-man "1 qemu")
# (find-man "1 qemu" "-n script" "TUN/TAP")
# (find-fline "/etc/qemu-ifup")

# (find-k26confvar "CONFIG_TUN")
# (find-k26docfile "networking/tuntap.txt")
# (find-k26file ".files.chS.used")

# (find-k26file "drivers/net/tun.c")
# (find-k26file "drivers/net/tun.c" "tun_chr_ioctl")
# (find-k26file "include/linux/if_tun.h")
# (find-k26file "include/linux/if_tun.h" "TUNSETIFF")

# Adjust the permissions:
# (find-fline "/dev/net/")
# Default: crw-------  1 root root 10, 200 Dec 23 13:15 tun
# Edrx:    crw-rw-rw-  1 root root 10, 200 Dec 23 13:15 tun
# Default: (find-sh0 "sudo chmod 600 /dev/net/tun")
# Edrx:    (find-sh0 "sudo chmod 666 /dev/net/tun")




#####
#
# Making qemu use a fake qemu-ifup script to setup tun/tap
# 2004dec24
#
#####

# «fake-qemu-ifup»  (to ".fake-qemu-ifup")

# Contents of: (find-fline "/etc/qemu-ifup")
#!/bin/sh
sudo -p "Password for $0:" /sbin/ifconfig $1 172.20.0.1

#*
# Unpack Fabrice Bellard's linux.img and bzImage-2.4.21
#
umount /tmp/linux-test/linux
rm -Rv /tmp/linux-test/
tar -C /tmp/ \
  -xvzf $S/http/fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz

#*
# Prepare a fake qemu-ifup script just to understand how the
# real qemu-ifup is being called
#
cat > /tmp/my-qemu-ifup <<'%%%'
#!/bin/sh
# sudo -p "Password for $0:" /sbin/ifconfig $1 172.20.0.1
sudo /sbin/ifconfig $1 172.20.0.1
date         >> /tmp/o
echo - $0 $* >> /tmp/o
%%%
chmod 755 /tmp/my-qemu-ifup
echo -n > /tmp/o
chmod 666 /tmp/o

#*
# Invoke qemu using the fake qemu-ifup script
#
cd /tmp/linux-test/
qemu -m 64 -isa -n /tmp/my-qemu-ifup \
  -monitor stdio \
  -kernel bzImage-2.4.21 \
  -append "root=/dev/hda" linux.img

#*
# Note: if (find-fline "/tmp/my-qemu-ifup")
# has no real ifconfig command then while qemu is running we should be
# able to do this in a shell:
#
sudo ifconfig tun0 172.20.0.1

# This is a good sign when gets said by qemu:
#   "Connected to host network interface: tun0"

# This is a bad sign when said by the guest kernel:
#   "SIOCSIFADDR: No such device"
#   "eth0: unknown interface: No such device"
# Sometimes the solution is to try with "-isa".
# (find-man "1 qemu" "\n       -isa")



 






# /dev/net/tun is 


# (find-man "8 ifconfig")

vtun

sudo ifconfig tun 172.20.0.1




#
# http://fabrice.bellard.free.fr/qemu/
# http://fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz

# A small netbsd image: http://nopid.free.fr/small.ffs.bz2

# (find-fline "$S/http/fabrice.bellard.free.fr/qemu/linux-test-0.5.1.tar.gz")
# (find-fline "/tmp/linux-test/")
# (find-fline "/tmp/linux-test/qemu.sh")
# (find-fline "/tmp/linux-test/qemu-ifup")
# (find-fline "/etc/qemu-ifup")
#




#*
cd /tmp/linux-test/
qemu -m 64 -user-net \
  -kernel ~/bigsrc/kernel-source-2.4.26/arch/i386/boot/bzImage \
  /tmp/sarge.hdimg -append "root=/dev/hda1"

#*
cd /tmp/linux-test/
qemu-fast -m 64 -user-net \
  -hda /tmp/sarge.hdimg \
  -kernel bzImage-2.4.21

#*

# (find-man "1 qemu")
# (find-man "1 qemu-fast")
# (find-man "1 qemu-i386")

# (find-fline "/etc/qemu-ifup")
# (find-fline "/usr/sbin/qemu-make-debian-root")


mount -o ro,loop linux.img linux




#####
#
# qemu 0.8.2 from the upstream sources
# 2007feb04
#
#####

# «qemu-0.8.2»  (to ".qemu-0.8.2")
# http://fabrice.bellard.free.fr/qemu/
# http://fabrice.bellard.free.fr/qemu/download.html
# http://fabrice.bellard.free.fr/qemu/qemu-0.8.2.tar.gz
#*
rm -Rv ~/usrc/qemu-0.8.2/
tar -C ~/usrc/ -xvzf $S/http/fabrice.bellard.free.fr/qemu/qemu-0.8.2.tar.gz
cd     ~/usrc/qemu-0.8.2/
./configure	|& tee oc
make		|& tee om

#*




#####
#
# qemu from the upstream sources
# 2004dec14
#
#####

# http://fabrice.bellard.free.fr/qemu/
# http://fabrice.bellard.free.fr/qemu/qemu-0.6.1.tar.gz
# http://packages.debian.org/src:qemu
# http://ftp.debian.org/debian/pool/main/q/qemu/qemu_0.6.1-1.dsc
#*
rm -Rv ~/usrc/qemu-0.6.1/
tar -C ~/usrc/ -xvzf $S/http/fabrice.bellard.free.fr/qemu/qemu-0.6.1.tar.gz
cd     ~/usrc/qemu-0.6.1/
./configure	|& tee oc
make		|& tee om

#*
# (code-c-d "qemu" "~/usrc/qemu-0.6.1/")
# (find-qemufile "")


sh-2.05b# route
Kernel IP routing table
Destination  Gateway  Genmask     Flags Metric Ref Use Iface
172.20.0.0   *        255.255.0.0 U     0      0     0 eth0
sh-2.05b# ping 10.0.2.2
connect: Network is unreachable
sh-2.05b#

sh-2.05b# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:12:23:56
          inet addr:172.20.0.2  Bcast:172.20.255.255  Mask:255.255.0.0
(...)


sendkey w
sendkey ctrl-a
sendkey ctrl-e
# not working in linux.img:
sendkey ctrl-c

ctrl-alt-1 and ctrl-alt-2 in


# (find-fline "/tmp/tomsfs/")
# (find-tomsrtbtfile "")

# (find-tomsrtbtfile "buildit.s")







# (find-fline "/tmp/toms/")
# (find-fline "/tmp/toms/rc.custom.gz")
# (find-fline "/tmp/toms/settings.s")

cd /tmp/linux-test/
qemu -m 64 -isa -n /tmp/my-qemu-ifup \
  -monitor stdio \
  -kernel /tmp/toms/bz2bzImage \
  -append "root=/dev/hda" linux.img

cd ~/usrc/tomsrtbt-2.0.103/
qemu -m 64 -isa -n /tmp/my-qemu-ifup \
  -monitor stdio \
  -fda tomsrtbt.raw


kernel /tmp/toms/bz2bzImage \
  -append "root=/dev/hda" linux.img

# (find-htetfile "Ethernet-HOWTO.gz")

# (find-man "1 qemu" "-append")
# (find-udfile "qemu/README.Debian")



#####
#
# Talking to a qemu'ed system through the emulated ethernet
# 2004dec23
#
#####

# «qemu-net»  (to ".qemu-net")

# (find-man "1 qemu")
# (find-man "1 qemu" "\n       -n script")
# (find-man "1 qemu" "\n       -redir")
# (find-man "1 qemu" "\n       -dummy-net")
# (find-man "1 qemu" "-append")
# (find-udfile "qemu/README.Debian")
# (find-udw3m  "qemu/qemu-doc.html")
# (find-udw3m  "qemu/qemu-doc.html" "`-monitor dev'")
# (find-udw3m  "qemu/qemu-tech.html")

# (find-fline "/etc/qemu-ifup")




#####
#
# qemu-arm
# 2007nov21
#
#####

# «qemu-arm»  (to ".qemu-arm")

http://www.debian.org/News/weekly/2007/05/
http://kitenet.net/~joey/blog/entry/tour_of_the_Debian_4.0_CDs/
http://www.debian.org/releases/stable/debian-installer/
http://ftp.nl.debian.org/debian/dists/etch/main/installer-arm/current/images/iop32x/netboot/
http://ftp.nl.debian.org/debian/dists/etch/main/installer-arm/current/images/ixp4xx/netboot/
http://blog.janik.cz/archives/2004/05/22/T21_50_50/
ftp://mirrors.vbi.vt.edu/linux/armedslack/armedslack-11.0/bootdisks/riscpc/slackb.zip
http://www.armedslack.org/
ftp://ftp.slackware.pl/pub/armedslack
ftp://mirrors.vbi.vt.edu/linux/armedslack
ftp://ftp.stealth3.com/pub/armedslack
rsync mirrors.vbi.vt.edu::armedslack
rsync rsync.stealth3.com::armedslack

http://lists.debian.org/debian-arm/
http://lists.debian.org/debian-arm/2007/01/msg00034.html
http://lists.debian.org/debian-arm/2007/11/msg00001.html  <--
http://lists.debian.org/debian-arm/2007/11/msg00025.html
http://wiki.debian.org/ArmEabiHowto
http://wiki.debian.org/ArmEabiTodo
http://wiki.debian.org/CrossDebootstrap
http://www.arm.linux.org.uk/
http://www.aurel32.net/info/debian_arm_qemu.php
http://www.linuxhints.info/armlinux/
http://www.linuxhints.info/armlinux/debian.html
http://www.linuxhints.info/armlinux/systems.html

http://en.wikipedia.org/wiki/QEMU
qemu-arm -h
qemu-armeb -h




#####
#
# VirtualBox (2015, Triquel)
# 2015aug27
#
#####

# «virtualbox-2015» (to ".virtualbox-2015")
# https://www.virtualbox.org/wiki/Linux_Downloads
# http://download.virtualbox.org/virtualbox/5.0.2/virtualbox-5.0_5.0.2-102096~Debian~jessie_amd64.deb




#####
#
# VirtualBox
# 2011mar30 / 2012apr10
#
#####

# «virtualbox»  (to ".virtualbox")
# (find-angg ".emacs" "virtualbox")
# http://wiki.debian.org/VirtualBox
# I use a backported linux kernel, so I had to install a backported vbox...
# http://en.wikipedia.org/wiki/Comparison_of_platform_virtual_machines

sudo apt-get install \
   linux-source linux-headers-686-pae
sudo apt-get -t squeeze-backports install \
  virtualbox-ose virtualbox-ose-qt virtualbox-ose-guest-x11

# (find-zsh "availabledebs | sort | grep virtualbox")
# (find-zsh "installeddebs | sort | grep virtualbox")
# (find-zsh "availabledebs | sort | grep linux-source")
# (find-zsh "availabledebs | sort | grep linux-headers")

# (find-status   "virtualbox")
# (find-vldifile "virtualbox.list")
# (find-udfile   "virtualbox/")
# (find-status   "virtualbox-ose")
# (find-vldifile "virtualbox-ose.list")
# (find-udfile   "virtualbox-ose/")
# (find-status   "virtualbox-ose-qt")
# (find-vldifile "virtualbox-ose-qt.list")
# (find-udfile   "virtualbox-ose-qt/")
# (find-status   "virtualbox-ose-guest-x11")
# (find-vldifile "virtualbox-ose-guest-x11.list")
# (find-udfile   "virtualbox-ose-guest-x11/")
# (find-status   "virtualbox-ose-dkms")
# (find-vldifile "virtualbox-ose-dkms.list")
# (find-udfile   "virtualbox-ose-dkms/")
# (find-man "1 VirtualBox")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
VirtualBox &

# (find-available "virtualbox-ose-guest-x11")
# (find-zsh "availabledebs | sort | grep virtualbox-ose")
# (find-zsh "dmissing virtualbox")
# http://download.virtualbox.org/virtualbox/4.0.4/UserManual.pdf
# http://duq.ca/duqamuq/?p=232
# http://en.wikipedia.org/wiki/VirtualBox
# http://virtualboxes.org/images/debian/
# http://www.virtualbox.org/
# http://www.virtualbox.org/wiki/Downloads#manual
# http://www.virtualbox.org/wiki/End-user_documentation
# http://www.virtualbox.org/wiki/Guest_OSes
# http://www.virtualbox.org/wiki/Linux_Downloads
# http://www.virtualbox.org/wiki/User_FAQ
# http://www.virtualbox.org/wiki/User_HOWTOS

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)






#  Local Variables:
#  coding:               raw-text-unix
#  ee-delimiter-hash:    "\n#*\n"
#  ee-delimiter-percent: "\n%*\n"
#  ee-anchor-format:     "«%s»"
#  End: