Initramfs » История » Редакция 5
Редакция 4 (Андрей Волков, 2013-04-28 14:02) → Редакция 5/8 (Андрей Волков, 2014-05-23 14:02)
h1. Initramfs
/init
<pre>
#!/bin/busybox sh
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
# Do your stuff here.
echo "This script mounts rootfs and boots it up, nothing more!"
rescue_shell() {
echo "Something went wrong. Dropping you to a shell."
busybox --install -s
exec /bin/sh
}
mini_udev() {
ln -s ../bin/busybox /sbin/mdev
echo /sbin/mdev > /proc/sys/kernel/hotplug
/sbin/mdev -s
}
# Use devtmpfs if possible
if grep -qs devtmpfs /proc/filesystems; then
mount -n -t devtmpfs -o "exec,nosuid,mode=0755,size=10M" udev /dev
devtmpfs=true
else
mini_udev
devtmpfs=false
fi
uuidlabel_root() {
for cmd in $(cat /proc/cmdline) ; do
case $cmd in
root=*)
mkdir -p /etc/lvm
echo 'devices { filter = [ "a|/dev/md[0-9]+$|", "a|/dev/[hsv]d[a-z][0-9]*$|", "r/.*/" ] }' > /etc/lvm/lvm.conf
echo 'activation { udev_rules = 0 }' >> /etc/lvm/lvm.conf
/sbin/lvm vgscan
/sbin/lvm vgchange -ay --sysinit
type=$(echo $cmd | cut -d= -f2)
if [ $type == "LABEL" ] || [ $type == "UUID" ] ; then
uuid=$(echo $cmd | cut -d= -f3)
mount -o ro $(blkid |grep "$type=\"$uuid\"" | cut -d: -f1 | grep -v '/dev/dm-[0-9]*$\|-real$' | sort | head -n1 ) /mnt/root || rescue_shell
else
mount -o ro $(echo $cmd | cut -d= -f2) /mnt/root || rescue_shell
fi
;;
rescue)
rescue_shell
;;
esac
done
}
uuidlabel_root || rescue_shell
# Remount /dev if devtmpfs
$devtmpfs && mount -n --move /dev /mnt/root/dev
# Clean up.
umount /proc
umount /sys
# Boot the real thing.
exec switch_root /mnt/root /sbin/init
</pre>
<pre>
cd initramfs
find | cpio -o -H newc | gzip -9 > ../initramfs-2012-04-03.igz
</pre>
для сборки i686:
/etc/paludis/bashrc
<pre>
CC="x86_64-pc-linux-gnu-gcc -m32"
</pre>
для dropbear --enable-static-nss (glibc)
/etc/paludis/use.conf.d/initramfs.conf
<pre>
dev-libs/libtommath static-libs
net-misc/dropbear minimal -pam -shadow static -zlib
dev-libs/popt static-libs
net-misc/rsync static -drop_cache -iconv -ipv6
sys-fs/lvm2 static -udev
sys-apps/busybox -ipv6 static
</pre>