From 66dd8276289a072aab0b03e8e56c69b64a41dae5 Mon Sep 17 00:00:00 2001 From: Francois Lesueur Date: Tue, 7 Feb 2023 22:11:03 +0100 Subject: [PATCH] =?UTF-8?q?passage=20=C3=A0=20btrfs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/snster-kaz/kaz/prod/provision.sh | 20 +++++++++++++++----- files/vm-provision.sh | 23 ++++++++++++++++++----- files/vm-upgrade.sh | 2 ++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/files/snster-kaz/kaz/prod/provision.sh b/files/snster-kaz/kaz/prod/provision.sh index d4ceeec..85ab1c2 100644 --- a/files/snster-kaz/kaz/prod/provision.sh +++ b/files/snster-kaz/kaz/prod/provision.sh @@ -18,7 +18,7 @@ DEBIAN_FRONTEND=noninteractive apt-get autoremove -y # KAZ specific things #installation de docker, docker-compose et on y fourre le user debian dans le groupe idoine -DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose docker-clean git apg curl sudo unzip rsync fuse-overlayfs +DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io docker-compose docker-clean git apg curl sudo unzip rsync btrfs-progs # fuse-overlayfs usermod -G docker debian # activation dans alias dans /root/.bashrc sed -i \ @@ -49,13 +49,23 @@ echo "export SNSTERGUARD='true'" >> /root/.bashrc # On active fuse-overlayfs pour docker cat >> /etc/docker/daemon.json <> /etc/rc.local -chmod +x /etc/rc.local +#mknod -m 666 /dev/fuse c 10 229 +#echo -e '#!/bin/sh\nmknod -m 666 /dev/fuse c 10 229' >> /etc/rc.local +#chmod +x /etc/rc.local + +# lxc.cgroup2.devices.allow = b 7:* rwm +# lxc.cgroup2.devices.allow = c 10:237 rwm +# +# mknod -m 666 /dev/loop0 b 7 0 +# mknod -m 666 /dev/loop-control c 10 237 +# truncate -s 30G /root/varlibdocker.img +# mkfs.btrfs /root/varlibdocker.img +# losetup -f /root/varlibdocker.img +# mount /dev/loop0 /var/lib/docker # On place les certifs if [ -d letsencrypt ]; then diff --git a/files/vm-provision.sh b/files/vm-provision.sh index 1dad524..2b6d5bc 100755 --- a/files/vm-provision.sh +++ b/files/vm-provision.sh @@ -40,7 +40,7 @@ export DebugLog="${VAGRANT_SRC_DIR}/log/log-vagrant-$(date +%y-%m-%d-%T)-" DEBIAN_FRONTEND=noninteractive apt-get --allow-releaseinfo-change update DEBIAN_FRONTEND=noninteractive apt-get -y upgrade DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade - DEBIAN_FRONTEND=noninteractive apt-get install -y apg curl git sudo unzip rsync firefox-esr tcpdump net-tools mousepad wireshark swapspace whois ldap-utils python3-lxc lxc python3-pygraphviz python3-pil python3-yaml imagemagick # could be with --no-install-recommends + DEBIAN_FRONTEND=noninteractive apt-get install -y apg curl git sudo unzip rsync firefox-esr tcpdump net-tools mousepad wireshark swapspace whois ldap-utils python3-lxc lxc python3-pygraphviz python3-pil python3-yaml imagemagick btrfs-progs # could be with --no-install-recommends DEBIAN_FRONTEND=noninteractive apt-get install -y xfce4 lightdm xfce4-terminal xserver-xorg gitk # needs to install recommends ssh-keygen -t rsa -b 4096 -N '' <<<$'\ny' @@ -181,9 +181,20 @@ EOF git clone https://framagit.org/flesueur/snster.git cd snster # git checkout tags/v1.1.0 - git checkout c8b46866b598996e33120c9cae88b5a30725ed79 + git checkout fe59ef1f ./install.sh + # BTRFS avec hotfix sale de SNSTER + freespace=`df /root | awk '/[0-9]%/{print $(NF-2)}'` + btrsize=$(( $freespace - 5000000 )) # on laisse 5GB libres + truncate -s ${btrsize}k /root/btrfs.img + mkfs.btrfs -f /root/btrfs.img + echo "/root/btrfs.img /var/lib/lxc btrfs loop 0 0" >> /etc/fstab + mount /var/lib/lxc + #losetup -f /root/btrfs.img + #mount /dev/loop0 /var/lib/lxc + sed -i -e "s/template=self.template/template=self.template, bdevtype='btrfs'/" /usr/local/lib/python3.9/dist-packages/backends/LxcBackend.py + # SNSTER KAZ # cp -ar ${VAGRANT_SRC_DIR}/templates /root cp -ar ${VAGRANT_SRC_DIR}/snster-kaz /root @@ -193,9 +204,11 @@ EOF cp -ar /etc/letsencrypt /root/snster-kaz/isp-a/home/ # On monte le filesystem de kaz-prod dans le /kaz de la VM pour le dév (en nofail) - mkdir /kaz-prod /kaz - echo "overlay /kaz-prod overlay lowerdir=/var/lib/lxc/sr-masters-bullseye/rootfs,upperdir=/var/lib/lxc/kaz-kaz-prod/overlay/delta,workdir=/var/lib/lxc/kaz-kaz-prod/overlay/work,nofail 0 0" >> /etc/fstab - echo "/kaz-prod/kaz /kaz none bind,nofail 0 0" >> /etc/fstab +# mkdir /kaz-prod /kaz +# echo "overlay /kaz-prod overlay lowerdir=/var/lib/lxc/sr-masters-bullseye/rootfs,upperdir=/var/lib/lxc/kaz-kaz-prod/overlay/delta,workdir=/var/lib/lxc/kaz-kaz-prod/overlay/work,nofail 0 0" >> /etc/fstab +# echo "/kaz-prod/kaz /kaz none bind,nofail 0 0" >> /etc/fstab + ln -s /var/lib/lxc/kaz-kaz-prod/rootfs/ /kaz-prod + ln -s /kaz-prod/kaz /kaz # On met le KAZGUARD pour la mise au point echo "export KAZGUARD='true'" >> /root/.bashrc diff --git a/files/vm-upgrade.sh b/files/vm-upgrade.sh index 0e83a3c..af79a2f 100755 --- a/files/vm-upgrade.sh +++ b/files/vm-upgrade.sh @@ -11,6 +11,8 @@ cd /root/snster git switch main git pull ./install.sh +# hotfix pour btrfs +sed -i -e "s/template=self.template/template=self.template, bdevtype='btrfs'/" /usr/local/lib/python3.9/dist-packages/backends/LxcBackend.py # On récupère le dernier kaz-vagrant cd /tmp