Implement private data area.
[libguestfs.git] / tools / make-test-img.sh
1 #!/bin/bash -
2 # libguestfs virt-* tools
3 # Copyright (C) 2010 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 # Make a standard test image which is used by all the tools/test-*.sh
20 # test scripts.  This test image is supposed to look like a Fedora
21 # installation, or at least enough of one to fool virt-inspector's
22 # heuristics.
23
24 export LANG=C
25 set -e
26
27 rm -f test.img
28
29 cat > fstab <<EOF
30 LABEL=BOOT /boot ext2 default 0 0
31 LABEL=ROOT / ext2 default 0 0
32 EOF
33
34 # Create a disk image.
35 ../fish/guestfish <<'EOF'
36 sparse test.img- 512M
37 run
38
39 # Format the disk.
40 part-init /dev/sda mbr
41 part-add /dev/sda p 64     524287
42 part-add /dev/sda p 524288    -64
43
44 pvcreate /dev/sda2
45 vgcreate VG /dev/sda2
46 lvcreate Root VG 32
47 lvcreate LV1 VG 32
48 lvcreate LV2 VG 32
49 lvcreate LV3 VG 64
50
51 # Phony /boot filesystem.
52 mkfs-b ext2 4096 /dev/sda1
53 set-e2label /dev/sda1 BOOT
54
55 # Phony root filesystem.
56 mkfs-b ext2 4096 /dev/VG/Root
57 set-e2label /dev/VG/Root ROOT
58
59 # Enough to fool virt-inspector.
60 mount-options "" /dev/VG/Root /
61 mkdir /boot
62 mount-options "" /dev/sda1 /boot
63 mkdir /bin
64 mkdir /etc
65 mkdir /usr
66 upload fstab /etc/fstab
67 mkdir /boot/grub
68 touch /boot/grub/grub.conf
69
70 # Test files.
71 write /etc/test1 "abcdefg"
72 write /etc/test2 ""
73 write /bin/test1 "abcdefg"
74 write /bin/test2 "zxcvbnm"
75 write /bin/test3 "1234567"
76 write /bin/test4 ""
77 ln-s /bin/test1 /bin/test5
78 mkfifo 0777 /bin/test6
79 mknod 0777 10 10 /bin/test7
80
81 # Other filesystems.
82 # Note that these should be empty, for testing virt-df.
83 mkfs-b ext2 4096 /dev/VG/LV1
84 mkfs-b ext2 1024 /dev/VG/LV2
85 mkfs-b ext2 2048 /dev/VG/LV3
86 EOF
87
88 rm fstab
89 mv test.img- test.img