wiki:linux/debootstrap-install

Version 14 (modified by root, at 2020-06-16T07:38:25Z) (diff)

--

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/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.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"' >>/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-install --boot-directory=/boot /dev/sda
chroot /mnt systemctl disable networking
chroot /mnt systemctl enable systemd-networkd
chroot /mnt usermod -p '' root
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