diff --git a/debian_nfs.sh b/debian_nfs.sh index 86019a4..7691b38 100755 --- a/debian_nfs.sh +++ b/debian_nfs.sh @@ -48,6 +48,9 @@ cp /home/overlayroot/init-bottom-overlay /home/nfsboot/etc/initramfs-tools/scrip mkdir -p /home/nfsboot/root/.ssh cp `dirname $0`/authorized_keys /home/nfsboot/root/.ssh +# Copy install script +cp `dirname $0`/install.sh /home/nfsboot/root/ + chroot /home/nfsboot < /etc/hostname @@ -62,7 +65,7 @@ echo ru_RU.UTF-8 UTF-8 >> /etc/locale.gen apt-get update apt-get install -y network-manager mc less git wget ca-certificates linux-cpupower iperf3 \ - zip unzip curl smartmontools hdparm fio pciutils usbutils python3 bzip2 + zip unzip curl smartmontools hdparm fio pciutils usbutils python3 bzip2 dosfstools grub-efi-amd64 \ xz-utils file debootstrap ethtool nvme-cli openssh-server locales nfs-common \ linux-image-amd64 firmware-linux firmware-linux-nonfree \ firmware-amd-graphics firmware-realtek firmware-bnx2 firmware-bnx2x busybox diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..9abd463 --- /dev/null +++ b/install.sh @@ -0,0 +1,96 @@ +#!/bin/bash +# Copy NFS-booted Debian to the local drive and setup boot + +set -e + +DEV=$1 + +if [ ! -b $DEV ]; then + echo "USAGE: $0 /dev/sdXXX (sdXXX must be a block device)" + exit 1 +fi + +PART=${DEV}1 + +mkdir -p /root/target + +# Unmount old chroot-mounts if any +for i in boot/efi dev/pts dev proc sys; do + if grep -q " /root/target/$i " /proc/mounts; then + umount /root/target/$i + fi +done +if grep -q " /root/target " /proc/mounts; then + umount /root/target +fi + +# Check if $PART already contains a filesystem +if mount $PART /root/target &>/dev/null; then + umount /root/target + if [ "$WIPE" = "1" ]; then + echo "Device $PART already contains a filesystem. WIPE=1 specified. Wiping" + wipefs -a $DEV + else + echo "Device $PART already contains a filesystem. Wipe it first" + exit 1 + fi +fi + +# Make 2 partitions: rootfs and EFI System +SIZE=`blockdev --getsz $DEV` +ROOT_SIZE=$((SIZE-2048-1048576)) +EFISYSTEM_START=$((SIZE-1048576)) +sfdisk $DEV </root/target/etc/initramfs-tools/modules +cat >/root/target/etc/initramfs-tools/initramfs.conf < /root/target/etc/rc.local + +# Set fstab +cat >/root/target/etc/fstab <