| 1 | {{{#!bash |
| 2 | export LANG='en_US.UTF-8' |
| 3 | export LANGUAGE='en_US.UTF-8' |
| 4 | export LC_ALL='en_US.UTF-8' |
| 5 | unset LC_ALL |
| 6 | |
| 7 | lvremove -f vg_main |
| 8 | vgremove -f vg_main |
| 9 | pvremove /dev/sda2 |
| 10 | rm -rf /dev/vg_main |
| 11 | sgdisk -Z /dev/sda |
| 12 | sgdisk -g \ |
| 13 | -n 1:0:+4M \ |
| 14 | -t 1:ef02 \ |
| 15 | -c 1:bios \ |
| 16 | -n 2:0:+512M \ |
| 17 | -t 2:8300 \ |
| 18 | -c 2:boot \ |
| 19 | -n 3 \ |
| 20 | -t 3:8e00 \ |
| 21 | -c 3:main \ |
| 22 | /dev/sda |
| 23 | pvcreate -f /dev/sda3 |
| 24 | vgcreate -y -f vg_main /dev/sda3 |
| 25 | lvcreate -y -L 7G -n lv_swap vg_main |
| 26 | lvcreate -y -l 100%FREE -n lv_root vg_main |
| 27 | mke2fs -F -t ext3 -m 1 -L boot /dev/sda1 |
| 28 | mke2fs -F -t ext3 -m 1 -L boot /dev/sda2 |
| 29 | mke2fs -F -t ext4 -m 1 -L root /dev/vg_main/lv_root |
| 30 | mount /dev/vg_main/lv_root /mnt |
| 31 | mkdir -vp /mnt/{dev,sys,proc,boot} |
| 32 | mount /dev/sda2 /mnt/boot |
| 33 | export DEBOOTSTRAP_DIR='/root/debootstrap' |
| 34 | curl -o - \ |
| 35 | http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.123.tar.gz | |
| 36 | tar xzf - |
| 37 | debootstrap/debootstrap --include locales,linux-image-amd64,grub-pc --arch amd64 buster /mnt http://mirror.yandex.ru/debian |
| 38 | |
| 39 | mount -o bind /dev /mnt/dev |
| 40 | mount -o bind /sys /mnt/sys |
| 41 | mount -o bind /proc /mnt/proc |
| 42 | |
| 43 | #/mnt/debootstrap/debootstrap.log |
| 44 | |
| 45 | cat <<EOF >/mnt/etc/fstab |
| 46 | /dev/mapper/vg_main-lv_root / ext4 noatime,errors=remount-ro 0 1 |
| 47 | /dev/sda2 /boot ext3 defaults 0 2 |
| 48 | /dev/mapper/vg_main-lv_swap none swap sw 0 0 |
| 49 | EOF |
| 50 | mkdir -vp /mnt/etc/network/interfaces.d/ /mnt/root/.ssh/ /mnt/etc/default/grub.d/ |
| 51 | cat <<EOF >/mnt/etc/network/interfaces |
| 52 | source /etc/network/interfaces.d/* |
| 53 | auto lo |
| 54 | iface lo inet loopback |
| 55 | auto eth0 |
| 56 | iface eth0 inet static |
| 57 | address 192.168.79.23 |
| 58 | netmask 24 |
| 59 | gateway 192.168.79.2 |
| 60 | EOF |
| 61 | cp -v ~/.ssh/authorized_keys /mnt/root/.ssh/ |
| 62 | echo xpsvic > /mnt/etc/hostname |
| 63 | cat <<EOF > /mnt/etc/default/grub.d/net-ifnames.cfg |
| 64 | # set net.ifnames=0 |
| 65 | GRUB_CMDLINE_LINUX_DEFAULT="\${GRUB_CMDLINE_LINUX_DEFAULT} net.ifnames=0" |
| 66 | EOF |
| 67 | |
| 68 | cat <<EOF >/mnt/etc/apt/sources.list |
| 69 | deb http://mirror.corbina.net/debian/ buster main non-free contrib |
| 70 | deb-src http://mirror.corbina.net/debian/ buster main non-free contrib |
| 71 | deb http://security.debian.org/debian-security buster/updates main contrib non-free |
| 72 | deb-src http://security.debian.org/debian-security buster/updates main contrib non-free |
| 73 | deb http://mirror.corbina.net/debian/ buster-updates main contrib non-free |
| 74 | deb-src http://mirror.corbina.net/debian/ buster-updates main contrib non-free |
| 75 | deb http://mirror.corbina.net/debian/ buster-backports main contrib non-free |
| 76 | deb-src http://mirror.corbina.net/debian/ buster-backports main contrib non-free |
| 77 | EOF |
| 78 | |
| 79 | echo 'en_US.UTF-8 UTF-8' > /mnt/etc/locale.gen |
| 80 | chroot /mnt locale-gen |
| 81 | |
| 82 | chroot /mnt hostname -F /etc/hostname |
| 83 | export DEBIAN_FRONTEND=noninteractive |
| 84 | chroot /mnt apt-get update |
| 85 | #echo 'GRUB_CMDLINE_LINUX_DEFAULT="--verbose nosplash debug"' >>/mnt/etc/default/grub |
| 86 | echo 'GRUB_CMDLINE_LINUX_DEFAULT="--verbose nosplash"' >>/mnt/etc/default/grub |
| 87 | chroot /mnt update-initramfs -u |
| 88 | chroot /mnt update-grub2 |
| 89 | |
| 90 | # chroot /mnt grub-probe --verbose --device /dev/vg_main/lv_root --target=fs_uuid |
| 91 | # chroot /mnt grub-probe --verbose --device /dev/mapper/vg_main-lv_root --target=fs_uuid |
| 92 | # grub-probe: info: cannot open `/boot/grub/device.map': No such file or directory. |
| 93 | # grub-probe: info: /dev/vg_main/lv_root is not present. |
| 94 | # WARNING: Device /dev/loop0 not initialized in udev database even after waiting 10000000 microseconds. |
| 95 | # WARNING: Device /dev/sda not initialized in udev database even after waiting 10000000 microseconds. |
| 96 | # WARNING: Device /dev/vg_main/lv_swap not initialized in udev database even after waiting 10000000 microseconds. |
| 97 | # WARNING: Device /dev/sda1 not initialized in udev database even after waiting 10000000 microseconds. |
| 98 | |
| 99 | chroot /mnt grub-install --debug-image=all --boot-directory=/boot /dev/sda |
| 100 | chroot /mnt grub-install --debug-image=all --boot-directory=/boot /dev/sda1 |
| 101 | |
| 102 | umount /mnt/sys |
| 103 | umount /mnt/proc |
| 104 | chroot /mnt apt-get -y install lvm2 |
| 105 | mount -o bind /dev /mnt/dev |
| 106 | chroot /mnt update-initramfs -u |
| 107 | umount -R /mnt |
| 108 | sync |
| 109 | }}} |