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/sda2
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
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 locales,linux-image-amd64,grub-pc --arch amd64 buster /mnt http://mirror.yandex.ru/debian
#/mnt/debootstrap/debootstrap.log
cat <<EOF >/mnt/etc/fstab
/dev/mapper/vg_main-lv_root / ext4 noatime,errors=remount-ro 0 1
/dev/sda2 /boot ext3 defaults 0 2
/dev/mapper/vg_main-lv_swap none swap sw 0 0
EOF
mkdir -vp /mnt/etc/network/interfaces.d/ /mnt/root/.ssh/ /mnt/etc/default/grub.d/
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/apt/sources.list
deb http://mirror.corbina.net/debian/ buster main non-free contrib
deb-src http://mirror.corbina.net/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.corbina.net/debian/ buster-updates main contrib non-free
deb-src http://mirror.corbina.net/debian/ buster-updates main contrib non-free
deb http://mirror.corbina.net/debian/ buster-backports main contrib non-free
deb-src http://mirror.corbina.net/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 debug"' >>/mnt/etc/default/grub
for d in dev sys proc; do mount -o bind /${d} /mnt/${d}; done
chroot /mnt update-grub2
# chroot /mnt grub-probe --verbose --device /dev/vg_main/lv_root --target=fs_uuid
# chroot /mnt grub-probe --verbose --device /dev/mapper/vg_main-lv_root --target=fs_uuid
# grub-probe: info: cannot open `/boot/grub/device.map': No such file or directory.
# grub-probe: info: /dev/vg_main/lv_root is not present.
# WARNING: Device /dev/loop0 not initialized in udev database even after waiting 10000000 microseconds.
# WARNING: Device /dev/sda not initialized in udev database even after waiting 10000000 microseconds.
# WARNING: Device /dev/vg_main/lv_swap not initialized in udev database even after waiting 10000000 microseconds.
# WARNING: Device /dev/sda1 not initialized in udev database even after waiting 10000000 microseconds.
chroot /mnt grub-install --boot-directory=/boot /dev/sda
umount /mnt/proc
chroot /mnt apt-get -y install lvm2
for d in proc; do mount -o bind /${d} /mnt/${d}; done
chroot /mnt update-initramfs -u
umount -R /mnt
sync