From c9d4b4a69a7ad4a5f2039c4edcc433e3dafcc2b4 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 28 Jan 2020 19:41:23 +0300 Subject: [PATCH] Simple script to prepare a diskless PXE/NFS Debian Buster --- .gitignore | 1 + debian_nfs.sh | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 .gitignore create mode 100755 debian_nfs.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..05b023b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +authorized_keys diff --git a/debian_nfs.sh b/debian_nfs.sh new file mode 100755 index 0000000..68a6194 --- /dev/null +++ b/debian_nfs.sh @@ -0,0 +1,118 @@ +#!/bin/bash +# Prepare diskless NFS Debian Buster with tmpfs overlay +# The idea is just to boot a node and expose SSH +# NFS export is /home/nfsboot +# TFTP root is /home/tftp + +set -e + +SERVER=172.31.1.5 +SUBNET=172.31.1.0/24 + +CFG=`dirname $0`/debian_nfs.conf +[ -f "$CFG" ] && . $CFG + +apt-get -y install pxelinux syslinux-common nfs-kernel-server dnsmasq + +echo "/home/nfsboot $SUBNET(ro,no_root_squash)" >> /etc/exports + +service nfs-kernel-server restart +service rpcbind restart + +cat >/etc/dnsmasq.conf < /etc/hostname + +ln -s /proc/mounts /etc/mtab + +echo 'deb http://http.debian.net/debian buster main contrib non-free' > /etc/apt/sources.list +echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf +echo 'APT::Install-Suggests "false";' >> /etc/apt/apt.conf +echo en_US.UTF-8 UTF-8 > /etc/locale.gen +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 zip unzip curl smartmontools hdparm python3 bzip2 xz-utils file debootstrap \ + openssh-server locales nfs-common linux-image-amd64 firmware-linux firmware-linux-nonfree firmware-amd-graphics firmware-realtek firmware-bnx2 firmware-bnx2x busybox + +echo '/dev/nfs / nfs tcp,nolock,ro,soft 0 0' > /etc/fstab +echo 'tmpfs /tmp tmpfs defaults 0 0' >> /etc/fstab +rm -rf /var/tmp +ln -s /tmp /var/tmp + +if ! grep -q "^overlay" /etc/initramfs-tools/modules; then + echo overlay >> /etc/initramfs-tools/modules +fi + +cat >/etc/initramfs-tools/initramfs.conf </etc/rc.local <pxelinux.cfg/default <