commit 5192e2b062f20d582918b5977b630f38514be48b Author: root Date: Fri Oct 23 20:54:49 2020 +0000 test v1 WIP diff --git a/prepare_switch_root.sh b/prepare_switch_root.sh new file mode 100755 index 0000000..4440097 --- /dev/null +++ b/prepare_switch_root.sh @@ -0,0 +1,15 @@ +#!/bin/bash +mkdir /tmp/tmproot && mount none /tmp/tmproot -t tmpfs +mkdir /tmp/tmproot/{proc,sys,usr,var,run,oldroot,root} +cp -ax /{bin,etc,mnt,sbin,lib} /tmp/tmproot/ +cp -a /dev /tmp/tmproot/dev +lsof -Fn / | grep ^n/ | cut -c2- | sort -u | grep /usr | rsync -v --files-from=- / /tmp/tmproot/ +NEEDED_BINARIES=(/usr/bin/wget /usr/bin/gzip /usr/bin/dd /usr/bin/mount /usr/bin/ls /usr/bin/cp /usr/bin/cat /usr/sbin/sshd /usr/bin/systemctl /lib/systemd/systemd) +for binary_path in "${NEEDED_BINARIES[@]}" +do + ldd $binary_path | grep -o '/lib[^ ]*' | sed 's/^/\/usr/' | xargs -n1 readlink -f | rsync -v --files-from=- / /tmp/tmproot/ + ldd $binary_path | grep -o '/lib[^ ]*' | sed 's/^/\/usr/' | rsync -lv --files-from=- / /tmp/tmproot/ + rsync -v $binary_path /tmp/tmproot$binary_path +done + +rsync -lv /sbin/init /tmp/tmproot/sbin/init