162306a36Sopenharmony_ciNormally, a minimal initrd is created automatically by the rcutorture
262306a36Sopenharmony_ciscripting.  But minimal really does mean "minimal", namely just a single
362306a36Sopenharmony_ciroot directory with a single statically linked executable named "init":
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci$ size tools/testing/selftests/rcutorture/initrd/init
662306a36Sopenharmony_ci   text    data     bss     dec     hex filename
762306a36Sopenharmony_ci    328       0       8     336     150 tools/testing/selftests/rcutorture/initrd/init
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciSuppose you need to run some scripts, perhaps to monitor or control
1062306a36Sopenharmony_cisome aspect of the rcutorture testing.  This will require a more fully
1162306a36Sopenharmony_cifilled-out userspace, perhaps containing libraries, executables for
1262306a36Sopenharmony_cithe shell and other utilities, and soforth.  In that case, place your
1362306a36Sopenharmony_cidesired filesystem here:
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci	tools/testing/selftests/rcutorture/initrd
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciFor example, your tools/testing/selftests/rcutorture/initrd/init might
1862306a36Sopenharmony_cibe a script that does any needed mount operations and starts whatever
1962306a36Sopenharmony_ciscripts need starting to properly monitor or control your testing.
2062306a36Sopenharmony_ciThe next rcutorture build will then incorporate this filesystem into
2162306a36Sopenharmony_cithe kernel image that is passed to qemu.
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciOr maybe you need a real root filesystem for some reason, in which case
2462306a36Sopenharmony_ciplease read on!
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciThe remainder of this document describes one way to create the
2762306a36Sopenharmony_circu-test-image file that contains the filesystem used by the guest-OS
2862306a36Sopenharmony_cikernel.  There are probably much better ways of doing this, and this
2962306a36Sopenharmony_cifilesystem could no doubt be smaller.  It is probably also possible to
3062306a36Sopenharmony_cisimply download an appropriate image from any number of places.
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ciThat said, here are the commands:
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci------------------------------------------------------------------------
3562306a36Sopenharmony_cidd if=/dev/zero of=rcu-test-image bs=400M count=1
3662306a36Sopenharmony_cimkfs.ext3 ./rcu-test-image
3762306a36Sopenharmony_cisudo mount -o loop ./rcu-test-image /mnt
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci# Replace "precise" below with your favorite Ubuntu release.
4062306a36Sopenharmony_ci# Empirical evidence says this image will work for 64-bit, but...
4162306a36Sopenharmony_ci# Note that debootstrap does take a few minutes to run.  Or longer.
4262306a36Sopenharmony_cisudo debootstrap --verbose --arch i386 precise /mnt http://archive.ubuntu.com/ubuntu
4362306a36Sopenharmony_cicat << '___EOF___' | sudo dd of=/mnt/etc/fstab
4462306a36Sopenharmony_ci# UNCONFIGURED FSTAB FOR BASE SYSTEM
4562306a36Sopenharmony_ci#
4662306a36Sopenharmony_ci/dev/vda        /               ext3    defaults        1 1
4762306a36Sopenharmony_cidev             /dev            tmpfs   rw              0 0
4862306a36Sopenharmony_citmpfs           /dev/shm        tmpfs   defaults        0 0
4962306a36Sopenharmony_cidevpts          /dev/pts        devpts  gid=5,mode=620  0 0
5062306a36Sopenharmony_cisysfs           /sys            sysfs   defaults        0 0
5162306a36Sopenharmony_ciproc            /proc           proc    defaults        0 0
5262306a36Sopenharmony_ci___EOF___
5362306a36Sopenharmony_cisudo umount /mnt
5462306a36Sopenharmony_ci------------------------------------------------------------------------
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciReferences:
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci	http://sripathikodi.blogspot.com/2010/02/creating-kvm-bootable-fedora-system.html
6062306a36Sopenharmony_ci	https://help.ubuntu.com/community/KVM/CreateGuests
6162306a36Sopenharmony_ci	https://help.ubuntu.com/community/JeOSVMBuilder
6262306a36Sopenharmony_ci	http://wiki.libvirt.org/page/UbuntuKVMWalkthrough
6362306a36Sopenharmony_ci	http://www.moe.co.uk/2011/01/07/pci_add_option_rom-failed-to-find-romfile-pxe-rtl8139-bin/ -- "apt-get install kvm-pxe"
6462306a36Sopenharmony_ci	https://www.landley.net/writing/rootfs-howto.html
6562306a36Sopenharmony_ci	https://en.wikipedia.org/wiki/Initrd
6662306a36Sopenharmony_ci	https://en.wikipedia.org/wiki/Cpio
6762306a36Sopenharmony_ci	http://wiki.libvirt.org/page/UbuntuKVMWalkthrough
68