Actions
Initramfs¶
/init
#!/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
Вариант с gzip¶
cd initramfs find | cpio -o -H newc | gzip -9 > ../initramfs-2012-04-03.igz
Вариант с xz¶
cd initramfs find | cpio -o -H newc | xz -v --check=crc32 --x86 --lzma2 > ../initramfs-2015-04-03.ixz
для сборки i686:
/etc/paludis/bashrc
CC="x86_64-pc-linux-gnu-gcc -m32"
для dropbear --enable-static-nss (glibc)
/etc/paludis/use.conf.d/initramfs.conf
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
Конвертируем ключи openssh в ключи для dropbear¶
dropbearconvert openssh dropbear ../ssh/ssh_host_rsa_key dropbear_rsa_host_key dropbearconvert openssh dropbear ../ssh/ssh_host_dsa_key dropbear_dsa_host_key dropbearconvert openssh dropbear ../ssh/ssh_host_ecdsa_key dropbear_ecdsa_host_key
Updated by Андрей Волков over 8 years ago · 8 revisions