diff --git a/config b/config index 1cd4745..8b72fe8 100644 --- a/config +++ b/config @@ -6,28 +6,28 @@ #use_fstab=0 # root fs -root="/dev/sda1" +root="UUID=28305682-0dfe-40a9-bf39-5df42123b749" # root fs type -rootfstype="ext4" +#rootfstype="" # root fs mount options -rootflags="" +#rootflags="" # drivers -drivers="ext4 virtio-scsi virtio-pci sd-mod" +#drivers="" # binaries -binaries="./busybox findfs mount modprobe umount" +#binaries="" # LVM support -#use_lvm=0 +use_lvm=1 # LVM include config -#use_lvmconf=0 +use_lvmconf=0 # LVM issue_discards -#lvm_discard=0 +lvm_discard=0 # LUKS support #use_luks=0 diff --git a/generate b/generate index f1fb424..83f329e 100755 --- a/generate +++ b/generate @@ -28,28 +28,73 @@ fi tmpdir="$(mktemp -d /tmp/initramfs.XXXXXXXX)" kernel="$(uname -r)" moddir="/lib/modules" +binaries="./busybox udevd udevadm mount modprobe umount $binaries" # structure -for d in dev etc usr/lib usr/bin mnt/root proc root sys; do +for d in dev var run etc usr/lib usr/bin mnt/root proc root sys; do mkdir -p "$tmpdir/$d" done -# TODO usr/lib64 usr/sbin # symlinks -for s in lib lib64 bin sbin; do - case "$s" in - lib*) - ( cd "$tmpdir" && ln -s "usr/lib" "$s" ) - ;; - *bin) - ( cd "$tmpdir" && ln -s "usr/bin" "$s" ) - ;; - esac -done +( cd "$tmpdir" && { + ln -s "usr/lib" "lib" + ln -s "usr/lib" "lib64" + ln -s "usr/bin" "bin" + ln -s "usr/bin" "sbin" + cd "$tmpdir/usr" + ln -s "bin" "sbin" + ln -s "lib" "lib64" +} ) # TODO parse fstab | crypttab #while [ "$use_fstab" -eq 1 ] && read fs dir type opts; do thing; done < /etc/fstab +# install mdev +#mkdir "$tmpdir/usr/lib/mdev" +#cp ./mdev/mdev.conf ./mdev/passwd ./mdev/group "$tmpdir/etc" +#cp ./mdev/usbdev ./mdev/usbdisk_link ./mdev/ide_links "$tmpdir/usr/lib/mdev" +#chmod +x $tmpdir/usr/lib/mdev/* + +# install udev +find "/usr/lib/udev" -type f | grep -v "rc_keymaps\|hwdb.d" | cpio -pd "$tmpdir" + +#cat < "$tmpdir/etc/group" +#root:x:0: +#tty:x:5: +#dialout:x:11: +#kmem:x:3: +#input:x:25: +#video:x:13: +#audio:x:12: +#lp:x:10: +#disk:x:9: +#cdrom:x:16: +#tape:x:6: +#kvm:x:24: +#floppy:x:8: +#EOF + +#cat < "$tmpdir/etc/passwd" +#root:x:0:0::/root:/bin/sh +#nobody:x:99:99::/dev/null:/bin/false +#EOF + +# TODO implement use_lvmconf +# handle lvm +if [ "$use_lvm" = 1 ] && [ -x "$(command -v lvm)" ]; then + binaries="lvm dmsetup $binaries" + mkdir "$tmpdir/etc/lvm" + echo "use_lvmetad = 0" >> "$tmpdir/etc/lvm/lvm.conf" + if [ "$lvm_discard" = 1 ]; then + echo "issue_discards = 1" >> "$tmpdir/etc/lvm/lvm.conf" + fi +fi + +# TODO handle luks +#if [ "$use_luks" = 1 ] && [ -x "$(command -v cryptsetup)" ]; then +# binaries="cryptsetup $binaries" +#fi + # TODO rewrite drivers installing | handle $drivers config var # install drivers find \ diff --git a/init b/init index 9376155..102c663 100644 --- a/init +++ b/init @@ -20,17 +20,21 @@ mount -t sysfs none /sys mount -t devtmpfs none /dev # setup mdev -#echo "/bin/mdev" >/proc/sys/kernel/hotplug +#echo "/sbin/mdev" >/proc/sys/kernel/hotplug #mdev -s +# setup udev +udevd --daemon +udevadm trigger --action=add --type=subsystems +udevadm trigger --action=add --type=devices +udevadm settle + # TODO parse /proc/cmdline # load drivers -modprobe -a $drivers +#modprobe -a $drivers -# find rootfs -# TODO busybox findfs doesn't support PART{UUID,LABEL}. -root="$(findfs $root)" || panic +# merge mount flags [ -n "$rootflags" ] && mountargs="$rootflags" [ -n "$rootfstype" ] && mountargs="$mountargs -t $rootfstype" @@ -38,6 +42,8 @@ root="$(findfs $root)" || panic mount $mountargs "$root" "/mnt/root" || panic # clean up +udevadm control --exit + umount "/dev" umount "/sys" umount "/proc"