Add auto-installation script
parent
5f2aa4e40a
commit
d579406bbc
|
@ -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 <<EOF
|
||||
|
||||
echo net-client > /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
|
||||
|
|
|
@ -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 <<EOF
|
||||
label: gpt
|
||||
${DEV}1 : start=2048, size=$ROOT_SIZE, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
|
||||
${DEV}2 : start=$EFISYSTEM_START, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
|
||||
EOF
|
||||
|
||||
mkfs.ext4 -F $PART
|
||||
mkfs.vfat -F32 ${DEV}2
|
||||
|
||||
UUID=`blkid -o value -s UUID $PART`
|
||||
EFIUUID=`blkid -o value -s PARTUUID ${DEV}2`
|
||||
|
||||
# Mount new filesystems
|
||||
mount $PART /root/target
|
||||
mkdir -p /root/target/boot/efi
|
||||
mount ${DEV}2 /root/target/boot/efi
|
||||
|
||||
# Copy Debian to the new partition
|
||||
cp -av /overlay/lower/* /root/target
|
||||
|
||||
# Remove overlayroot from initramfs settings
|
||||
rm /root/target/etc/initramfs-tools/hooks/hooks-overlay
|
||||
rm /root/target/etc/initramfs-tools/scripts/init-bottom/init-bottom-overlay
|
||||
>/root/target/etc/initramfs-tools/modules
|
||||
cat >/root/target/etc/initramfs-tools/initramfs.conf <<EOF
|
||||
MODULES=most
|
||||
BUSYBOX=auto
|
||||
KEYMAP=n
|
||||
COMPRESS=gzip
|
||||
DEVICE=
|
||||
EOF
|
||||
|
||||
# Remove ssh-keygen -A
|
||||
(echo '#!/bin/bash'; echo 'exit 0') > /root/target/etc/rc.local
|
||||
|
||||
# Set fstab
|
||||
cat >/root/target/etc/fstab <<EOF
|
||||
UUID=$UUID / ext4 rw,relatime 0 0
|
||||
PARTUUID=$EFIUUID /boot/efi vfat defaults 0 0
|
||||
EOF
|
||||
|
||||
# Install GRUB
|
||||
for i in dev dev/pts proc sys; do mount --bind /$i /root/target/$i; done
|
||||
chroot /root/target <<EOF
|
||||
ssh-keygen -A
|
||||
update-initramfs -u -k all
|
||||
update-grub
|
||||
grub-install --target=x86_64-efi $DEV
|
||||
EOF
|
||||
for i in dev/pts dev proc sys; do umount /root/target/$i; done
|
||||
|
||||
# Unmount filesystems
|
||||
umount /root/target/boot/efi
|
||||
umount /root/target
|
Loading…
Reference in New Issue