]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - lfs/flash-images
flashimages: switch to single ext4 (wo journal)
[people/teissler/ipfire-2.x.git] / lfs / flash-images
CommitLineData
52ca8220
AF
1###############################################################################
2# #
3# IPFire.org - A linux based firewall #
920b610f 4# Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
52ca8220
AF
5# #
6# This program is free software: you can redistribute it and/or modify #
7# it under the terms of the GNU General Public License as published by #
8# the Free Software Foundation, either version 3 of the License, or #
9# (at your option) any later version. #
10# #
11# This program is distributed in the hope that it will be useful, #
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
18# #
19###############################################################################
20
21###############################################################################
22# Definitions
23###############################################################################
24
25include Config
26
27VER = ipfire
28
29THISAPP = flash-image
30TARGET = $(DIR_INFO)/$(THISAPP)
31
32###############################################################################
33# Top-level Rules
34###############################################################################
35
36install : $(TARGET)
37
38check :
39
40download :
41
42md5 :
43
44###############################################################################
45# Installation Details
46###############################################################################
3e011c27
AF
47IMGinst := /install/images/$(SNAME)-$(VERSION).1gb-ext4.$(MACHINE)-full-core$(CORE).img
48IMGinsts := /install/images/$(SNAME)-$(VERSION).1gb-ext4-scon.$(MACHINE)-full-core$(CORE).img
52ca8220
AF
49MNThdd := /install/harddisk
50IMGpart := /install/images/part_area
51IMGboot := /install/images/bootfs
52# don't change SIZEboot this without checking Image size
9831c245 53SIZEboot := 50
52ca8220 54IMGroot := /install/images/rootfs
3e011c27 55SIZEroot := 600
52ca8220
AF
56
57$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
3e011c27 58 rm -rf $(MNThdd) $(IMGinst) $(IMGpart) $(IMGboot) $(IMGroot) && mkdir -p $(MNThdd)
52ca8220
AF
59
60 # Create first 32 sectors of image
61 dd bs=1k if=/dev/zero of=$(IMGpart) count=16
62
63 # Create images for filesystems
9831c245 64 dd bs=1K if=/dev/zero of=$(IMGboot) count=51184 # 50MB-16K
52ca8220 65 dd bs=1M if=/dev/zero of=$(IMGroot) count=$(SIZEroot)
52ca8220
AF
66
67 # Format them
185f92e1
MT
68ifeq "$(MACHINE_TYPE)" "arm"
69 mkfs.vfat $(IMGboot)
70else
52ca8220 71 mkfs.ext2 -F $(IMGboot)
185f92e1 72endif
3e011c27 73 mkfs.ext4 -O ^has_journal,extent -F $(IMGroot)
52ca8220
AF
74
75 # Mount Images
76 mount -o loop $(IMGroot) $(MNThdd)
77 mkdir $(MNThdd)/boot
78 mkdir $(MNThdd)/var
6fafd272 79 mkdir $(MNThdd)/var/log
52ca8220 80 mount -o loop $(IMGboot) $(MNThdd)/boot
52ca8220 81
9831c245
AF
82 # Install MLO and uboot first
83ifeq "$(MACHINE_TYPE)" "arm"
84 cp -v /boot/MLO $(MNThdd)/boot/
85 cp -v /boot/u-boot.bin $(MNThdd)/boot/
86 sync
87 umount $(MNThdd)/boot
88 mount -o loop $(IMGboot) $(MNThdd)/boot
89endif
90
52ca8220 91 # Install IPFire
185f92e1 92 tar -C $(MNThdd)/ -xvaf /install/cdrom/$(SNAME)-$(VERSION).tlz
6fafd272
AF
93 echo "LANGUAGE=en" >> $(MNThdd)/var/ipfire/main/settings
94 echo "HOSTNAME=$(SNAME)" >> $(MNThdd)/var/ipfire/main/settings
95 echo "THEME=ipfire" >> $(MNThdd)/var/ipfire/main/settings
185f92e1 96 -touch $(MNThdd)/lib/modules/$(KVER)-ipfire/modules.dep
52ca8220
AF
97 mkdir $(MNThdd)/proc
98 mount --bind /proc $(MNThdd)/proc
99 mount --bind /dev $(MNThdd)/dev
100 mount --bind /sys $(MNThdd)/sys
101 chroot $(MNThdd) /usr/bin/perl -e "require '/var/ipfire/lang.pl'; &Lang::BuildCacheLang"
3cbeb8c7 102 sed -i -e "s|DEVICE1|UUID=$$(blkid -sUUID $(IMGboot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
185f92e1
MT
103ifeq "$(MACHINE_TYPE)" "arm"
104 # ARM flash images have a VFAT partition for /boot.
105 sed -i -e "s|ext2|vfat|" $(MNThdd)/etc/fstab
106endif
52ca8220 107 sed -i -e "s|DEVICE2|#DEVICE2|g" $(MNThdd)/etc/fstab
3cbeb8c7 108 sed -i -e "s|DEVICE3|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/etc/fstab
3e011c27
AF
109 sed -i -e "s|DEVICE4|#DEVICE4|g" $(MNThdd)/etc/fstab
110 sed -i -e "s|FSTYPE|ext4|g" $(MNThdd)/etc/fstab
52ca8220 111
185f92e1
MT
112ifneq "$(MACHINE_TYPE)" "arm"
113 sed -i -e "s|MOUNT|ro|g" $(MNThdd)/boot/grub/grub.conf
114 sed -i -e "s|KVER|$(KVER)|g" $(MNThdd)/boot/grub/grub.conf
115 sed -i -e "s|ROOT|UUID=$$(blkid -sUUID $(IMGroot) | cut -d'"' -f2)|g" $(MNThdd)/boot/grub/grub.conf
116 ln -s grub.conf $(MNThdd)/boot/grub/menu.lst
117
edc2be70
AF
118 # Copy grub files manually
119 cp -f $(MNThdd)/usr/share/grub/i386-pc/* $(MNThdd)/boot/grub/
120endif
121
a6d0d790
AF
122 # Setup symlink for partresize at first boot...
123 ln -sf ../init.d/partresize $(MNThdd)/etc/rc.d/rcsysinit.d/S25partresize
124 # Setup symlink for fsresize at second boot...
3e011c27 125 ln -sf ../init.d/fsresize $(MNThdd)/etc/rc.d/rcsysinit.d/S42fsresize
a6d0d790 126
52ca8220
AF
127 # Unmount
128 umount $(MNThdd)/proc
129 umount $(MNThdd)/dev
130 umount $(MNThdd)/sys
131 umount $(MNThdd)/boot
52ca8220
AF
132 umount $(MNThdd)
133
a6d0d790 134 # zerofree the ext2 images to get better compression
185f92e1 135ifneq "$(MACHINE_TYPE)" "arm"
dfc4bc56 136 zerofree $(IMGboot)
a6d0d790
AF
137 -fsck.ext2 -f -y $(IMGboot)
138 fsck.ext2 -f -y $(IMGboot)
185f92e1 139endif
dfc4bc56 140 zerofree $(IMGroot)
3e011c27
AF
141 -fsck.ext4 -f -y $(IMGroot)
142 fsck.ext4 -f -y $(IMGroot)
dfc4bc56 143
52ca8220 144 # Cat to an image
3e011c27 145 cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinst)
9831c245 146
52ca8220 147 # Write Partition table
9831c245 148ifneq "$(MACHINE_TYPE)" "arm"
3e011c27 149 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,0,0\n" \
52ca8220 150 | sfdisk -D -uM -H 64 -S 32 $(IMGinst)
9831c245 151else
3e011c27 152 echo -e ",$(SIZEboot),c,*\n,0,0\n,$(SIZEroot),L\n,0,0\n" \
9831c245
AF
153 | sfdisk -D -uM -H 64 -S 32 $(IMGinst)
154endif
52ca8220 155
185f92e1 156ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
157 # Install grub
158 echo "device (hd0) $(IMGinst)" > /tmp/grubinst.tmp
159 echo "root (hd0,0)" >> /tmp/grubinst.tmp
160 echo "setup (hd0)" >> /tmp/grubinst.tmp
161 echo "quit" >> /tmp/grubinst.tmp
162 grub < /tmp/grubinst.tmp
163 rm -f /tmp/grubinst.tmp
185f92e1 164endif
52ca8220
AF
165
166 # Compress Image
167 gzip -f9 $(IMGinst)
168
169 # Now Build serialcon Version
170 # Mount Images
171 mount -o loop $(IMGroot) $(MNThdd)
172 mount -o loop $(IMGboot) $(MNThdd)/boot
173
185f92e1 174ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
175 sed -i -e "s|splashimage|#splashimage|g" $(MNThdd)/boot/grub/grub.conf
176 sed -i -e "s|#serial|serial|g" $(MNThdd)/boot/grub/grub.conf
177 sed -i -e "s|#terminal|terminal|g" $(MNThdd)/boot/grub/grub.conf
185f92e1 178 sed -i -e "s| panic=10 | console=ttyS0,115200n8 panic=10 |g" $(MNThdd)/boot/grub/grub.conf
9007007b
AF
179else
180 sed -i -e "s| console=tty1 | console=ttyAMA0,115200n8 |g" $(MNThdd)/boot/cmdline.txt
3e011c27
AF
181 sed -i -e "s| console=tty1 omapfb.mode=dvi:800x600MR-16@60 | console=ttyO2,115200n8 |g" $(MNThdd)/boot/boot.script
182 cd $(MNThdd)/boot && ./convert_bootscript
185f92e1 183endif
52ca8220 184
3e962cfa
CS
185 sed -i -e "s|1:2345:respawn:|#1:2345:respawn:|g" $(MNThdd)/etc/inittab
186 sed -i -e "s|2:2345:respawn:|#2:2345:respawn:|g" $(MNThdd)/etc/inittab
187 sed -i -e "s|3:2345:respawn:|#3:2345:respawn:|g" $(MNThdd)/etc/inittab
188 sed -i -e "s|4:2345:respawn:|#4:2345:respawn:|g" $(MNThdd)/etc/inittab
189 sed -i -e "s|5:2345:respawn:|#5:2345:respawn:|g" $(MNThdd)/etc/inittab
190 sed -i -e "s|6:2345:respawn:|#6:2345:respawn:|g" $(MNThdd)/etc/inittab
52ca8220
AF
191 sed -i -e "s|#7:2345:respawn:|7:2345:respawn:|g" $(MNThdd)/etc/inittab
192
193 umount $(MNThdd)/boot
194 umount $(MNThdd)
195
dfc4bc56 196 # zerofree the ext3 images to get better compression
185f92e1 197ifneq "$(MACHINE_TYPE)" "arm"
dfc4bc56 198 zerofree $(IMGboot)
a6d0d790
AF
199 -fsck.ext2 -f -y $(IMGboot)
200 fsck.ext2 -f -y $(IMGboot)
185f92e1 201endif
dfc4bc56 202 zerofree $(IMGroot)
3e011c27
AF
203 -fsck.ext4 -f -y $(IMGroot)
204 fsck.ext4 -f -y $(IMGroot)
dfc4bc56 205
52ca8220 206 # Cat to an image
3e011c27
AF
207 cat $(IMGpart) $(IMGboot) $(IMGroot) > $(IMGinsts)
208 rm -vf $(IMGpart) $(IMGboot) $(IMGroot)
9831c245 209
52ca8220 210 # Write Partition table
9831c245 211ifneq "$(MACHINE_TYPE)" "arm"
3e011c27 212 echo -e ",$(SIZEboot),L,*\n,0,0\n,$(SIZEroot),L\n,0,0\n" \
52ca8220 213 | sfdisk -D -uM -H 64 -S 32 $(IMGinsts)
9831c245 214else
3e011c27 215 echo -e ",$(SIZEboot),c,*\n,0,0\n,$(SIZEroot),L\n,0,0\n" \
9831c245
AF
216 | sfdisk -D -uM -H 64 -S 32 $(IMGinsts)
217endif
52ca8220 218
185f92e1 219ifneq "$(MACHINE_TYPE)" "arm"
52ca8220
AF
220 # Install grub
221 echo "device (hd0) $(IMGinsts)" > /tmp/grubinst.tmp
222 echo "root (hd0,0)" >> /tmp/grubinst.tmp
223 echo "setup (hd0)" >> /tmp/grubinst.tmp
224 echo "quit" >> /tmp/grubinst.tmp
225 grub < /tmp/grubinst.tmp
226 rm -f /tmp/grubinst.tmp
185f92e1 227endif
52ca8220
AF
228
229 # Compress Image
230 gzip -f9 $(IMGinsts)
231
3e011c27 232 rm -rf $(MNThdd) $(IMGpart) $(IMGboot) $(IMGroot)