Действия
Initramfs » История » Редакция 1
Редакция 1/8
| Следующее »
Андрей Волков, 2012-04-03 19:21
Initramfs¶
#!/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=*) /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
Обновлено Андрей Волков больше 12 лет назад · 8 изменени(я, ий)