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 for i in `gen_dep_list`
120 mymod=`find /lib/modules/${KV} -name "${i}${MOD_EXT}" | head -n 1`
123 print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
126 print_info 2 "initrd: >> Copying ${i}${MOD_EXT}..."
127 cp -ax --parents "${mymod}" "${TEMP}/initrd-temp"
130 cp -ax --parents /lib/modules/${KV}/modules* ${TEMP}/initrd-temp
132 mkdir -p "${TEMP}/initrd-temp/etc/modules"
133 for group_modules in ${!MODULES_*}; do
134 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
135 print_list ${!group_modules} > "${TEMP}/initrd-temp/etc/modules/${group}"
139 create_initrd_aux() {
140 if [ -f "${GK_SHARE}/${ARCH}/linuxrc" ]
142 cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initrd-temp/linuxrc"
144 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initrd-temp/linuxrc"
147 if [ -f "${GK_SHARE}/${ARCH}/initrd.scripts" ]
149 cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
151 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
154 if [ -f "${GK_SHARE}/${ARCH}/initrd.defaults" ]
156 cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
158 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
161 echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initrd-temp/etc/initrd.defaults"
162 for group_modules in ${!MODULES_*}; do
163 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
164 echo -n "${group} " >> "${TEMP}/initrd-temp/etc/initrd.defaults"
166 echo "\"" >> "${TEMP}/initrd-temp/etc/initrd.defaults"
168 if [ -f "${GK_SHARE}/${ARCH}/modprobe" ]
170 cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
172 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
174 if isTrue $CMD_DOKEYMAPAUTO
176 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initrd-temp/etc/initrd.defaults
178 mkdir -p "${TEMP}/initrd-temp/lib/keymaps"
179 tar -C "${TEMP}/initrd-temp/lib/keymaps" -zxf "${GK_SHARE}/generic/keymaps.tar.gz"
181 cd ${TEMP}/initrd-temp/sbin && ln -s ../linuxrc init
183 chmod +x "${TEMP}/initrd-temp/linuxrc"
184 chmod +x "${TEMP}/initrd-temp/etc/initrd.scripts"
185 chmod +x "${TEMP}/initrd-temp/etc/initrd.defaults"
186 chmod +x "${TEMP}/initrd-temp/sbin/modprobe"
191 cd ${TEMP}/initrd-temp/
192 TEST=`du -sk 2> /dev/null`
193 echo $TEST | cut "-d " -f1
199 print_info 1 "initrd: >> Initializing..."
200 create_base_initrd_sys
202 if [ "${NOINITRDMODULES}" = '' ]
204 print_info 1 " >> Copying modules..."
205 create_initrd_modules
207 print_info 1 "initrd: Not copying modules..."
210 print_info 1 " >> Copying auxilary files..."
213 INITRD_CALC_SIZE=`calc_initrd_size`
214 INITRD_SIZE=`expr ${INITRD_CALC_SIZE} + 100`
215 print_info 1 " :: Size is at ${INITRD_SIZE}K"
217 print_info 1 " >> Creating loopback filesystem..."
218 create_initrd_loop ${INITRD_SIZE}
220 print_info 1 " >> Moving initrd files to the loopback..."
223 print_info 1 " >> Cleaning up and compressing the initrd..."
224 create_initrd_unmount_loop
226 if [ "${COMPRESS_INITRD}" ]
228 gzip -f -9 ${TEMP}/initrd-${KV}
229 mv ${TEMP}/initrd-${KV}.gz ${TEMP}/initrd-${KV}
232 if [ "${BOOTSPLASH}" -eq "1" ]
234 if [ -x /sbin/splash ]
236 [ -z "${BOOTSPLASH_THEME}" ] && [ -e /etc/conf.d/bootsplash.conf ] && source /etc/conf.d/bootsplash.conf
237 [ -z "${BOOTSPLASH_THEME}" ] && [ -e /etc/conf.d/bootsplash ] && source /etc/conf.d/bootsplash
238 [ -z "${BOOTSPLASH_THEME}" ] && BOOTSPLASH_THEME=default
239 print_info 1 " >> Installing bootsplash [ using the ${BOOTSPLASH_THEME} theme ]..."
240 for bootRes in '800x600' '1024x768' '1280x1024' '1600x1200'
242 if [ -f "/etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg" ]
244 /sbin/splash -s -f /etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${bootRes}.cfg >> ${TEMP}/initrd-${KV} || gen_die "Error: could not copy ${bootRes} bootsplash!"
246 print_warning 1 "splash: Did not find a bootsplash for the ${bootRes} resolution..."
250 print_warning 1 " >> No bootsplash detected; skipping!"
253 if ! isTrue "${CMD_NOINSTALL}"
255 cp ${TEMP}/initrd-${KV} /boot/initrd-${KV} || gen_die 'Could not copy the initrd to /boot!'