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)

# 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

# Disable OverlayFS

echo "Disable overlayfs (read only file system at /)"
cat << EOF | sudo tee $FILE

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


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.


source ./script2.sh
# call the function


do_stuff() {
  echo "hello world"
  • 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. Mar 12 at 10:09

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.