1

I am trying to chroot the Ubuntu 16.04 Image Nvidia has for developing on the shield. I placed it on a sdcard mounted it at /mnt/chroots I am not able to get apt-get update to work without failing, ping also fails. Help would be appreciated.

cd rootfs
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
mount -o bind /dev/pts dev/pts/
chroot . /bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH

Also I added root to the groups:

groupadd -g 3001 aid_net_bt_admin
groupadd -g 3002 aid_net_bt
groupadd -g 3003 aid_inet
groupadd -g 3004 aid_inet_raw
groupadd -g 3005 aid_inet_admin

gpasswd -a root aid_net_bt_admin
gpasswd -a root aid_net_bt
gpasswd -a root aid_inet
gpasswd -a root aid_inet_raw
gpasswd -a root aid_inet_admin

/etc/resolv.conf
nameserver 8.8.8.8

with /etc/init.d/networking start

root@localhost:/# apt-get update
Err:1 http://ports.ubuntu.com/ubuntu-ports xenial InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:2 http://ports.ubuntu.com/ubuntu-ports xenial-updates InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:3 http://ports.ubuntu.com/ubuntu-ports xenial-security InRelease
Temporary failure resolving 'ports.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports...nial/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports...ates/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports...rity/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
2

You have 2 different issues here

  • apt not resolving DNS
  • ping not working

-


APT NOT RESOLVING DNS:

The issue is APT uses _apt as our unprivileged user. On Android with paranoid network, only users in group 3003 aid_inet or 3004 aid_inet_raw can open network sockets. When apt installs it creates user _apt.

    # add unprivileged user for the apt methods
     adduser --force-badname --system --home /nonexistent  \
       --no-create-home --quiet _apt || true

The user looks like this in /etc/passwd

    root@localhost:~
    # grep -E "_apt" /etc/passwd
    _apt:x:103:65534::/nonexistent:/bin/false

passwd format is

User name:Encrypted password:User ID number (UID):User's group ID number (GID):Full name of the user (GECOS):User home directory:Login shell

looking at _apt user the GID is set to 65534 which means no group, on normal linux systems this is fine. On Android this GID will never be able to make network connections Need to change GID to 3003

# usermod -g 3003 _apt will change GID

    root@localhost:~
    # grep -E "_apt" /etc/passwd
    _apt:x:103:3003::/nonexistent:/bin/false

Now APT will work on Android chroot

PING NOT WORKING


For me, I noticed when I chroot using this command example

# chroot /linux /bin/bash -l

In Android groups are used for apps, somewhat. So root calling bash is only in root group you can check this by

    # groups
     root

groups run with no username outputs current process groups

Now try this

# su - root

su commmand is switch user

    # groups
    root sdcard-rw aid_bt aid_bt-net aid_inet aid_net-raw aid_net_admin

Now ping will work

I now use

# chroot /linux /bin/su - root

which login as root from linux not root from Android

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.