ajouts pour raid10 online

This commit is contained in:
Jérémy Lecour 2020-10-23 14:18:46 +02:00 committed by Jérémy Lecour
parent 87e2026fd1
commit 097140f962

View file

@ -144,82 +144,103 @@ mkdir -p rootfs/var && mount -LVAR rootfs/var
mkdir -p rootfs/usr && mount -LUSR rootfs/usr
sleep 1
# mount partitions
mount -LROOTFS rootfs
mount -LHOME home
mount -LVAR var
mount -LUSR usr
# Copy data from RAM.
rsync -a root_in_ram/home/ home/
rsync -a root_in_ram/var/ var/
rsync -a root_in_ram/usr/ usr/
rsync -a root_in_ram/home/ rootfs/home/
rsync -a root_in_ram/var/ rootfs/var/
rsync -a root_in_ram/usr/ rootfs/usr/
rsync -a \
--exclude="home/**" \
--exclude="var/**" \
--exclude="usr/**" \
root_in_ram/ rootfs/
umount home var usr
sleep 1
# Generate fstab.
cat <<EOT > rootfs/etc/fstab
cat <<EOT>rootfs/etc/fstab
LABEL=ROOTFS / ext4 errors=remount-ro 0 1
LABEL=BOOT /boot ext4 defaults 0 2
/dev/nvme0n1p1 /boot/efi vfat defaults 0 2
LABEL=EFI_SYSPART /boot/efi vfat defaults 0 2
LABEL=HOME /home ext4 defaults 0 2
LABEL=TMP /tmp ext4 defaults 0 2
LABEL=USR /usr ext4 defaults 0 2
LABEL=VAR /var ext4 defaults 0 2
LABEL=SWAP1 none swap sw 0 0
LABEL=SWAP2 none swap sw 0 0
LABEL=SWAP3 none swap sw 0 0
LABEL=SWAP4 none swap sw 0 0
LABEL=SWAP1 none swap sw 0 2
LABEL=SWAP2 none swap sw 0 2
LABEL=SWAP3 none swap sw 0 2
EOT
# Chroot + reconfigure grub-pc
# Chroot and install lvm2 + reconfigure grub-pc
mount -t proc none /mnt/rootfs/proc
mount -o bind /dev /mnt/rootfs/dev
mount -o bind /dev/pts /mnt/rootfs/dev/pts
mount -t sysfs sys /mnt/rootfs/sys
rm -rf /mnt/rootfs/boot/*
sleep 1
chroot /mnt/rootfs/ bash
sleep 1
export LC_ALL=C
mount /boot
mount /boot/efi
mount /usr
mount /var
mkdir -p /boot && mount /boot
mkdir -p /boot/efi && mount /dev/nvme0n1p1 /boot/efi
mount /tmp
chmod 1777 /tmp
sleep 1
# generate RAID configuration
/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
# apt install -y debconf-utils apt-utils
# sleep 1
# cat <<EOT>/tmp/grub-selections
# grub-efi-amd64 grub2/force_efi_extra_removable boolean true
# grub-efi-amd64 grub2/linux_cmdline_default string quiet
# grub-efi-amd64 grub2/update_nvram boolean true
# grub-efi-amd64 grub2/linux_cmdline string
# grub-pc grub-pc/postrm_purge_boot_grub boolean true
# EOT
# sleep 1
# debconf-set-selections /tmp/grub-selections
# sleep 1
# dpkg-reconfigure --frontend=noninteractive grub-pc
# sleep 1
# purge des paquets de Grub et du noyau, pour réinitialiser complètement les config
apt purge -y grub-common grub-efi-amd64 grub-efi-amd64-bin grub2-common
rm -rf /etc/default/grub.d
apt purge -y os-prober grub-common grub-efi grub-efi-amd64 grub-efi-amd64-bin grub-pc grub2-common
sleep 1
# purge des kernels
for kernel_pkg in $(dpkg -l | grep linux-image | awk '{ print $2 }'); do apt purge -y $kernel_pkg; done
sleep 1
# réinstallation des paquets
# Note: bien installer Grub sur les 4 disques nvme[0123]n1
apt install -y grub-common grub-efi grub-efi-amd64 grub-efi-amd64-bin grub2-common linux-image-amd64
apt install -y lvm2 grub-common grub-efi grub-efi-amd64 grub-efi-amd64-bin grub2-common linux-image-amd64
sleep 1
apt purge -y os-prober
# En cas d'erreur à l'install/config de Grub, il faut vérifier si le RAID est OK
# cat/proc/mdstat
grub-install /dev/nvme0n1
sleep 1
grub-install /dev/nvme1n1
sleep 1
grub-install /dev/nvme2n1
sleep 1
# Questions "update-grub":
# * Linux command line:
# * Linux default command line: quiet
# * Force extra installation to the EFI removable media path? Yes
# * Update NVRAM variables to automatically boot into Debian? Yes
update-grub
# dpkg-reconfigure --frontend=noninteractive grub-efi-amd64
dpkg-reconfigure grub-efi-amd64
sleep 1
# paquets utiles pour evolixisation par Ansible
apt install -y sudo python python-apt
# ajouter l'utilisateur dans le groupe sudo
# ça facilite le passage d'Ansible (sans root)
usermod -a -G sudo jlecour
passwd jlecour
# change root password
passwd
# permit root login via SSH with password
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sleep 1
exit