fork-pty inside chroot in Ubuntu 18

It took way too long for me to figure this out, so maybe this will be helpful for someone else:
This is how you make fork-pty work inside a chroot in Ubuntu 18

sudo mount -t devpts none "/home/guest2/dev/pts" -o ptmxmode=0666,newinstance
sudo mount --bind /home/guest2/dev/pts/ptmx /home/guest2/dev/ptmx

Where /home/guest2 is the chroot folder.

fork-pty is used to create pseuodo terminals. It's used in the nodejs pty module. Which stopped working for me when I upgraded from Ubuntu-16 to Ubuntu-18. Because I was running it in a chroot.

What finally lead me to the solution was to read about terminal special files, the actual manual for mount, and finally a stack-overflow question with the exact commands.

I also read old tutorials on how you used to do it, read the source code for pty.js and asked on IRC (where I did not get any help, although IRC is usually awesome)

Lesson learned

Start with the manual for the command you are running.

Often we just want to get a quick fix, and get on with our lives. But sometimes "quick" can turn into hours, and even days, so sometimes it pays off to actually read the damn manual.


Written by Mars 22, 2019.


Follow me via RSS:   RSS https://z├Ąta.com/rss_en.xml (copy to feed-reader)
or Github:   Github https://github.com/Z3TA