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 [ "${PAT}" -gt "4" ]
58 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
60 cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
63 bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not uncompress insmod.static"
64 mv "${TEMP}/initrd-temp/bin/insmod.static" "${TEMP}/initrd-temp/bin/insmod"
65 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"
76 for i in '[' ash basename cat chroot clear cp dirname echo env false find \
77 grep gunzip gzip insmod ln ls loadkmap losetup lsmod mkdir mknod more mount mv \
78 pivot_root ps awk pwd rm rmdir rmmod sh sleep tar test touch true umount uname \
79 xargs yes zcat chmod chown cut kill killall; do
80 rm -f ${TEMP}/initrd-temp/bin/$i > /dev/null
81 ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || gen_die "could not link ${i}"
85 create_initrd_modules() {
86 if [ "${PAT}" -gt "4" ]
92 # local modc i mods mymod
93 # for modc in storage firewire ataraid pcmcia usb
96 # mkdir -p ${TEMP}/initrd-temp/lib/modules/${modc}
97 # mods=`echo $modc | tr [:lower:] [:upper:]`_MODULES
100 for i in `gen_dep_list`
102 print_info 2 "$i : module searching" 1 0
103 mymod=`find /lib/modules/${KV} -name "${i}${MOD_EXT}"`
106 print_info 2 "Warning : ${i}${MOD_EXT} not found; skipping..."
109 print_info 2 "copying ${mymod} to initrd"
110 cp -ax --parents "${mymod}" "${TEMP}/initrd-temp"
114 cp -ax --parents /lib/modules/${KV}/modules* ${TEMP}/initrd-temp
116 print_info 1 "WARNING WARNING: Brad, Dont forget to output modules files to autoload"
117 # cat ${GK_SHARE}/${ARCH}/linuxrc | sed -e "s/%%STORAGE_MODULES%%/${STORAGE_MODULES}/" \
118 # -e "s/%%FIREWIRE_MODULES%%/${FIREWIRE_MODULES}/" \
119 # -e "s/%%ATARAID_MODULES%%/${ATARAID_MODULES}/" \
120 # -e "s/%%PCMCIA_MODULES%%/${PCMCIA_MODULES}/" \
121 # -e "s/%%USB_MODULES%%/${USB_MODULES}/" \
122 # > ${TEMP}/initrd-temp/linuxrc
124 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initrd-temp/linuxrc"
125 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initrd-temp/etc/initrd.scripts"
126 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initrd-temp/etc/initrd.defaults"
127 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initrd-temp/sbin/modprobe"
128 chmod +x "${TEMP}/initrd-temp/linuxrc"
129 chmod +x "${TEMP}/initrd-temp/etc/initrd.scripts"
130 chmod +x "${TEMP}/initrd-temp/etc/initrd.defaults"
131 chmod +x "${TEMP}/initrd-temp/sbin/modprobe"
136 cd ${TEMP}/initrd-temp/
137 TEST=`du -sk 2> /dev/null`
138 echo $TEST | cut "-d " -f1
144 print_info 1 "initrd: creating base system"
145 create_base_initrd_sys
147 print_info 1 "initrd: copying modules"
148 create_initrd_modules
150 print_info 1 "initrd: calculating initrd size"
151 INITRD_CALC_SIZE=`calc_initrd_size`
153 print_info 1 "initrd: calculated size ${INITRD_CALC_SIZE} + 100k slop for fs overhead"
154 INITRD_SIZE=`expr ${INITRD_CALC_SIZE} + 100`
156 print_info 1 "initrd: real size ${INITRD_SIZE}"
158 print_info 1 "initrd: creating loopback filesystem"
159 create_initrd_loop ${INITRD_SIZE}
161 print_info 1 "initrd: moving initrd fs to loopback"
164 print_info 1 "initrd: cleaning up and compressing initrd"
165 create_initrd_unmount_loop
167 if [ "${COMPRESS_INITRD}" ]
169 gzip -f -9 ${TEMP}/initrd-loop
170 mv ${TEMP}/initrd-loop.gz ${TEMP}/initrd-loop
173 if [ "${BOOTSPLASH}" -eq "1" ]
175 print_info 1 "initrd: copying bootsplash"
176 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-800x600.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 800x600 bootsplash"
177 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1024x768.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1024x768 bootsplash"
178 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1280x1024.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1280x1024 bootsplash"
179 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1600x1200.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1600x1200 bootsplash"
181 cp ${TEMP}/initrd-loop /boot/initrd-${KV} || gen_die "could not copy initrd to boot"