3 # create_initrd_loop(size)
6 [ "$#" -ne "1" ] && gen_die "invalid use of create_initrd_loop"
7 mkdir -p ${TEMP}/initrd-mount || gen_die "could not create loopback mount dir"
8 dd if=/dev/zero of=${TEMP}/initrd-loop bs=1k count=${1} >> "${DEBUGFILE}" 2>&1 || gen_die "could not zero initrd-loop"
9 mke2fs -F -N500 -q "${TEMP}/initrd-loop" >> "${DEBUGFILE}" 2>&1 || gen_die "could not format initrd-loop"
10 mount -t ext2 -o loop "${TEMP}/initrd-loop" "${TEMP}/initrd-mount" >> "${DEBUGFILE}" 2>&1 || gen_die "could not mount 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}
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 mkdir -p ${TEMP}/initrd-temp/new_root
35 mkdir -p ${TEMP}/initrd-temp/keymaps
36 ln -s bin ${TEMP}/initrd-temp/sbin
37 ln -s ../bin ${TEMP}/initrd-temp/usr/bin
38 ln -s ../bin ${TEMP}/initrd-temp/usr/sbin
39 echo "/dev/ram0 / ext2 defaults" > ${TEMP}/initrd-temp/etc/fstab
40 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initrd-temp/etc/fstab
42 echo "REGISTER .* MKOLDCOMPAT" > ${TEMP}/initrd-temp/etc/devfsd.conf
43 echo "UNREGISTER .* RMOLDCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
44 echo "REGISTER .* MKNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
45 echo "UNREGISTER .* RMNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
48 cd ${TEMP}/initrd-temp/dev
52 cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not copy busybox from bincache"
53 bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not uncompress busybox"
54 chmod +x "${TEMP}/initrd-temp/bin/busybox"
56 if [ "${NOINITRDMODULES}" = "" ]
58 if [ "${PAT}" -gt "4" ]
60 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
62 cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
65 bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not uncompress insmod.static"
66 mv "${TEMP}/initrd-temp/bin/insmod.static" "${TEMP}/initrd-temp/bin/insmod"
67 chmod +x "${TEMP}/initrd-temp/bin/insmod"
70 cp "${DEVFSD_BINCACHE}" "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
71 bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
72 chmod +x "${TEMP}/initrd-temp/bin/devfsd"
74 # We make our own devfsd.conf these days, the default one doesn't work with the stripped
75 # down devfsd we use with dietlibc
76 # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not copy devfsd.conf from bincache"
77 # bunzip2 "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not uncompress devfsd.conf"
79 for i in '[' ash basename cat chroot clear cp dirname echo env false find \
80 grep gunzip gzip ln ls loadkmap losetup lsmod mkdir mknod more mount mv \
81 pivot_root ps awk pwd rm rmdir rmmod sh sleep tar test touch true umount uname \
82 xargs yes zcat chmod chown cut kill killall; do
83 rm -f ${TEMP}/initrd-temp/bin/$i > /dev/null
84 ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || gen_die "could not link ${i}"
97 create_initrd_modules() {
98 if [ "${PAT}" -gt "4" ]
104 for i in `gen_dep_list`
106 print_info 2 "$i : module searching" 1 0
107 mymod=`find /lib/modules/${KV} -name "${i}${MOD_EXT}"`
110 print_info 2 "Warning : ${i}${MOD_EXT} not found; skipping..."
113 print_info 2 "copying ${mymod} to initrd"
114 cp -ax --parents "${mymod}" "${TEMP}/initrd-temp"
117 cp -ax --parents /lib/modules/${KV}/modules* ${TEMP}/initrd-temp
119 mkdir -p "${TEMP}/initrd-temp/etc/modules"
120 print_list ${SCSI_MODULES} > "${TEMP}/initrd-temp/etc/modules/scsi"
121 print_list ${FIREWIRE_MODULES} > "${TEMP}/initrd-temp/etc/modules/firewire"
122 print_list ${ATARAID_MODULES} > "${TEMP}/initrd-temp/etc/modules/ataraid"
123 print_list ${PCMCIA_MODULES} > "${TEMP}/initrd-temp/etc/modules/pcmcia"
124 print_list ${USB_MODULES} > "${TEMP}/initrd-temp/etc/modules/usb"
127 create_initrd_aux() {
128 if [ -f "${GK_SHARE}/${ARCH}/linuxrc" ]
130 cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initrd-temp/linuxrc"
132 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initrd-temp/linuxrc"
135 if [ -f "${GK_SHARE}/${ARCH}/initrd.scripts" ]
137 cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
139 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
142 if [ -f "${GK_SHARE}/${ARCH}/initrd.defaults" ]
144 cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
146 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
148 if [ -f "${GK_SHARE}/${ARCH}/modprobe" ]
150 cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
152 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
155 chmod +x "${TEMP}/initrd-temp/linuxrc"
156 chmod +x "${TEMP}/initrd-temp/etc/initrd.scripts"
157 chmod +x "${TEMP}/initrd-temp/etc/initrd.defaults"
158 chmod +x "${TEMP}/initrd-temp/sbin/modprobe"
164 cd ${TEMP}/initrd-temp/
165 TEST=`du -sk 2> /dev/null`
166 echo $TEST | cut "-d " -f1
172 print_info 1 "initrd: creating base system"
173 create_base_initrd_sys
175 if [ "${NOINITRDMODULES}" = "" ]
177 print_info 1 "initrd: copying modules"
178 create_initrd_modules
180 print_info 1 "initrd: not copying modules"
183 print_info 1 "initrd: copying auxilary files"
186 print_info 1 "initrd: calculating initrd size"
187 INITRD_CALC_SIZE=`calc_initrd_size`
189 print_info 1 "initrd: calculated size ${INITRD_CALC_SIZE} + 100k slop for fs overhead"
190 INITRD_SIZE=`expr ${INITRD_CALC_SIZE} + 100`
192 print_info 1 "initrd: real size ${INITRD_SIZE}"
194 print_info 1 "initrd: creating loopback filesystem"
195 create_initrd_loop ${INITRD_SIZE}
197 print_info 1 "initrd: moving initrd fs to loopback"
200 print_info 1 "initrd: cleaning up and compressing initrd"
201 create_initrd_unmount_loop
203 if [ "${COMPRESS_INITRD}" ]
205 gzip -f -9 ${TEMP}/initrd-loop
206 mv ${TEMP}/initrd-loop.gz ${TEMP}/initrd-loop
209 if [ "${BOOTSPLASH}" -eq "1" ]
211 print_info 1 "initrd: copying bootsplash"
212 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-800x600.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 800x600 bootsplash"
213 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1024x768.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1024x768 bootsplash"
214 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1280x1024.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1280x1024 bootsplash"
215 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1600x1200.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1600x1200 bootsplash"
217 cp ${TEMP}/initrd-loop /boot/initrd-${KV} || gen_die "could not copy initrd to boot"