Installation in an Android Chroot

Install Arch Linux ARM on other devices.

Re: Installation in an Android Chroot

Postby fackamato » Tue Apr 17, 2012 9:01 am

Thanks for the guide!

I'm setting up Archlinux on my old Galasy S phone (gen1). I wrote a shell script to to the mount/umount/chroot stuff so I don't have to type this manually. I use sshdroid on the phone as the SSH server, so you might want to adjust the script etc.

Code: Select all
#!/data/data/berserker.android.apps.sshdroid/home/bin/ash
export PATH=$PATH:/data/data/berserker.android.apps.sshdroid/home/bin:/data/data/berserker.android.apps.sshdroid/dropbear
unset _chroot
_chroot="/mnt/emmc/chroot"
unset _tmp
_tmp="/mnt/sdcard/losetup.txt"
unset _rootfsimage
_rootfsimage="/mnt/emmc/alarm.img"


if [ ! -e "$_rootfsimage" ]; then
   echo "$_rootfsimage not found, exiting"
   exit 1
#else
   #echo "$_rootfsimage found, continuing"
fi

# Checking if losetup is done
busybox [ -e "$_tmp" ] && rm -f $_tmp
busybox losetup > $_tmp
unset _line

echo >> "$_tmp"
while read _line; do
   case "$_line" in
      *"alarm.img"* )
         echo "Loop found."
         break
      ;;
      * )
         echo "Setting up loop"...
         busybox losetup /dev/loop1 "$_rootfsimage" || exit 1
      ;;
   esac
done < $_tmp


echo "Mounting file systems..."
mount -t ext2 -o rw,noatime /dev/loop1 $_chroot || exit 1
mount -o bind /dev/ $_chroot/dev || exit 1
mount -t devpts devpts $_chroot/dev/pts || exit 1
mount -t proc proc $_chroot/proc || exit 1
mount -t sysfs sysfs $_chroot/sys || exit 1
echo "Entering chroot..."
busybox chroot $_chroot /usr/bin/env HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
   PATH=/bin:/usr/bin:/sbin:/usr/sbin /bin/bash --login +h
echo "chroot exited. umount..."
umount $_chroot/dev/pts || exit 1
umount $_chroot/dev || exit 1
umount $_chroot/proc || exit 1
umount $_chroot/sys || exit 1
umount $_chroot || exit 1
echo "Deactivating loop..."
busybox losetup -d /dev/loop1
echo "Done. Bye!"
busybox [ -e "$_tmp" ] && rm -f $_tmp
exit 0


What I want to do:
* Get X up and running (VNC first)
* Find out of I can (maybe with help of Clockwork Mod Recovery?) boot straight into Archlinux instead of Android ICS
* Get X to run on a framebuffer (needs the previous done first)

Problems:
* The chroot environment seems to inherit all environment variables by the Android host, so you have to (re)set path, home etc. Annoying
*
Code: Select all
[root@galaxys ~]# df -h
df: ‘/acct’: No such file or directory
df: ‘/mnt/asec’: No such file or directory
df: ‘/mnt/obb’: No such file or directory
df: ‘/system’: No such file or directory
df: ‘/cache’: No such file or directory
df: ‘/radio’: No such file or directory
df: ‘/data’: No such file or directory
df: ‘/datadata’: No such file or directory
df: ‘/efs’: No such file or directory
df: ‘/mnt/emmc’: No such file or directory
df: ‘/mnt/secure/asec’: No such file or directory
df: ‘/mnt/emmc/.android_secure’: No such file or directory
df: ‘/mnt/secure/asec’: No such file or directory
df: ‘/mnt/emmc/.android_secure’: No such file or directory
df: ‘/mnt/sdcard’: No such file or directory
df: ‘/mnt/secure/asec’: No such file or directory
df: ‘/mnt/sdcard/.android_secure’: No such file or directory
Filesystem      Size  Used Avail Use% Mounted on
rootfs          756M  464M  285M  62% /
/dev/loop1      756M  464M  285M  62% /


Perhaps this can be solved if proc is mounted after the chroot has been entered.
fackamato
 
Posts: 2
Joined: Tue Apr 17, 2012 8:57 am

Re: Installation in an Android Chroot

Postby workdowg » Tue Apr 17, 2012 11:01 pm

So I've managed to get Archlinux running in a chroot environment on my A200.

THIS IS ONLY FOR ROOTED DEVICES - MUST HAVE BUSYBOX AND SUPERUSER


credits: crimsonredmk @ archlinuxarm.org forum, JoshAshby » Arch-droid, and some miscellaneous others...

The following gets you command line only Arch Linux installation only.
There are several errors that come up and I would apreciate any help with them. (from the scripts)
I'll edit this later with getting LXDE running via vnc.

The following works on the Acer Iconia A200:

1) download and start a SSH server app (I use SSHdroid)
2) get SSH client for your PC
3) connect to tablet using SSH client

or open terminal emulator

Code: Select all
#these commands get typed in to create your arch install - run first time only
su
cd /sdcard
dd if=/dev/zero of=archarm.img seek=1750000000 bs=1 count=1 #create empty 1.6gb image file
mke2fs -F archarm.img
mknod /dev/loop256 b 7 256
losetup /dev/loop256 archarm.img
mount -t ext2 /dev/loop256 arch/
cd arch
wget http://archlinuxarm.org/os/ArchLinuxARM-trimslice-latest.tar.gz #this is for our A200, it is Tegra2 Arm7
tar xzf ArchLinuxARM*.tar.gz
rm ArchLinuxARM*.tar.gz
mount -o bind /dev/ /sdcard/arch/dev
mkdir media/sdcard #for mounting sdcard
mkdir media/external_sd #for mounting external_sd
mount -o /sdcard/ /sdcard/arch/media/sdcard #mount the sdcard
mount -o /mnt/external_sd/ /sdcard/arch/media/external_sd #mount the internal storage
chroot . /bin/bash #enter the chroot, your now in the Arch install.
#next we need to set some stuff up to make sure everything works well:
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "export TERM=xterm" >> /etc/profile
echo "export HOME=/root" >> /etc/profile
mount -t proc proc /proc
mount -t sysfs sysfs /sys
source /etc/profile
mount /dev/pts
pacman -Syu


Before you leave the chroot for the first time, create this file called "start" in "/" of the chroot:



Code: Select all
#http://joshashby.com/2011/08/arch-droid/
#quick hack to start up everything for the chrooted Arch
if [ "mount | grep proc" ]; then
        echo "Proc already mounted, skipping..."
else
        mount -t proc proc /proc
fi
if [ "mount | grep sysfs" ]; then
        echo "Sysfs already mounted, skipping..."
else
        mount -t sysfs sysfs /sys
fi
if [ "mount | grep devpts" ]; then
        echo "Sysfs already mounted, skipping..."
else
        mount /dev/pts
fi


Then

Code: Select all
chmod 755 start


When you are done, type exit to exit the chroot.

(Unfortunately this leaves the processes open, I'm not really sure how to stop them.)

Next is a script called "startarch" you can create in /sdcard to start the chroot next time.

Code: Select all
#http://joshashby.com/2011/08/arch-droid/
#quick hack to mount and start the chroot...
if [ "mount | grep arch" ]; then
        cd /sdcard/arch/
        chroot . /bin/bash
else
        mknod /dev/loop256 b 7 256
        losetup /dev/loop256 /sdcard/archarm.img
        mount -t ext2 /dev/block/loop256 /sdcard/arch/
        cd /sdcard/arch/
        mount -o bind /dev/ /sdcard/arch/dev
        chroot . /bin/bash
fi


Then

Code: Select all
chmod 755 startarch


So here is the final result:

Connect to the tablet with SSH (or terminal emulator)

Code: Select all
su #at command prompt
cd /sdcard
sh startarch #enters arch chroot
source /etc/profile
./start



I have been rebooting the tablet after exiting to clear things up...

Any and all suggestions are welcome!
workdowg
 
Posts: 15
Joined: Tue Apr 17, 2012 10:57 pm

Re: Installation in an Android Chroot

Postby workdowg » Sat Apr 21, 2012 6:00 am

Thought I would post this here also... Modifiy away....

So I've managed to get Archlinux running in a chroot environment with 2 choices of desktop managers, LXDE and XFCE4, on my A200.

THIS IS ONLY FOR ROOTED DEVICES - MUST HAVE BUSYBOX AND SUPERUSER


credits: Linux-On-Android, crimsonredmk @ archlinuxarm.org forum,
JoshAshby » Arch-droid, and many more I'm sure...

The following works on the Acer Iconia A200:

In a file manager make a directory called arch in your sdcard root.

Copy and paste this into a text editor and save to your /sdcard directory:

archarm.sh - http://pastebin.com/hXz526ff

Copy and paste these into a text editor and save to your /sdcard/Download directory:

.bashrc - http://pastebin.com/qqWDAdh9
bash.bashrc - http://pastebin.com/uCyRhLNM
xfce4startup - http://pastebin.com/HtNwepGi
lxstartup - http://pastebin.com/GiuwLpet
archarm.init.sh http://pastebin.com/j0W2cbH6
archarm-image-creator - http://pastebin.com/Kt62Qbp4



Next to create and setup your ArchArm 2gb install, open Terminal Emulator and enter the following:

Code: Select all
su
cd /sdcard/Download/
sh archarm-image-creator.sh


that runs....

When that finishes we need to manually type some stuff(sorry) to make sure everything works well:

Code: Select all
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "export TERM=xterm" >> /etc/profile
echo "export HOME=/root" >> /etc/profile
source /etc/profile
sh /media/sdcard/Download/copy-files.sh
pacman -Syyu
pacman -S xorg-xrdb tightvnc lxde xfce4 #select all for lxde and xfce4
exit


that is that....

you may delete the files in your Download directory...

And now to run it....

To run goto terminal and carefully follow the prompts. I suggest 1280x750 for the resolution:

Code: Select all
su
cd /sdcard
sh archarm.sh


first time it will ask for a vnc password... I suggest archarm

leave the terminal open and switch to androidvnc connect to localhost, port 5900, password is archarm

After the first run, you can put archarm.img and archarm.sh anywhere (hint external_sd) as long as you keep them together

Have fun.. I did!
workdowg
 
Posts: 15
Joined: Tue Apr 17, 2012 10:57 pm

Re: Installation in an Android Chroot

Postby pione » Wed May 09, 2012 11:14 am

Do you use some accessibility program to get better experience using graphical interface?
Manage LXDE with AndroidVNC is not really comfortable, It would be great if Archlinux could recognize the touchscreen and use it to interact with the user and not the vnc emulated mouse!
pione
 
Posts: 2
Joined: Mon May 07, 2012 5:22 pm

Re: Installation in an Android Chroot

Postby WarheadsSE » Wed May 09, 2012 12:17 pm

We agree, got any pointers to a specific driver, config & all around setup ;)
OXNAS pwner

Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 4805
Joined: Mon Oct 18, 2010 2:12 pm

Re: Installation in an Android Chroot

Postby Jasuramme » Sat May 19, 2012 8:23 am

Good day, I installed archlinux on my android phone and realy strugglin to add alsa dummy driver to chrooted system.
Actually there wasn't success to install any modules.
I tried to compile ALSA dummy driver from sources, but i got error: The file /alsa-driver-1.0.25/alsa-kernel/include/INCLUDE_VERSION_H does not exist.
i tried to wowload my kernel source and use it to compile, but still no success.
Can you help me, please?
may be it's not easiest way to install this bloody dummy driver?

And yeah, I'm newbie in archlinux.

Thanx,
Alex
Jasuramme
 
Posts: 1
Joined: Sat May 19, 2012 8:14 am

Re: Installation in an Android Chroot

Postby daveosel » Mon May 28, 2012 4:24 am

Hi guys, thnx for this great guide.
Its stupid really, but i've ben having problems with the very simplest of these steps. I have been an ArchLinux user for years...
I have BusyBox installed, I connected through dab shell, and yet:
1. mount -t ext2 /dev/loop1 arch/ gives out mount: File too Large Why?
2. "tar" seems not to have a '-z' option to run a gzip filter??? I am very frustrated after hours of searching...

I just bought the Samsung Galaxy Tab 2 10.1" with Ice Cream Sandwich (v 4.0.3) installed and latest BusyBox Pro (7.9.2) installed.

Any help would be much appreciated.
By the way, I downloaded ArchLinuxARM-omap-smp-latest.tar.gz to install on this device (ARMv7 cpu), is that good, bad?

Thanks in advance :)
daveosel
 
Posts: 2
Joined: Mon May 28, 2012 4:15 am

Re: Installation in an Android Chroot

Postby fackamato » Mon May 28, 2012 4:59 am

daveosel wrote:Hi guys, thnx for this great guide.
Its stupid really, but i've ben having problems with the very simplest of these steps. I have been an ArchLinux user for years...
I have BusyBox installed, I connected through dab shell, and yet:
1. mount -t ext2 /dev/loop1 arch/ gives out mount: File too Large Why?
2. "tar" seems not to have a '-z' option to run a gzip filter??? I am very frustrated after hours of searching...

I just bought the Samsung Galaxy Tab 2 10.1" with Ice Cream Sandwich (v 4.0.3) installed and latest BusyBox Pro (7.9.2) installed.

Any help would be much appreciated.
By the way, I downloaded ArchLinuxARM-omap-smp-latest.tar.gz to install on this device (ARMv7 cpu), is that good, bad?

Thanks in advance :)


busybox mount
busybox tar -xvzf

Try that. How large is your image?
fackamato
 
Posts: 2
Joined: Tue Apr 17, 2012 8:57 am

Re: Installation in an Android Chroot

Postby daveosel » Mon May 28, 2012 5:20 am

fackamato wrote:
daveosel wrote:Hi guys, thnx for this great guide.
Its stupid really, but i've ben having problems with the very simplest of these steps. I have been an ArchLinux user for years...
I have BusyBox installed, I connected through dab shell, and yet:
1. mount -t ext2 /dev/loop1 arch/ gives out mount: File too Large Why?
2. "tar" seems not to have a '-z' option to run a gzip filter??? I am very frustrated after hours of searching...

I just bought the Samsung Galaxy Tab 2 10.1" with Ice Cream Sandwich (v 4.0.3) installed and latest BusyBox Pro (7.9.2) installed.

Any help would be much appreciated.
By the way, I downloaded ArchLinuxARM-omap-smp-latest.tar.gz to install on this device (ARMv7 cpu), is that good, bad?

Thanks in advance :)


busybox mount
busybox tar -xvzf

Try that. How large is your image?


I tried adding 'busybox' before but same thing, file too large...and tar no gzip filter
My image is 750 MB, i have over 6 GB of internal storage, I'm quite sure i have enough space
daveosel
 
Posts: 2
Joined: Mon May 28, 2012 4:15 am

Re: Installation in an Android Chroot

Postby gtp » Fri Jun 22, 2012 9:58 pm

i am trying to install alarm in motorola charm http://www.gsmarena.com/motorola_charm-3420.php with ArchLinuxARM-omap-smp-latest.tar.gz as the image.

but i cant get pass the
Code: Select all
chroot . /bin/bash
[1]   Segmentation fault      chroot . /bin/bash


i have busybox v1.19.4 installed in android.

what do i do?
gtp
 
Posts: 2
Joined: Fri Jun 22, 2012 9:32 pm

PreviousNext

Return to [Please read announcement] Community-Supported Devices

Who is online

Users browsing this forum: No registered users and 2 guests