self-flash-image/switch_root.sh

22 lines
621 B
Bash
Raw Normal View History

2020-10-24 13:06:22 +02:00
#!/bin/sh
sudo modprobe zram num_devices=4
2020-10-24 14:49:27 +02:00
echo 500M | sudo tee /sys/block/zram2/disksize
sudo mkfs.ext4 -m0 /dev/zram2
2020-10-24 13:06:22 +02:00
mkdir /tmp/sys
2020-10-24 14:49:27 +02:00
sudo mount /dev/zram2 /tmp/sys
2020-10-24 13:06:22 +02:00
sudo tar -cpSf - \
--acls --xattrs --selinux \
2020-10-24 14:49:27 +02:00
--exclude-from ./exclude.list \
2020-10-24 13:06:22 +02:00
/ |
sudo tar -xvf - \
--acls --xattrs --selinux \
-C /tmp/sys
sudo truncate -s0 /tmp/sys/etc/fstab
sudo swapoff -a
2020-10-24 13:58:33 +02:00
sudo mkdir -p /sysroot
2020-10-24 13:06:22 +02:00
sudo mount --rbind /tmp/sys /sysroot
sudo touch /etc/initrd-release
2021-03-20 20:13:01 +01:00
# it will stop all other services (isolate) and call systemctl switch-root /sysroot
sudo systemctl --no-block isolate initrd-switch-root