Add first version of the febootstrap-minimize script.
[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 ../febootstrap -i bash -i coreutils fedora-10 ./minimal $1
16
17 # ... but let's minimize it aggressively.
18
19 echo -n "Before minimization: "; du -sh minimal
20 ../febootstrap-minimize --all ./minimal
21 echo -n "After minimization:  "; du -sh minimal
22
23 # Create the /init which is just a simple script to give users an
24 # interactive shell.
25
26 ( cd minimal && cat > init <<'__EOF__'
27 #!/bin/sh
28 echo; echo; echo
29 echo "Welcome to the minimal filesystem example"
30 echo; echo; echo
31 /bin/bash -i
32 __EOF__
33 chmod +x init
34 )
35
36 # Convert the filesystem to an initrd image.
37
38 ../febootstrap-to-initramfs ./minimal > minimal-initrd.img
39
40 # This is needed because of crappiness with qemu.
41
42 rm -f zero
43 dd if=/dev/zero of=zero bs=2048 count=1
44
45 # Now run qemu to boot this minimal system.
46
47 qemu-system-$(arch) \
48   -m 128 \
49   -kernel vmlinuz -initrd minimal-initrd.img \
50   -hda zero -boot c