Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save coderofsalvation/43d7d476dc5eeba98926b9437e52bb49 to your computer and use it in GitHub Desktop.
Save coderofsalvation/43d7d476dc5eeba98926b9437e52bb49 to your computer and use it in GitHub Desktop.
installing ALPINE LINUX on any (old) android device using ssh-droid

installing ALPINE LINUX on any (old) android device using ssh-droid (tested: NEO G4 MINIX)

note: bit of unix-skills (vi e.g.) is needed (a very good investment for your future)

  1. install ssh-droid thru playstore, or download/open its .apk file after googling
  2. open ssh-droid
  3. on another laptop/computer ssh into your android device
  4. type mkdir alpine in your homefolder
  5. download the following shellscript below by typing:

wget https://gist.githubusercontent.com/coderofsalvation/43d7d476dc5eeba98926b9437e52bb49/raw/27980cdb3d2dd2c49968549bc696f7e9ac3c17bc/install.sh && chmod 755 install.sh

  1. update ARCH= to your architecture (surf to http://nl.alpinelinux.org/alpine to see the supported ones)
  2. update INSTALL= to your chroot-folder location (absolute path)
  3. run ./install.sh
  4. profit!

now run this script (./alpine.sh e.g.) to teleport into your alpine distro!

#!/bin/sh
INSTALL='/data/data/berserker.android.apps.sshdroid/home/alpine'
mount -o bind /dev $INSTALL/dev # access all devices (usb etc) from linux
HOME=/root chroot $INSTALL bash
#!/bin/bash
INSTALL='/data/data/berserker.android.apps.sshdroid/home/alpine'
APKTOOLS='2.10.3-r1'
ARCH='armv7'
MIRROR='http://dl-cdn.alpinelinux.org/alpine'
MIRROR='http://nl.alpinelinux.org/alpine'
VER='v3.9'
RED='\033[0;31m'
NC='\033[0m'
set -e
mkdir -p $INSTALL/etc
printf "${RED}remounting /system as writable to write /etc/resolv.conf${NC}"
mount -o remount,rw $(mount | grep '/system' | awk '{ print $1 }') /system
printf "${RED}initing DNS settings"
echo -e "nameserver $(getprop net.dns1)\nnameserver $(getprop net.dns2)" > /etc/resolv.conf
set +e; mkdir $INSTALL/etc; set -e
cp /etc/resolv.conf $INSTALL/etc/.
printf "${RED}Downloading Static installer apk...${NC}\n"
set -x
wget $MIRROR/$VER/main/$ARCH/apk-tools-static-$APKTOOLS.apk
tar -xzf apk-tools-static-*.apk
rm apk-tools-static-*.apk
rm .PKGINFO
printf "\n${RED}Installing Base Alpine...${NC}\n"
./sbin/apk.static -X $MIRROR/$VER/main -U --allow-untrusted --root $INSTALL --initdb add alpine-base
rm -r ./sbin/
printf "\n${RED}Adding Repos to chroot${NC}\n"
echo "$MIRROR/$VER/main" > $INSTALL/etc/apk/repositories
echo "$MIRROR/$VER/community" >> $INSTALL/etc/apk/repositories
echo "http://nl.alpinelinux.org/alpine/edge/testing/" >> $INSTALL/etc/apk/repositories
printf "\n\n${RED} Done! Logging into chroot..${NC}\n"
echo "in the future you can do this using: chroot $INSTALL bash"
chroot $INSTALL apk update
@Dani3I
Copy link

Dani3I commented May 19, 2021

Is this for rooted devices only?

@coderofsalvation
Copy link
Author

coderofsalvation commented May 19, 2021

I can't remember, but I think this works for non-rooted as I used the ssh-droid app to SSH into the device (apps dont never run as root).
I've used it to install home assistant, which worked at some point after installing fakeroot (to fake homeassistant into thinking that i was root).

@abasgames
Copy link

anyway to install it in external sdcard ? i have root if it matter

@coderofsalvation
Copy link
Author

@abasgames maybe modify INSTALL=... to your desired location? (INSTALL=/sdcard e.g.)

@abasgames
Copy link

@abasgames maybe modify INSTALL=... to your desired location? (INSTALL=/sdcard e.g.)

android exec limitations in external storage

@coderofsalvation
Copy link
Author

@abasgames how about trying this on line 15:

mount -o remount,rw,exec /sdcard                    # maybe must be done with root?

Other then that I guess it's trial error

@wkddudwo
Copy link

Running sh install.sh remounting /system as writable to write /etc/resolv.confmount: Permission denied

comes out how can i solve it? Need rooting?

My device is samsung SM-G150NK.

@LEKPHET-KUNSUE
Copy link

I don't have idea about this:

Read-only file system

@LEKPHET-KUNSUE
Copy link

I want to root my device. But how?

@LEKPHET-KUNSUE
Copy link

No apt, and apk.

@LEKPHET-KUNSUE
Copy link

And no sudo

@coderofsalvation
Copy link
Author

coderofsalvation commented Feb 22, 2024

@LEKPHET-KUNSUE It's possible that the script is broken / only works after rooting your specific device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment