3 # create_initrd_loop(size)
6 [ "$#" -ne '1' ] && gen_die 'create_initrd_loop(): Not enough arguments!'
7 mkdir -p ${TEMP}/initrd-mount || gen_die 'Could not create loopback mount directory!'
8 dd if=/dev/zero of=${TEMP}/initrd-${KV} bs=1k count=${1} >> "${DEBUGFILE}" 2>&1 || gen_die "Could not zero initrd-${KV}"
9 mke2fs -F -N500 -q "${TEMP}/initrd-${KV}" >> "${DEBUGFILE}" 2>&1 || gen_die "Could not format initrd-${KV}!"
10 mount -t ext2 -o loop "${TEMP}/initrd-${KV}" "${TEMP}/initrd-mount" >> "${DEBUGFILE}" 2>&1 || gen_die 'Could not mount the initrd filesystem!'
13 create_initrd_unmount_loop()
16 umount "${TEMP}/initrd-mount" || gen_die 'Could not unmount initrd system!'
21 cd "${TEMP}/initrd-temp"
22 mv * "${TEMP}/initrd-mount" >> ${DEBUGFILE} 2>&1
25 create_base_initrd_sys() {
26 rm -rf "${TEMP}/initrd-temp" > /dev/null
27 mkdir -p ${TEMP}/initrd-temp/dev
28 mkdir -p ${TEMP}/initrd-temp/bin
29 mkdir -p ${TEMP}/initrd-temp/etc
30 mkdir -p ${TEMP}/initrd-temp/usr
31 mkdir -p ${TEMP}/initrd-temp/proc
32 mkdir -p ${TEMP}/initrd-temp/temp
33 mkdir -p ${TEMP}/initrd-temp/.initrd
34 ln -s bin ${TEMP}/initrd-temp/sbin
35 ln -s ../bin ${TEMP}/initrd-temp/usr/bin
36 ln -s ../bin ${TEMP}/initrd-temp/usr/sbin
37 echo "/dev/ram0 / ext2 defaults" > ${TEMP}/initrd-temp/etc/fstab
38 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initrd-temp/etc/fstab
40 echo "REGISTER .* MKOLDCOMPAT" > ${TEMP}/initrd-temp/etc/devfsd.conf
41 echo "UNREGISTER .* RMOLDCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
42 echo "REGISTER .* MKNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
43 echo "UNREGISTER .* RMNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
45 cd ${TEMP}/initrd-temp/dev
49 cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not copy busybox from bincache"
50 bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not uncompress busybox"
51 chmod +x "${TEMP}/initrd-temp/bin/busybox"
53 if [ "${NOINITRDMODULES}" = '' ]
55 if [ "${PAT}" -gt "4" ]
57 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
59 cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
62 bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not uncompress insmod.static"
63 mv "${TEMP}/initrd-temp/bin/insmod.static" "${TEMP}/initrd-temp/bin/insmod"
64 chmod +x "${TEMP}/initrd-temp/bin/insmod"
67 cp "${DEVFSD_BINCACHE}" "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
68 bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
69 chmod +x "${TEMP}/initrd-temp/bin/devfsd"
71 # We make our own devfsd.conf these days, the default one doesn't work with the stripped
72 # down devfsd we use with dietlibc
73 # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not copy devfsd.conf from bincache"
74 # bunzip2 "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not uncompress devfsd.conf"
77 if [ -e '/sbin/vgscan.static' -a -e '/sbin/vgchange.static' ]
79 if [ "${CMD_NOLVM2}" -ne '1' ]
81 cp /sbin/vgscan.static "${TEMP}/initrd-temp/bin/vgscan" || gen_die 'Could not copy over vgscan!'
82 cp /sbin/vgchange.static "${TEMP}/initrd-temp/bin/vgchange" || gen_die 'Could not copy over vgchange!'
85 # print_warning 1 "initrd: No LVM2 static binaries found; skipping support..."
88 for i in '[' ash basename cat chroot clear cp dirname echo env false find \
89 grep gunzip gzip ln ls loadkmap losetup lsmod mkdir mknod more mount mv \
90 pivot_root ps awk pwd rm rmdir rmmod sed sh sleep tar test touch true umount uname \
91 xargs yes zcat chmod chown cut kill killall; do
92 rm -f ${TEMP}/initrd-temp/bin/$i > /dev/null
93 ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || gen_die "Busybox error: could not link ${i}!"
106 create_initrd_modules() {
110 if [ "${PAT}" -gt "4" ]
117 print_info 2 "initrd: >> Searching for modules..."
118 if [ "${INSTALL_MOD_PATH}" != '' ]
120 cd ${INSTALL_MOD_PATH}
124 for i in `gen_dep_list`
126 mymod=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" | head -n 1`
129 print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
132 print_info 2 "initrd: >> Copying ${i}${MOD_EXT}..."
133 cp -ax --parents "${mymod}" "${TEMP}/initrd-temp"
136 cp -ax --parents ./lib/modules/${KV}/modules* ${TEMP}/initrd-temp
138 mkdir -p "${TEMP}/initrd-temp/etc/modules"
139 for group_modules in ${!MODULES_*}; do
140 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
141 print_list ${!group_modules} > "${TEMP}/initrd-temp/etc/modules/${group}"
145 create_initrd_aux() {
146 if [ -f "${GK_SHARE}/${ARCH}/linuxrc" ]
148 cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initrd-temp/linuxrc"
150 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initrd-temp/linuxrc"
153 if [ -f "${GK_SHARE}/${ARCH}/initrd.scripts" ]
155 cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
157 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
160 if [ -f "${GK_SHARE}/${ARCH}/initrd.defaults" ]
162 cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
164 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
167 echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initrd-temp/etc/initrd.defaults"
168 for group_modules in ${!MODULES_*}; do
169 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
170 echo -n "${group} " >> "${TEMP}/initrd-temp/etc/initrd.defaults"
172 echo "\"" >> "${TEMP}/initrd-temp/etc/initrd.defaults"
174 if [ -f "${GK_SHARE}/${ARCH}/modprobe" ]
176 cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
178 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
180 if isTrue $CMD_DOKEYMAPAUTO
182 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initrd-temp/etc/initrd.defaults
184 mkdir -p "${TEMP}/initrd-temp/lib/keymaps"
185 tar -C "${TEMP}/initrd-temp/lib/keymaps" -zxf "${GK_SHARE}/generic/keymaps.tar.gz"
187 cd ${TEMP}/initrd-temp/sbin && ln -s ../linuxrc init
189 chmod +x "${TEMP}/initrd-temp/linuxrc"
190 chmod +x "${TEMP}/initrd-temp/etc/initrd.scripts"
191 chmod +x "${TEMP}/initrd-temp/etc/initrd.defaults"
192 chmod +x "${TEMP}/initrd-temp/sbin/modprobe"
197 cd ${TEMP}/initrd-temp/
198 TEST=`du -sk 2> /dev/null`
199 echo $TEST | cut "-d " -f1
205 print_info 1 "initrd: >> Initializing..."
206 create_base_initrd_sys
208 if [ "${NOINITRDMODULES}" = '' ]
210 print_info 1 " >> Copying modules..."
211 create_initrd_modules
213 print_info 1 "initrd: Not copying modules..."
216 print_info 1 " >> Copying auxilary files..."
219 INITRD_CALC_SIZE=`calc_initrd_size`
220 INITRD_SIZE=`expr ${INITRD_CALC_SIZE} + 100`
221 print_info 1 " :: Size is at ${INITRD_SIZE}K"
223 print_info 1 " >> Creating loopback filesystem..."
224 create_initrd_loop ${INITRD_SIZE}
226 print_info 1 " >> Moving initrd files to the loopback..."
229 print_info 1 " >> Cleaning up and compressing the initrd..."
230 create_initrd_unmount_loop
232 if [ "${COMPRESS_INITRD}" ]
234 gzip -f -9 ${TEMP}/initrd-${KV}
235 mv ${TEMP}/initrd-${KV}.gz ${TEMP}/initrd-${KV}
238 if [ "${BOOTSPLASH}" -eq "1" ]
240 if [ -x /sbin/splash ]
242 [ -z "${BOOTSPLASH_THEME}" ] && [ -e /etc/conf.d/bootsplash.conf ] && source /etc/conf.d/bootsplash.conf
243 [ -z "${BOOTSPLASH_THEME}" ] && [ -e /etc/conf.d/bootsplash ] && source /etc/conf.d/bootsplash
244 [ -z "${BOOTSPLASH_THEME}" ] && BOOTSPLASH_THEME=default
245 print_info 1 " >> Installing bootsplash [ using the ${BOOTSPLASH_THEME} theme ]..."
246 for bootRes in '800x600' '1024x768' '1280x1024' '1600x1200'
248 if [ -f "/etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg" ]
250 /sbin/splash -s -f /etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg >> ${TEMP}/initrd-${KV} || gen_die "Error: could not copy ${bootRes} bootsplash!"
252 print_warning 1 "splash: Did not find a bootsplash for the ${bootRes} resolution..."
256 print_warning 1 " >> No bootsplash detected; skipping!"
259 if ! isTrue "${CMD_NOINSTALL}"
261 cp ${TEMP}/initrd-${KV} /boot/initrd-${KV} || gen_die 'Could not copy the initrd to /boot!'