3 # create_initrd_loop(size)
5 [ "$#" -ne "1" ] && gen_die "invalid use of create_initrd_loop"
6 mkdir -p ${TEMP}/initrd-temp || gen_die "could not create loopback dir"
7 dd if=/dev/zero of=${TEMP}/initrd-loop bs=1k count=${1} >> "${DEBUGFILE}" 2>&1 || gen_die "could not zero initrd-loop"
8 mke2fs -F -q -N${1} "${TEMP}/initrd-loop" >> "${DEBUGFILE}" 2>&1 || gen_die "could not format initrd-loop"
9 mount -t ext2 -o loop "${TEMP}/initrd-loop" "${TEMP}/initrd-temp" >> "${DEBUGFILE}" 2>&1 || gen_die "could not mount initrd filesystem"
12 create_initrd_unmount_loop()
15 umount "${TEMP}/initrd-temp" || gen_die "could not unmount initrd system"
18 create_base_initrd_sys() {
19 mkdir -p ${TEMP}/initrd-temp/dev
20 mkdir -p ${TEMP}/initrd-temp/bin
21 mkdir -p ${TEMP}/initrd-temp/etc
22 mkdir -p ${TEMP}/initrd-temp/usr
23 mkdir -p ${TEMP}/initrd-temp/proc
24 mkdir -p ${TEMP}/initrd-temp/temp
25 mkdir -p ${TEMP}/initrd-temp/.initrd
26 mkdir -p ${TEMP}/initrd-temp/new_root
27 mkdir -p ${TEMP}/initrd-temp/keymaps
28 ln -s bin ${TEMP}/initrd-temp/sbin
29 ln -s ../bin ${TEMP}/initrd-temp/usr/bin
30 ln -s ../bin ${TEMP}/initrd-temp/usr/sbin
31 echo "/dev/ram0 / ext2 defaults" > ${TEMP}/initrd-temp/etc/fstab
32 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initrd-temp/etc/fstab
34 echo "REGISTER .* MKOLDCOMPAT" > ${TEMP}/initrd-temp/etc/devfsd.conf
35 echo "UNREGISTER .* RMOLDCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
36 echo "REGISTER .* MKNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
37 echo "UNREGISTER .* RMNEWCOMPAT" >> ${TEMP}/initrd-temp/etc/devfsd.conf
40 cd ${TEMP}/initrd-temp/dev
44 cp "${BUSYBOX_BINCACHE}" "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not copy busybox from bincache"
45 bunzip2 "${TEMP}/initrd-temp/bin/busybox.bz2" || gen_die "could not uncompress busybox"
46 chmod +x "${TEMP}/initrd-temp/bin/busybox"
48 if [ "${PAT}" -gt "4" ]
50 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
52 cp "${MODUTILS_BINCACHE}" "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not copy insmod.static from bincache"
55 bunzip2 "${TEMP}/initrd-temp/bin/insmod.static.bz2" || gen_die "could not uncompress insmod.static"
56 chmod +x "${TEMP}/initrd-temp/bin/insmod.static"
58 cp "${DEVFSD_BINCACHE}" "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
59 bunzip2 "${TEMP}/initrd-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
60 chmod +x "${TEMP}/initrd-temp/bin/devfsd"
62 # We make our own devfsd.conf these days, the default one doesn't work with the stripped
63 # down devfsd we use with dietlibc
64 # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not copy devfsd.conf from bincache"
65 # bunzip2 "${TEMP}/initrd-temp/etc/devfsd.conf.bz2" || gen_die "could not uncompress devfsd.conf"
67 for i in '[' ash basename cat chroot clear cp dirname echo env false find \
68 grep gunzip gzip insmod ln ls loadkmap losetup lsmod mkdir mknod modprobe more mount mv \
69 pivot_root ps awk pwd rm rmdir rmmod sh sleep tar test touch true umount uname \
70 xargs yes zcat chmod chown cut kill; do
71 rm -f ${TEMP}/initrd-temp/bin/$i > /dev/null
72 ln ${TEMP}/initrd-temp/bin/busybox ${TEMP}/initrd-temp/bin/$i || gen_die "could not link ${i}"
76 create_initrd_modules() {
77 if [ "${PAT}" -gt "4" ]
83 local modc i mods mymod
84 for modc in storage firewire ataraid pcmcia usb
86 mkdir -p ${TEMP}/initrd-temp/lib/modules/${modc}
87 mods=`echo $modc | tr [:lower:] [:upper:]`_MODULES
91 print_info 2 "$i : module searching" 1 0
92 mymod=`find /lib/modules/${KV} -name "${i}${MOD_EXT}"`
95 print_info 2 "Warning : ${i}${MOD_EXT} not found; skipping..."
98 print_info 2 "copying ${mymod} to initrd"
99 cp -ax --parents "${mymod}" "${TEMP}/initrd-temp"
103 cp -ax --parents /lib/modules/${KV}/modules* ${TEMP}/initrd-temp
104 cat ${GK_SHARE}/${ARCH}/linuxrc | sed -e "s/%%STORAGE_MODULES%%/${STORAGE_MODULES}/" \
105 -e "s/%%FIREWIRE_MODULES%%/${FIREWIRE_MODULES}/" \
106 -e "s/%%ATARAID_MODULES%%/${ATARAID_MODULES}/" \
107 -e "s/%%PCMCIA_MODULES%%/${PCMCIA_MODULES}/" \
108 -e "s/%%USB_MODULES%%/${USB_MODULES}/" \
109 > ${TEMP}/initrd-temp/linuxrc
110 chmod +x ${TEMP}/initrd-temp/linuxrc
115 print_info 1 "initrd: creating loopback filesystem"
116 create_initrd_loop 5000
118 print_info 1 "initrd: creating base system"
119 create_base_initrd_sys
121 print_info 1 "initrd: copying modules"
122 create_initrd_modules
124 print_info 1 "initrd: cleaning up and compressing initrd"
125 create_initrd_unmount_loop
127 if [ "${COMPRESS_INITRD}" ]
129 gzip -f -9 ${TEMP}/initrd-loop
130 mv ${TEMP}/initrd-loop.gz ${TEMP}/initrd-loop
133 if [ "${BOOTSPLASH}" -eq "1" ]
135 print_info 1 "initrd: copying bootsplash"
136 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-800x600.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 800x600 bootsplash"
137 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1024x768.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1024x768 bootsplash"
138 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1280x1024.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1280x1024 bootsplash"
139 /sbin/splash -s -f /etc/bootsplash/gentoo/config/bootsplash-1600x1200.cfg >> ${TEMP}/initrd-loop || gen_die "could not copy 1600x1200 bootsplash"
141 cp ${TEMP}/initrd-loop /boot/initrd-${KV} || gen_die "could not copy initrd to boot"