3 # create_initrd_loop(size)
6 [ "$#" -ne '1' ] && gen_die 'create_initrd_loop(): Not enough arguments!'
7 mkdir -p ${TEMP}/initrd-mount ||
8 gen_die 'Could not create loopback mount directory!'
9 dd if=/dev/zero of=${TEMP}/initrd-${KV} bs=1k count=${1} >> "${DEBUGFILE}" 2>&1 ||
10 gen_die "Could not zero initrd-${KV}"
11 mke2fs -F -N500 -q "${TEMP}/initrd-${KV}" >> "${DEBUGFILE}" 2>&1 ||
12 gen_die "Could not format initrd-${KV}!"
13 mount -t ext2 -o loop "${TEMP}/initrd-${KV}" "${TEMP}/initrd-mount" >> "${DEBUGFILE}" 2>&1 ||
14 gen_die 'Could not mount the initrd filesystem!'
17 create_initrd_unmount_loop()
20 umount "${TEMP}/initrd-mount" ||
21 gen_die 'Could not unmount initrd system!'
26 cd "${TEMP}/initrd-temp"
27 mv * "${TEMP}/initrd-mount" >> ${DEBUGFILE} 2>&1
30 create_base_initrd_sys() {
31 rm -rf "${TEMP}/initrd-temp" > /dev/null
32 mkdir -p ${TEMP}/initrd-temp/dev
33 mkdir -p ${TEMP}/initrd-temp/bin
34 mkdir -p ${TEMP}/initrd-temp/etc
35 mkdir -p ${TEMP}/initrd-temp/usr
36 mkdir -p ${TEMP}/initrd-temp/proc
37 mkdir -p ${TEMP}/initrd-temp/temp
38 mkdir -p ${TEMP}/initrd-temp/sys
39 mkdir -p ${TEMP}/initrd-temp/.initrd
40 ln -s bin ${TEMP}/initrd-temp/sbin
41 ln -s ../bin ${TEMP}/initrd-temp/usr/bin
42 ln -s ../bin ${TEMP}/initrd-temp/usr/sbin
44 echo "/dev/ram0 / ext2 defaults" > ${TEMP}/initrd-temp/etc/fstab
45 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initrd-temp/etc/fstab
47 echo "REGISTER .* MKOLDCOMPAT" > ${TEMP}/initrd-temp/etc/devfsd.conf
48 echo "UNREGISTER .* RMOLDCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
49 echo "REGISTER .* MKNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
50 echo "UNREGISTER .* RMNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
52 cd ${TEMP}/initrd-temp/dev
56 cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" ||
57 gen_die 'Could not copy busybox from bincache!'
58 bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" ||
59 gen_die 'Could not uncompress busybox!'
60 chmod +x "${TEMP}/initrd-temp/bin/busybox"
62 if [ "${NOINITRDMODULES}" = '' ]
64 if [ "${PAT}" -gt "4" ]
66 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" ||
67 gen_die 'Could not copy insmod.static from bincache!'
69 cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" ||
70 gen_die 'Could not copy insmod.static from bincache'
73 bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" ||
74 gen_die 'Could not uncompress insmod.static!'
75 mv "${TEMP}/initrd-temp/bin/insmod.static" "${TEMP}/initrd-temp/bin/insmod"
76 chmod +x "${TEMP}/initrd-temp/bin/insmod"
79 cp "${DEVFSD_BINCACHE}" "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
80 bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
81 chmod +x "${TEMP}/initrd-temp/bin/devfsd"
83 [ "${UDEV}" -eq '1' ] && { tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initrd-temp" ||
84 gen_die "Could not extract udev binary cache!"; }
86 # We make our own devfsd.conf these days, the default one doesn't work with the stripped
87 # down devfsd we use with dietlibc
88 # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" ||
89 # gen_die "could not copy devfsd.conf from bincache"
90 # bunzip2 "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" ||
91 # gen_die "could not uncompress devfsd.conf"
94 if [ -e '/sbin/lvm' ] && ldd /sbin/lvm|grep -q 'not a dynamic executable';
96 if [ "${CMD_NOLVM2}" != '1' ]
98 cp /sbin/lvm "${TEMP}/initrd-temp/bin/lvm" ||
99 gen_die 'Could not copy over lvm!'
100 ln -sf "${TEMP}/initrd-temp/bin/lvm" "${TEMP}/initrd-temp/bin/vgscan" ||
101 gen_die 'Could not symlink lvm -> vgscan!'
102 ln -sf "${TEMP}/initrd-temp/bin/lvm" "${TEMP}/initrd-temp/bin/vgchange" ||
103 gen_die 'Could not symlink lvm -> vgchange!'
106 # print_warning 1 "initrd: No LVM2 static binaries found; skipping support..."
109 for i in '[' ash basename cat chroot clear cp dirname echo env false find \
110 grep gunzip gzip ln ls loadkmap losetup lsmod mkdir mknod more mount mv \
111 pivot_root ps awk pwd rm rmdir rmmod sed sh sleep tar test touch true umount uname \
112 xargs yes zcat chmod chown cut kill killall; do
113 rm -f ${TEMP}/initrd-temp/bin/$i > /dev/null
114 ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i ||
115 gen_die "Busybox error: could not link ${i}!"
128 create_initrd_modules() {
132 if [ "${PAT}" -gt "4" ]
139 print_info 2 "initrd: >> Searching for modules..."
140 if [ "${INSTALL_MOD_PATH}" != '' ]
142 cd ${INSTALL_MOD_PATH}
146 for i in `gen_dep_list`
148 mymod=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" | head -n 1`
151 print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
154 print_info 2 "initrd: >> Copying ${i}${MOD_EXT}..."
155 cp -ax --parents "${mymod}" "${TEMP}/initrd-temp"
158 cp -ax --parents ./lib/modules/${KV}/modules* ${TEMP}/initrd-temp
160 mkdir -p "${TEMP}/initrd-temp/etc/modules"
161 for group_modules in ${!MODULES_*}; do
162 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
163 print_list ${!group_modules} > "${TEMP}/initrd-temp/etc/modules/${group}"
167 create_initrd_aux() {
168 if [ -f "${GK_SHARE}/${ARCH}/linuxrc" ]
170 cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initrd-temp/linuxrc"
172 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initrd-temp/linuxrc"
175 if [ -f "${GK_SHARE}/${ARCH}/initrd.scripts" ]
177 cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
179 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
182 if [ -f "${GK_SHARE}/${ARCH}/initrd.defaults" ]
184 cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
186 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
189 echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initrd-temp/etc/initrd.defaults"
190 for group_modules in ${!MODULES_*}; do
191 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
192 echo -n "${group} " >> "${TEMP}/initrd-temp/etc/initrd.defaults"
194 echo '"' >> "${TEMP}/initrd-temp/etc/initrd.defaults"
196 if [ -f "${GK_SHARE}/${ARCH}/modprobe" ]
198 cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
200 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
202 if isTrue $CMD_DOKEYMAPAUTO
204 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initrd-temp/etc/initrd.defaults
206 mkdir -p "${TEMP}/initrd-temp/lib/keymaps"
207 tar -C "${TEMP}/initrd-temp/lib/keymaps" -zxf "${GK_SHARE}/generic/keymaps.tar.gz"
209 cd ${TEMP}/initrd-temp/sbin && ln -s ../linuxrc init
211 chmod +x "${TEMP}/initrd-temp/linuxrc"
212 chmod +x "${TEMP}/initrd-temp/etc/initrd.scripts"
213 chmod +x "${TEMP}/initrd-temp/etc/initrd.defaults"
214 chmod +x "${TEMP}/initrd-temp/sbin/modprobe"
219 cd ${TEMP}/initrd-temp/
220 TEST=`du -sk 2> /dev/null`
221 echo $TEST | cut "-d " -f1
227 print_info 1 "initrd: >> Initializing..."
228 create_base_initrd_sys
230 if [ "${NOINITRDMODULES}" = '' ]
232 print_info 1 " >> Copying modules..."
233 create_initrd_modules
235 print_info 1 "initrd: Not copying modules..."
238 print_info 1 " >> Copying auxilary files..."
241 INITRD_CALC_SIZE=`calc_initrd_size`
242 INITRD_SIZE=`expr ${INITRD_CALC_SIZE} + 100`
243 print_info 1 " :: Size is at ${INITRD_SIZE}K"
245 print_info 1 " >> Creating loopback filesystem..."
246 create_initrd_loop ${INITRD_SIZE}
248 print_info 1 " >> Moving initrd files to the loopback..."
251 print_info 1 " >> Cleaning up and compressing the initrd..."
252 create_initrd_unmount_loop
254 if [ "${COMPRESS_INITRD}" ]
256 gzip -f -9 ${TEMP}/initrd-${KV}
257 mv ${TEMP}/initrd-${KV}.gz ${TEMP}/initrd-${KV}
260 if [ "${BOOTSPLASH}" -eq "1" ]
262 if [ -x /sbin/splash ]
264 [ -z "${BOOTSPLASH_THEME}" ] && [ -e /etc/conf.d/bootsplash.conf ] && source /etc/conf.d/bootsplash.conf
265 [ -z "${BOOTSPLASH_THEME}" ] && [ -e /etc/conf.d/bootsplash ] && source /etc/conf.d/bootsplash
266 [ -z "${BOOTSPLASH_THEME}" ] && BOOTSPLASH_THEME=default
267 print_info 1 " >> Installing bootsplash [ using the ${BOOTSPLASH_THEME} theme ]..."
268 for bootRes in '800x600' '1024x768' '1280x1024' '1600x1200'
270 if [ -f "/etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg" ]
272 /sbin/splash -s -f /etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg >> ${TEMP}/initrd-${KV} ||
273 gen_die "Error: could not copy ${bootRes} bootsplash!"
275 print_warning 1 "splash: Did not find a bootsplash for the ${bootRes} resolution..."
279 print_warning 1 ' >> No bootsplash detected; skipping!'
282 if ! isTrue "${CMD_NOINSTALL}"
284 cp ${TEMP}/initrd-${KV} /boot/initrd-${KV} ||
285 gen_die 'Could not copy the initrd to /boot!'