A way to switch root and flash a new root filesystem
Go to file
2021-03-20 20:13:01 +01:00
.gitignore doc: change command for nuke the image 2020-10-29 20:43:35 +01:00
example_to_prepare_switch_root.sh wip commit final script 2021-03-20 20:13:01 +01:00
exclude.list opti for arm 2020-10-24 14:49:27 +02:00
README.md wip commit final script 2021-03-20 20:13:01 +01:00
switch_root.sh wip commit final script 2021-03-20 20:13:01 +01:00
Vagrantfile first version working 2020-10-24 13:06:22 +02:00

How to pivot_root

  1. Stop all uneeded services systemctl isolate rescue-ssh.target

  2. Create the new / on ramdisk mkdir /tmp/tmproot && mount none /tmp/tmproot -t tmpfs

  3. Create all the base directories mkdir /tmp/tmproot/{proc,sys,usr,var,run,oldroot,root}

  4. Copy the base symlink cp -ax /{bin,etc,mnt,sbin,lib} /tmp/tmproot/

  5. Copy /dev cp -a /dev /tmp/tmproot/dev

  6. Copy the libs for services lsof -Fn / | grep ^n/ | cut -c2- | sort -u | grep /usr | rsync --files-from=- / /tmp/tmproot/

  7. Copy other libs and binaries needed

    ldd /usr/bin/{wget,gzip,dd,mount,ls,cp,cat} | grep -o '/lib[^ ]*' | sed 's/^/\/usr/' | xargs -n1 readlink -f | rsync -v --files-from=- / /tmp/tmproot/

    ldd /usr/bin/{wget,gzip,dd,mount,ls,cp,cat} | grep -o '/lib[^ ]*' | sed 's/^/\/usr/' | rsync -lv --files-from=- / /tmp/tmproot/

    rsync -v /usr/bin/{wget,gzip,dd,mount,ls,cp,cat} /tmp/tmproot/usr/bin/

systemctl switch-root /tmp/tmproot/

OLLLD WAY NOT WORKING ANYMORE

unshare -m pivot_root /tmp/tmproot/ /tmp/tmproot/oldroot mount none /proc -t proc mount none /sys -t sysfs mount none /dev/pts -t devpts

wget -O - https://github.com/YunoHost/arm-images/releases/download/v2020.10/internetcube_4.0.8_v2020.10_lime2.img.gz | gzip -cd | dd iflag=fullblock bs=1M oflag=direct status=progress of=/dev/mmcblk0