TODO file added with some ideas.
[febootstrap.git] / examples / minimal-filesystem.sh
1 #!/bin/sh -
2
3 # Before running, make sure 'vmlinuz' in this examples directory is a
4 # bootable Linux kernel or a symlink to one.  You can just use any
5 # kernel out of the /boot directory for this.
6 #
7 # eg:
8 # cd examples
9 # ln -s /boot/vmlinuz-NNN vmlinuz
10
11 # This creates a very minimal filesystem, just containing bash and a
12 # few command line utilities.  One of the joys of Fedora is that even
13 # this minimal install is still 200 MB ...
14
15 if [ $(id -u) -eq 0 ]; then
16     echo "Don't run this script as root.  Read instructions in script first."
17     exit 1
18 fi
19
20 if [ ! -e vmlinuz ]; then
21     echo "Read instructions in script first."
22     exit 1
23 fi
24
25 ../febootstrap -i bash -i coreutils fedora-10 ./minimal $1
26
27 # ... but let's minimize it aggressively.
28
29 echo -n "Before minimization: "; du -sh minimal
30 ../febootstrap-minimize --all --pack-executables ./minimal
31 echo -n "After minimization:  "; du -sh minimal
32
33 # Create the /init which is just a simple script to give users an
34 # interactive shell.
35
36 ( cd minimal && cat > init <<'__EOF__'
37 #!/bin/sh
38 echo; echo; echo
39 echo "Welcome to the minimal filesystem example"
40 echo; echo; echo
41 /bin/bash -i
42 __EOF__
43 chmod +x init
44 )
45
46 # Convert the filesystem to an initrd image.
47
48 ../febootstrap-to-initramfs ./minimal > minimal-initrd.img
49
50 # This is needed because of crappiness with qemu.
51
52 rm -f zero
53 dd if=/dev/zero of=zero bs=2048 count=1
54
55 # Now run qemu to boot this minimal system.
56
57 qemu-system-$(arch) \
58   -m 128 \
59   -kernel vmlinuz -initrd minimal-initrd.img \
60   -hda zero -boot c