Added:
After reading suggested as duplicate Which of proc, sys etc. should be bind-mounted (or not) when chrooting into a "replacement" distribution? :
How I know:
- it is customary to invoke mounts of sysfs, proc, dev, dev/pts before
chroot, - I guess using
bindinmount -o bind /dev dev/one gives assess to same devices as the system has from wherechrootis run.
However it does not explain why I got the error is a setup that from what I see does not differ in relevant parts to setup where the error was not in output. Please somebody help to learn more how Linux works under the hood. TIA
Original:
I've been doing scripting using chroot for Linux Mint 20.2. On 20.2 I've been chrooting into mounted ISO distro of 20.2, sudo worked as expected.
Recently I've tried to chroot from 20.2 to ISO distro 21 and when running sudo mount -t proc proc /proc after chroot got
sudo: unable to allocate pty: No such device I've compared contents of /dev and /dev/pts when chrooted in 20.2 and 21 with ls -a, contents matched, also /dev/pts was empty.
I understand when chrooted command runs as root as user is root, however I do scripting partly to learn Linux under the hood and want to understand the reason for the error. Web search got links to similar error when connecting to servers, I could not see there info explaining behavior of my setup.
uname -a outputs same "5.4.0-74-generic" for both 20.2 and 21; replacing sudo with sudo --stdin still resulted in "sudo: unable to allocate pty: No such device", I recall there was a time when adding --stdin got rid of some error (don't recall exactly what the error was), I've read related What's the purpose of using `sudo -S` explicitly?
sudo stops to output "sudo: unable to allocate pty: No such device" after mount -t devpts devpts /dev/pts, however output becomes
*** closefrom failed to close a file descriptor ***: terminated Aborted After also running mount -t proc proc /proc sudo works as expected, but mount /proc w/out /dev/pts still results in previous "unable to allocate pty", so I'm puzzled (as stated above contents of /dev/pts match and empty in both working and non-working cases).
What else can I check and try? TIA
sudoworked in a chroot without these mounts at all? I don't think it has ever worked that way for me.Ventoyreplacingquiet splashwithtoramwith legacy boot to be exact, then (optional? - later noted it was mounted after boot already) re-plugged USB to get access to ISO file from system, double-click on ISO file, mounted to say path1. Start terminalCtrl-Alt-t. 2) mkdir ~/lm ; mount $path1/casper/filesystem.squashfs ~/lm 3) chroot ~/lm /bin/bash 4)sudo echo aoutput "a" Please let me know if this reperformance is acceptable to you.sudo -lin the chroot wheresudo echo aworked?