only rune one switch_root process

This commit is contained in:
Tobias Powalowski 2023-02-14 09:06:47 +01:00
parent 4462268f58
commit d5ffaa60ab
2 changed files with 17 additions and 16 deletions

View file

@ -26,12 +26,13 @@ _local_mode () {
# fstrim <mountpoint> for manual action # fstrim <mountpoint> for manual action
# it needs some seconds to get RAM free on delete! # it needs some seconds to get RAM free on delete!
_switch_root_zram() { _switch_root_zram() {
if ! [[ -e "/.switch_root" ]]; then
touch /.switch_root
clear clear
echo -e "Moving \e[1mrootfs\e[m to btrfs on 4G \e[1m/dev/zram0\e[m. This needs some time..." echo -e "Moving \e[1mrootfs\e[m to btrfs on 4G \e[1m/dev/zram0\e[m. This needs some time..."
[[ -d /sysroot ]] || mkdir /sysroot [[ -d /sysroot ]] || mkdir /sysroot
modprobe zram &>/dev/null modprobe zram &>/dev/null
modprobe zstd &>/dev/null modprobe zstd &>/dev/null
sleep 3
echo "zstd" >/sys/block/zram0/comp_algorithm echo "zstd" >/sys/block/zram0/comp_algorithm
echo "4G" >/sys/block/zram0/disksize echo "4G" >/sys/block/zram0/disksize
mkfs.btrfs /dev/zram0 &>/dev/null mkfs.btrfs /dev/zram0 &>/dev/null
@ -41,6 +42,7 @@ rsync -aAXv --numeric-ids \
"/" "/sysroot" / /sysroot &>/dev/null "/" "/sysroot" / /sysroot &>/dev/null
touch /etc/initrd-release touch /etc/initrd-release
systemctl start initrd-switch-root systemctl start initrd-switch-root
fi
} }
_enter_shell() { _enter_shell() {

View file

@ -35,7 +35,6 @@ setfont consolefont.psf.gz -C /dev/console
echo -e "\e[1mStep 1/4:\e[m Creating /dev/zram0 with zstd compression..." echo -e "\e[1mStep 1/4:\e[m Creating /dev/zram0 with zstd compression..."
modprobe zram &>/dev/null modprobe zram &>/dev/null
modprobe zstd &>/dev/null modprobe zstd &>/dev/null
read -r -t 3
echo "zstd" >/sys/block/zram0/comp_algorithm echo "zstd" >/sys/block/zram0/comp_algorithm
echo "4G" >/sys/block/zram0/disksize echo "4G" >/sys/block/zram0/disksize
echo -e "\e[1mStep 2/4:\e[m Creating btrfs on /dev/zram0..." echo -e "\e[1mStep 2/4:\e[m Creating btrfs on /dev/zram0..."