export LANG='en_US.UTF-8'
export LANGUAGE='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
unset LC_ALL
lvremove -f vg_main
vgremove -f vg_main
pvremove /dev/sda3
rm -rf /dev/vg_main
sgdisk -Z /dev/sda
sgdisk -g \
-n 1:0:+4M \
-t 1:ef02 \
-c 1:bios \
-n 2:0:+512M \
-t 2:8300 \
-c 2:boot \
-n 3 \
-t 3:8e00 \
-c 3:main \
/dev/sda
pvcreate -f /dev/sda3
vgcreate -y -f vg_main /dev/sda3
lvcreate -y -L 7G -n lv_swap vg_main
lvcreate -y -l 100%FREE -n lv_root vg_main
mke2fs -F -t ext3 -m 1 -L boot /dev/sda1
mke2fs -F -t ext3 -m 1 -L boot /dev/sda2
mke2fs -F -t ext4 -m 1 -L root /dev/vg_main/lv_root
mkswap -L swap /dev/vg_main/lv_swap
mount /dev/vg_main/lv_root /mnt
mkdir -vp /mnt/{dev,sys,proc,boot}
mount /dev/sda2 /mnt/boot
export DEBOOTSTRAP_DIR='/root/debootstrap'
curl -o - \
http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.123.tar.gz |
tar xzf -
debootstrap/debootstrap --include lvm2,linux-image-amd64,grub-pc,locales,openssh-server --arch amd64 buster /mnt http://mirror.yandex.ru/debian
#/mnt/debootstrap/debootstrap.log
cat <<EOF >/mnt/etc/fstab
# fstab
/dev/mapper/vg_main-lv_root / ext4 noatime,nodiratime,errors=remount-ro 0 1
/dev/sda2 /boot ext3 noatime,nodiratime 0 2
/dev/mapper/vg_main-lv_swap none swap sw 0 0
EOF
mkdir -vp /mnt/root/.ssh/ /mnt/etc/default/grub.d/
scp -o StrictHostKeyChecking=no 192.168.77.114:/home/raven/.ssh/authorized_keys /mnt/root/.ssh/
echo xpsvic > /mnt/etc/hostname
cat <<EOF > /mnt/etc/default/grub.d/net-ifnames.cfg
# set net.ifnames=0
GRUB_CMDLINE_LINUX_DEFAULT="\${GRUB_CMDLINE_LINUX_DEFAULT} net.ifnames=0"
EOF
cat <<EOF > /mnt/etc/systemd/network/generic.network
[Match]
Name=*
[Network]
DHCP=yes
EOF
cat <<EOF >/mnt/etc/apt/sources.list
deb http://mirror.yandex.ru/debian/ buster main non-free contrib
deb-src http://mirror.yandex.ru/debian/ buster main non-free contrib
deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
deb http://mirror.yandex.ru/debian/ buster-updates main contrib non-free
deb-src http://mirror.yandex.ru/debian/ buster-updates main contrib non-free
deb http://mirror.yandex.ru/debian/ buster-backports main contrib non-free
deb-src http://mirror.yandex.ru/debian/ buster-backports main contrib non-free
EOF
echo 'en_US.UTF-8 UTF-8' > /mnt/etc/locale.gen
chroot /mnt locale-gen
chroot /mnt hostname -F /etc/hostname
export DEBIAN_FRONTEND=noninteractive
chroot /mnt apt-get update
echo 'GRUB_CMDLINE_LINUX_DEFAULT="--verbose nosplash"' >>/mnt/etc/default/grub
for d in dev sys proc; do mount -o bind /${d} /mnt/${d}; done
chroot /mnt update-initramfs -u
# because https://www.reddit.com/r/Gentoo/comments/bce0d8/long_delay_starting_the_lvm_service_device_not/
sed -i 's#md_component_detection = 1#md_component_detection = 0#' /mnt/etc/lvm/lvm.conf
chroot /mnt update-grub2
sed -i 's#md_component_detection = 0#md_component_detection = 1#' /mnt/etc/lvm/lvm.conf
chroot /mnt grub-install --boot-directory=/boot /dev/sda
chroot /mnt systemctl disable networking
chroot /mnt systemctl enable systemd-networkd
chroot /mnt usermod -p '' root
umount -R /mnt
sync