forked from rhinstaller/kickstart-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lvm-cache-2.ks.in
175 lines (148 loc) · 6.6 KB
/
lvm-cache-2.ks.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#version=DEVEL
url @KSTEST_URL@
install
network --bootproto=dhcp
bootloader --timeout=1
zerombr
clearpart --all --initlabel
part /boot --fstype=ext4 --size=300
part pv.1 --fstype=lvmpv --size=6600
part pv.2 --fstype=lvmpv --size=3100
volgroup fedora pv.1 pv.2
logvol swap --name=swap --vgname=fedora --size=500 --fstype=swap
logvol / --name=root --vgname=fedora --size=4000 --grow --fstype=ext4 --cachepvs=pv.2 --cachesize=1000 --cachemode=writethrough
logvol /home --name=home --vgname=fedora --size=1000 --grow --fstype=ext4 --cachepvs=pv.2 --cachesize=1000 --cachemode=writeback
keyboard us
lang en_US.UTF-8
timezone America/New_York --utc
rootpw testcase
shutdown
%packages
%end
%post
root_lv="/dev/mapper/fedora-root"
root_uuid="UUID=$(blkid -o value -s UUID "$root_lv")"
home_lv="/dev/mapper/fedora-home"
home_uuid="UUID=$(blkid -o value -s UUID "$home_lv")"
# verify root LV is mounted at /mnt/sysimage
root_mount=$(grep ^$root_lv\\s/\\s /proc/mounts)
if [ -z "$root_mount" ]; then
echo "*** lvm lv 'fedora-root' is not mounted at /" >> /root/RESULT
fi
root_fstype=$(echo "$root_mount" | cut -d' ' -f3)
if [ "$root_fstype" != "ext4" ]; then
echo "*** lvm lv 'fedora-root' does not contain an ext4 fs" >> /root/RESULT
fi
# verify root entry in /etc/fstab is correct
root_lv_entry=$(grep ^$root_lv\\s/\\s /etc/fstab)
root_uuid_entry=$(grep ^$root_uuid\\s/\\s /etc/fstab)
if [ -z "$root_lv_entry" -a -z "$root_uuid_entry" ] ; then
echo "*** root LV is not the root entry in /etc/fstab" >> /root/RESULT
fi
# verify size of root lv
root_lv_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/root | sed -r 's/\s*([0-9]+)\..*/\1/')
if [ $root_lv_size -le 4000 ]; then
echo "*** root lv has incorrect size" >> /root/RESULT
fi
# verify size of home lv
home_lv_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/home | sed -r 's/\s*([0-9]+)\..*/\1/')
if [ $home_lv_size -le 1000 ]; then
echo "*** home lv has incorrect size" >> /result/RESULT
fi
# verify swap on lvm is active
swap_lv="/dev/mapper/fedora-swap"
swap_uuid="UUID=$(blkid -o value -s UUID "$swap_lv")"
swap_dm=$(basename $(readlink "$swap_lv"))
if ! grep -q "$swap_dm" /proc/swaps ; then
echo "*** lvm lv 'fedora-swap' is not active as swap space" >> /root/RESULT
fi
# verify swap entry in /etc/fstab is correct
swap_lv_entry=$(grep ^$swap_lv\\sswap\\s /etc/fstab)
swap_uuid_entry=$(grep ^$swap_uuid\\sswap\\s /etc/fstab)
if [ -z "$swap_lv_entry" -a -z "$swap_uuid_entry" ] ; then
echo "*** swap lv is not in /etc/fstab" >> /root/RESULT
fi
# verify size of swap lv
swap_lv_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/swap | sed -r 's/\s*([0-9]+)\..*/\1/')
if [ "$swap_lv_size" != "500" ]; then
echo "*** swap lv has incorrect size" >> /root/RESULT
fi
# verify that not too much space was left free in the VG
vg_free="$(vgs -o vg_free_count --noheadings fedora)"
if [ $vg_free -gt 2 ]; then
echo "*** too much free space left in the fedora vg" >> /root/RESULT
fi
# we don't need to check sizes of grown LVs, the fact that the installation
# reached this point means everything fit into the VG somehow
## cache-specific checks
# verify that root and home LVs are cached
lvs -o lv_attr --noheadings fedora/root|grep -q '^\s\+C'
if [ $? != 0 ]; then
echo "*** root LV is not cached" >> /root/RESULT
fi
lvs -o lv_attr --noheadings fedora/home|grep -q '^\s\+C'
if [ $? != 0 ]; then
echo "*** home LV is not cached" >> /root/RESULT
fi
# verify size of root LV's cache
root_cache_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/root_cache | sed -r 's/\s*([0-9]+)\..*/\1/')
root_cache_md_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/root_cache_cmeta | sed -r 's/\s*([0-9]+)\..*/\1/')
root_cache_all=$(($root_cache_size + $root_cache_md_size))
if [ "$root_cache_all" != "1000" ]; then
echo "*** root LV's cache has incorrect size" >> /root/RESULT
fi
# verify size of home LV's cache
home_cache_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/home_cache | sed -r 's/\s*([0-9]+)\..*/\1/')
home_cache_md_size=$(lvs --noheadings -o size --unit=m --nosuffix fedora/home_cache_cmeta | sed -r 's/\s*([0-9]+)\..*/\1/')
home_cache_all=$(($home_cache_size + $home_cache_md_size))
if [ "$home_cache_all" != "1000" ]; then
echo "*** home LV's cache has incorrect size" >> /root/RESULT
fi
# verify mode of root LV's cache
root_cache_mode=$(lvs --noheadings -o cachemode fedora/root|sed -r 's/\s*//')
if [ "$root_cache_mode" != "writethrough" ]; then
echo "*** root LV's cache has wrong mode" >> /root/RESULT
fi
# verify mode of home LV's cache
home_cache_mode=$(lvs --noheadings -o cachemode fedora/home|sed -r 's/\s*//')
if [ "$home_cache_mode" != "writeback" ]; then
echo "*** home LV's cache has wrong mode" >> /root/RESULT
fi
# verify caches are using (only) the right (aka "faster") PV for both data and metadata
fast_pv=$(pvs --noheadings -o name,size --unit m --nosuffix|egrep '3[0-9]{3}'|sed -r 's/\s+(\S+)\s+.*/\1/')
root_cache_num_pvs=$(lvs -a --noheadings -o devices fedora/root_cache_cdata|wc -l)
if [ "$root_cache_num_pvs" != "1" ]; then
echo "*** root LV's cache is using multiple PVs" >> /root/RESULT
fi
home_cache_num_pvs=$(lvs -a --noheadings -o devices fedora/home_cache_cdata|wc -l)
if [ "$home_cache_num_pvs" != "1" ]; then
echo "*** home LV's cache is using multiple PVs" >> /root/RESULT
fi
root_cache_num_pvs=$(lvs -a --noheadings -o devices fedora/root_cache_cmeta|wc -l)
if [ "$root_cache_num_pvs" != "1" ]; then
echo "*** root LV's cache (meta) is using multiple PVs" >> /root/RESULT
fi
home_cache_num_pvs=$(lvs -a --noheadings -o devices fedora/home_cache_cmeta|wc -l)
if [ "$home_cache_num_pvs" != "1" ]; then
echo "*** home LV's cache (meta) is using multiple PVs" >> /root/RESULT
fi
root_cache_pv=$(lvs -a --noheadings -o devices fedora/root_cache_cdata|sed -r 's/\s*([^(]+)\(.*/\1/')
if [ "$root_cache_pv" != "$fast_pv" ]; then
echo "*** root LV's cache is using wrong PV" >> /root/RESULT
fi
home_cache_pv=$(lvs -a --noheadings -o devices fedora/home_cache_cdata|sed -r 's/\s*([^(]+)\(.*/\1/')
if [ "$home_cache_pv" != "$fast_pv" ]; then
echo "*** home LV's cache is using wrong PV" >> /root/RESULT
fi
root_cache_pv=$(lvs -a --noheadings -o devices fedora/root_cache_cmeta|sed -r 's/\s*([^(]+)\(.*/\1/')
if [ "$root_cache_pv" != "$fast_pv" ]; then
echo "*** root LV's cache (meta) is using wrong PV" >> /root/RESULT
fi
home_cache_pv=$(lvs -a --noheadings -o devices fedora/home_cache_cmeta|sed -r 's/\s*([^(]+)\(.*/\1/')
if [ "$home_cache_pv" != "$fast_pv" ]; then
echo "*** home LV's cache (meta) is using wrong PV" >> /root/RESULT
fi
if [ ! -e /root/RESULT ]; then
echo SUCCESS > /root/RESULT
fi
%end