diff --git a/README.md b/README.md index af1fbe0..79ac3e7 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ sudo cp -r /bootfiles/* /mnt/EFI # Install GRUB sudo grub-install --target=x86_64-efi --removable --efi-directory=/mnt --boot-directory=/mnt/EFI -sudo grub-install --target=i386-pc --root-directory=/mnt/EFI --boot-directory=/mnt/EFI /dev/sdb +sudo grub-install --target=i386-pc --boot-directory=/mnt/EFI /dev/sdb # Unmount and your disk is ready to boot! sudo umount /mnt diff --git a/local.ramfs b/local.ramfs index f406bf0..616d53e 100644 --- a/local.ramfs +++ b/local.ramfs @@ -173,24 +173,21 @@ local_mount_root() # panic "Failed to mount ${ROOT} as root file system." # fi echo "Mounting filesystem ..." - mkdir /mount - mount -t ${FSTYPE} ${ROOT} /mount + mkdir /mnt + mount -t ${FSTYPE} ${ROOT} /mnt mount -t tmpfs -o size=95% none ${rootmnt} cd ${rootmnt} echo "Find and execute init.sh ..." - if test -f /mount/init.sh; then - cp /mount/init.sh . - chmod +x init.sh - ./init.sh - rm init.sh - elif test -f /mount/EFI/init.sh; then - cp /mount/EFI/init.sh . - chmod +x init.sh - ./init.sh - rm init.sh + if test -f /mnt/init.sh; then + cp /mnt/init.sh . + elif test -f /mnt/EFI/init.sh; then + cp /mnt/EFI/init.sh . else - find /mount -name _init.sh -exec {} \; + find /mnt -name init.sh -exec cp {} . \; fi + chmod +x init.sh + ./init.sh + rm init.sh } local_mount_fs() diff --git a/ramfs_setup.sh b/ramfs_setup.sh index 1030de8..4fc67b5 100644 --- a/ramfs_setup.sh +++ b/ramfs_setup.sh @@ -5,7 +5,7 @@ set -e echo "Install additional software ..." apt update -# basic system utilities +# system utilities apt install htop screen nano wget bash-completion eject dosfstools ntfs-3g exfat-fuse grub-pc-bin mdadm lvm2 iptables net-tools network-manager -y # driver apt install firmware-linux-nonfree firmware-iwlwifi firmware-realtek firmware-atheros -y @@ -18,19 +18,19 @@ apt clean echo "Customizing initramfs script ..." if ! test -f /usr/share/initramfs-tools/scripts/local.original; then - cp /usr/share/initramfs-tools/scripts/local /usr/share/initramfs-tools/scripts/local.original + cp /usr/share/initramfs-tools/scripts/local /usr/share/initramfs-tools/scripts/local.original fi cp local.ramfs /usr/share/initramfs-tools/scripts/local.ramfs echo "Adding additional kernel module for FAT and exFAT ..." if ! test -f /etc/initramfs-tools/modules.original; then - cp /etc/initramfs-tools/modules /etc/initramfs-tools/modules.original + cp /etc/initramfs-tools/modules /etc/initramfs-tools/modules.original fi if ! test -f /etc/initramfs-tools/modules.ramfs; then - cp /etc/initramfs-tools/modules /etc/initramfs-tools/modules.ramfs - ls /lib/modules/`uname -r`/kernel/fs/fat/ | cut -f1 -d '.' | tee -a /etc/initramfs-tools/modules.ramfs - ls /lib/modules/`uname -r`/kernel/fs/exfat/ | cut -f1 -d '.' | tee -a /etc/initramfs-tools/modules.ramfs - ls /lib/modules/`uname -r`/kernel/fs/nls/ | cut -f1 -d '.' | tee -a /etc/initramfs-tools/modules.ramfs + cp /etc/initramfs-tools/modules /etc/initramfs-tools/modules.ramfs + ls /lib/modules/`uname -r`/kernel/fs/fat/ | cut -f1 -d '.' | tee -a /etc/initramfs-tools/modules.ramfs + ls /lib/modules/`uname -r`/kernel/fs/exfat/ | cut -f1 -d '.' | tee -a /etc/initramfs-tools/modules.ramfs + ls /lib/modules/`uname -r`/kernel/fs/nls/ | cut -f1 -d '.' | tee -a /etc/initramfs-tools/modules.ramfs fi echo "Adding tar binary to initramfs" @@ -39,13 +39,13 @@ cat << EOF > /usr/share/initramfs-tools/hooks/tar PREREQ="" prereqs() { - echo "\$PREREQ" + echo "\$PREREQ" } case \$1 in prereqs) - prereqs - exit 0 - ;; + prereqs + exit 0 + ;; esac . /usr/share/initramfs-tools/hook-functions rm -f \${DESTDIR}/bin/tar @@ -57,7 +57,7 @@ echo "Customizing fstab ..." if ! test -f /etc/fstab.original; then cp /etc/fstab /etc/fstab.original fi -echo 'none / tmpfs size=95% 0 0' | tee /etc/fstab.ramfs +echo 'none / tmpfs size=95% 0 0' | tee /etc/fstab.ramfs echo "Setup startup.service ..." cat << EOF > /etc/systemd/system/startup.service @@ -82,7 +82,9 @@ cp /etc/fstab.ramfs /etc/fstab echo "Preparing boot files ..." echo "Packing rootfs ..." mkdir -p /bootfiles/grub -tar zcf /bootfiles/rootfs.tar.gz --exclude='ramfs_setup.sh' --exclude='local.ramfs' --exclude='boot_dvd.sh' --exclude='README.md' --exclude='/bootfiles' --one-file-system / --checkpoint=.5000 +systemctl stop systemd-journald.service +tar zcf /bootfiles/rootfs.tar.gz --exclude='/home/*/ramfs' --exclude='/bootfiles' --one-file-system / --checkpoint=.5000 +systemctl start systemd-journald.service echo "Copying Linux kernel ..." cp /boot/vmlinuz-`uname -r` /bootfiles/vmlinuz-`uname -r` @@ -95,14 +97,15 @@ cat << EOF > /bootfiles/init.sh #!/bin/sh echo "Copying rootfs.tar.gz ..." -cp /mount/EFI/rootfs.tar.gz . +cp /mnt/EFI/rootfs.tar.gz . echo "Copying start.sh ..." -cp /mount/EFI/start.sh . +cp /mnt/EFI/start.sh . chmod +x start.sh echo "Unmount boot device ..." -umount /mount +umount /mnt echo -n "Extracting from rootfs.tar.gz ..." tar zxf rootfs.tar.gz --checkpoint=.5000 +echo rm rootfs.tar.gz EOF @@ -149,16 +152,15 @@ EOF echo "Create GRUB boot menu ..." cat << EOF > /bootfiles/grub/grub.cfg -serial --speed=115200 --unit=0 --word=8 --parity=no --stop +serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1 terminal_input console serial terminal_output console serial set timeout=5 probe -u \$root --set=boot_uuid menuentry "Debian" { - linux /EFI/vmlinuz-`uname -r` root=UUID=\$boot_uuid ro console=tty0 + linux /EFI/vmlinuz-`uname -r` root=UUID=\$boot_uuid ro console=ttyS0,115200 console=tty0 initrd /EFI/initrd.img-`uname -r` } -grub_platform if [ "\$grub_platform" = "efi" ]; then menuentry 'UEFI Firmware Settings' { fwsetup