1

Using Ubuntu 20.04. I can disable Overlay file system by manually calling a command which creates a shell, then calling a second script from within this new shell. However I would like to be able to script it so I can auto update a pc.

Here are the two scripts I run to diable OverlayFS:

Script 1: Open a shell that allows permanent changes (overlayroot-chroot creates a new shell)

#!/bin/bash
# Enter chroot mode, which allows one to make permanent changes to / parition

echo "Enter mood to make permanent changes"
echo "Press CTRL+D to exit when finished editing"
sudo overlayroot-chroot

Script 2: Make the changes

#!/bin/bash
# Disable OverlayFS

echo "Disable overlayfs (read only file system at /)"
FILE=/etc/overlayroot.conf
cat << EOF | sudo tee $FILE
overlayroot_cfgdisk="disabled"
overlayroot=""
EOF

echo "COMPLETE."
echo "Press CTRL+D to exit chroot mode."
echo "Then 'sudo reboot' for the changes to take effect."

Script 2 needs to run within the shell that script 1 created.

But how does one pass the command to run into the new created shell?

2 Answers 2

1

That doesn't work. Each script spawns a new shell with it's own PID.
I would create a bash function in script2.sh and source script2 in script1.
Call the function from script2 in script1.

script1

source ./script2.sh
# call the function
do_stuff

script2

do_stuff() {
  echo "hello world"
}
1
  • Thanks for that, sourcing an important part. The problem was inside script1, is a 3rd party command that I can't change, that needs to run script 2, but a simple echo did the trick. Commented Mar 12, 2022 at 10:09
0

Solved it by simply echoing the command to run into overlayroot-chroot (which I have not had success with before):

echo "source /home/path/to/overlayfs/disable.sh" | sudo overlayroot-chroot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .