Magisk-Modules-Alt-Repo / chroot-distro

install linux distributions on android
GNU General Public License v3.0
87 stars 7 forks source link

Sudo not working in chroot on P7P #5

Closed matejdro closed 1 month ago

matejdro commented 5 months ago

When attempting to use sudo inside chrooted system (notably archlinux), sudo command is broken, complaining about

effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

I guess this has to do something with the way Android mounts /data? The device is Pixel 7 Pro.

gixousiyq commented 4 months ago

Try su -c mount -o remount,dev,suid /data Then login to Arch

matejdro commented 4 months ago

Yes, that worked, thanks!

Although I feel it is a bad idea to do a global remount since that affects the entire Android instead of just the chroot instance. Presumably there is no better solution?

gixousiyq commented 3 months ago

Sorry for the late response su -c remounts /data for the running proccess that invoked it only E.g termux To remount /data for all the system you have to add -mm to the command to force it into global mount space su -mm -c mount...

jjkola commented 2 months ago

My solution to this was to format external sd card with ext4 and then transfer files/folders from /data/local/chroot-distro to newly formatted SD card, and then mounting it at that folder with Termux:boot (unfortunately it sometimes does not work, and I have to manually run the scripts). This has the added benefit of not taking space from internal storage. If this solution is used then you can't allow android to format the SD card and you will not be able to access it from android side. As I will not be using the android side at all (other than for administrating the tablet) this is perfectly okay with me, but your mileage may wary.

jjkola commented 2 months ago

Reopening this to document the problem and solutions so that others can avoid this.

gixousiyq commented 1 month ago

I think a better way to solve this problem is to make the script run su -c mount -o remount,dev,suid /data every mount, This should fix the problem without needing to use external storage or any workaround's

By the way you can also make a virtual disk and format it as ext4 and mount it into /data/local/chroot-distro by running these:

su -c truncate -S 15G /data/local/distros.img

The above will create a disk image in /data/local with the size 15 Gigabyte's, Change it to the size you want

su -c mke2fs -t ext4 /data/local/distros.img

The above will put a ext4 filesystem on our virtual disk

su -c mount /data/local/distros.img /data/local/chroot-distro

The above will mount our disk image to /data/local/chroot-distro, Now our distros are housed in a ext4 filesystem separate from our main filesystem But keep in mind that this will take space from internal storage and it may be complicated to resize this disk image, Just an idea I wanted to share.

jjkola commented 1 month ago

@gixousiyq Thanks for the pointers. I'll create a PR for this and would like it if you could help reviewing it.

jjkola commented 1 month ago

@gixousiyq Any chance of reviewing the change? If you can't comment on the PR then could you please add your comments here so I can finish this? Also, if you don't want or can't review the change can you notify about it so that I will know not to wait for your comments.

gixousiyq commented 1 month ago

Sorry didnt see it :)

jjkola commented 1 month ago

No problem.