Android 4.2.2 (PAC, CM10.1, etc): Mount CIFS share on /sdcard (incl. nls_utf8) - Galaxy Tab 7.7 General

With Android 4.2's multi-user stuff and the dreaded "0" folder, Google broke mounting of CIFS shares for good. (They basically implemented something utterly useless for my needs, and broke something I need on a daily basis.) Cyanogenmod fixed that for mounts outside the /storage hierarchy, but many apps can't go there. And with 4.2.2, Google made using adb on the device very annoying as well, which adds to problems for a workaround for mounting shares in a useful place.
So I looked around for various fixes for that issue and compiled those into one method that works perfectly well for me on a P6810 running the current PAC ROM 20130629. It should probably work for any other CM10.1 or PA3.6x-based ROM as well. A nls_utf8.ko module compiled for the Nexus 10 is included as well, which can be loaded via punchmod (at least in PAC), so you can access shares with Ümläüts in them.
Prerequisites: SManager, SMWidgets, and a working Busybox install (I use Stericson's Busybox Installer).
1.) Extract nls_utf8.ko and punchmod from the attached .zip file and put them in /system/lib/modules. You can put them in some other place as well, but my scripts need to be adjusted then. Next, give the files sufficient permissions:
Code:
chmod 644 /system/lib/modules/nls_utf8.ko
chmod 755 /system/lib/modules/punchmod
2.) Optional: if you want the module to auto-start, create a file called 00punch-nls_utf8 (or whatever you like) with the content below, put it in /etc/init.d and chmod it to 755. To check if nls-utf8 is loaded after a reboot, type lsmod in a terminal window or adb shell - it should display the module name. If punchmod auto-detection fails, read here how to get the right vermagic string for your device: http://forum.xda-developers.com/showthread.php?p=41920265#post41920265
Code:
#!/system/bin/sh
sleep 10
/system/lib/modules/punchmod /system/lib/modules/nls_utf8.ko ""
3.) Here's the script that mounts a CIFS share. Edit the settings on top and either put your correct vermagic string as well, or delete the "$VERMAGIC" part in line 22 and try your luck with auto-detection. I put some sanity checks in the script, but it might not work for all directories in /sdcard (or, /data/media/0, to call it by its 'real' name/location). If you don't want to use the nls-utf8 module, just delete lines 18-23, and iocharset=utf8 in line 67.
Name the script mount-music.sh or something, put the script wherever you like, open SManager and navigate to the script. Run the script with SU permissions. If everything goes well, it will ask you to accept an adb RSA key, and then adb mounts the share. You can also add a desktop widget for quick access to the script with SMWidgets.
Code:
#!/system/bin/sh
# Your settings here
IP="192.168.1.123"
SHARE="Music"
USER="yourusername"
PASS="yourpassword"
MOUNTPOINT="/data/media/0/cifs"
VERMAGIC="3.0.31-CM-ga034655-dirty SMP preempt mod_unload ARMv7 p2v8 "
# Load cifs (if it isn't already loaded)
if [ `lsmod | grep -o cifs` ] ; then
:
else
insmod /system/lib/modules/cifs.ko
fi
# Load nls_utf8 brute-force style (if it isn't already loaded)
if [ `lsmod | grep -o nls_utf8` ] ; then
:
else
/system/lib/modules/punchmod /system/lib/modules/nls_utf8.ko "" "$VERMAGIC"
fi
# Check if cifs $MOUNTPOINT dir exists, create it if not, give sufficient permissions
if [ -d $MOUNTPOINT ] ; then
:
else
mkdir $MOUNTPOINT
fi
chmod 755 $MOUNTPOINT
# Check if $SHARE directory is empty - if not, unmount the share
if [ "$(su root -c busybox ls -A $MOUNTPOINT/$SHARE 2> /dev/null)" == "" ] ; then
:
else
/system/xbin/busybox umount -l $MOUNTPOINT/$SHARE
fi
# Create $SHARE directory if necessary, give sufficient permissions
if [ -d $MOUNTPOINT/$SHARE ] ; then
:
else
mkdir $MOUNTPOINT/$SHARE
fi
chmod 755 $MOUNTPOINT/$SHARE
# Starting adb
adb kill-server
export HOME=/sdcard
# PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port 5555
adb start-server
cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys
stop adbd
start adbd
adb connect localhost
# Make sure we only use the first device (sometimes there is more than one)
SERIAL=`adb devices | head -n2 | tail -n1 | cut -f1`
if [ "$SERIAL" = "" ] ; then
echo "ERROR: Could not find ADB device.";
fi
# Mounting share via adb
echo Mounting share via adb...
adb -s $SERIAL shell su root -c /system/xbin/busybox mount -t cifs //$IP/$SHARE $MOUNTPOINT/$SHARE -o user=$USER,pass=$PASS,iocharset=utf8,cache=none,directio,CIFSMaxBufSize=130048,rw,file_mode=0777,dir_mode=0777,uid=1015,gid=1015
# If you started adb, then stop it here for security
adb disconnect localhost
stop adbd
PORT=`getprop service.adb.tcp.port`
setprop service.adb.tcp.port $PORT
start adbd
# Show some results
RESULT=`mount | grep $MOUNTPOINT/$SHARE`
if [ "$RESULT" = "" ] ; then
echo "FAILED! //$IP/$SHARE could not be mounted."
else
echo "SUCCESS! //$IP/$SHARE has been mounted on $MOUNTPOINT/$SHARE."
fi
echo
echo All done. You may close this script window now.
4.) This is the script to unmount the share. Name it unmount-music.sh or similar, and edit your settings at the beginning of the script. Again, run it in SManager with SU permissions, and add a desktop widget with SMWidgets if you like.
Code:
#!/system/bin/sh
# Your settings here
SHARE="Music"
MOUNTPOINT="/data/media/0/cifs"
# Check if $SHARE directory exists
if [ -d $MOUNTPOINT/$SHARE ] ; then
# Check if $SHARE directory is empty - if not, unmount the share
if [ "$(su root -c busybox ls -A $MOUNTPOINT/$SHARE 2> /dev/null)" == "" ] ; then
echo "$MOUNTPOINT/$SHARE is empty."
else
su root -c busybox umount -l $MOUNTPOINT/$SHARE
fi
fi
# Show some results
RESULT=`mount | grep $MOUNTPOINT/$SHARE`
if [ "$RESULT" = "" ] ; then
echo "SUCCESS! $MOUNTPOINT/$SHARE has been unmounted."
else
echo "FAILED! $MOUNTPOINT/$SHARE could not be unmounted."
fi
echo
echo All done. You may close this script window now.
Hope this helps some of you. It sure stumped me how incredibly convoluted this simple and much needed procedure has become on Android 4.2.2... just because of that multi-account stuff and new restrictions on adb.
Credits:
Script bits and nls_utf8.ko by H3g3m0n
More script bits by dafunk60 and jmtw000
Punchmod by Jann Horn
Punchmod info by idcrisis

Thanks man, looks awesome, I am going to try it on my 6800.
Do you know how to mount ext4 or ntfs sdcard on CM10.1 based roms?

Removed the original post, still trying to make it work!
I checked vermagic in some existing ko files and found that it is exactly the same as yours.
Sent from my GT-p6800 using Tapatalk HD

m0bster said:
Removed the original post, still trying to make it work!
I checked vermagic in some existing ko files and found that it is exactly the same as yours.
Sent from my GT-p6800 using Tapatalk HD
Click to expand...
Click to collapse
You can try loading the UTF8 module without vermagic string as well, it should work on PAC. Or, make sure you have a blank space at the end of the vermagic string, it is required. Maybe read the short tutorial here: http://forum.xda-developers.com/showthread.php?p=41920265#post41920265

dfkt_ said:
You can try loading the UTF8 module without vermagic string as well, it should work on PAC. Or, make sure you have a blank space at the end of the vermagic string, it is required. Maybe read the short tutorial here: http://forum.xda-developers.com/showthread.php?p=41920265#post41920265
Click to expand...
Click to collapse
I finally managed to mount cifs shares, after loading original cifs and punmode load of nls_utf8.ko.
But I mounted it with cifsmanager. The script always shows "failure to mount" !

Related

Not sure if this has been done yet (or is even possible...); Flashing via ADB

Hi everyone ^^
I recently had a little... "Incident"... With my phone, resulting in a soft-brick and a whole lot of the Android system being removed (/System/Bin had to be replaced with ADB). What used to happen (Before replacing some of the Android system) was the phone would boot and get stuck at the bootloader. What happens now (after replacing some of the system files) is it'll boot and then reboot after about 30 seconds.
Common fixes would normally include (And are unavailable because...);
Download Mode via 3 button combo (Unavalable due to homekey not working)
Download Mode via ADB (Reboot/Crash)
Recovery Mode via 3 button combo (Again ,home key)
Recovery Mode via ADB (Reboot/Crash)
JIG (Parts unavailable/Stupidly expensive)
Flash via Odin/Heimdall(ADB recognizes the phone, but the system Odin/Heimdall uses does not)
So, what can I do? Well I just tried "ADB shell sbin/recovery" and... Woah, it worked! Sort of... The phone still crashed after about 30 seconds or when I tried to use the CWM recovery to flash a zip. No biggie. It just means some system stuff is missing (I think...).
This is more or less development, and I do not claim to have any major understanding of Android's inner workings besides some UNIX commands. I can't post in Development because of the 10-post requirement, but meh.
What I'm looking for (It's not exactly a question ) is the absolutely critical files that my system is missing (Which I believe to be causing the crash). I ran logcat only to have;
Code:
link_image[1962]: 98 could not load needed library 'liblog.so' for 'logcat' (load_library[1104]: Library 'liblog.so' not found)CANNOT LINK EXECUTABLE
This would eventually go towards an open-source tool for software-based soft-brick recovery.
Here's the ls from /sbin;
Code:
[ expr mkyaffs2image split
[[ false mmcwait.sh stat
adbd fbsetup.sh modprobe strings
ash fdisk more stty
awk fgrep mount swapoff
basename find mountpoint swapon
bbconfig fix_permissions mv sync
bml_over_mtd flash_image nandroid sysctl
bunzip2 fold nandroid-md5.sh tac
busybox free nice tail
bzcat freeramdisk nohup tar
bzip2 fuser od tee
cal getopt parted test
cat grep patch time
catv gunzip pgrep top
chgrp gzip pidof touch
chmod head pkill tr
chown hexdump printenv true
chroot id printf tty
cksum insmod ps tune2fs
clear install pwd ueventd
cmp kill rdev umount
cp killall readlink uname
cpio killall5 realpath uniq
cut killrecovery.sh reboot unix2dos
date length recovery unlzop
dc less renice unyaffs
dd ln reset unzip
depmod losetup rm uptime
devmem ls rmdir usleep
df lsmod rmmod uudecode
diff lspci run-parts uuencode
dirname lsusb sdparted volume
dmesg lzop sed watch
dos2unix lzopcat seq wc
du md5sum setsid which
dump_image mkdir setupenv.sh whoami
e2fsck mke2fs sh xargs
echo mkfifo sha1sum yes
edify mkfs.ext2 sha256sum zcat
egrep mknod sha512sum
env mkswap sleep
erase_image mktemp sort
And ls /system;
Code:
app fonts lost+found tts xbin
bin framework media usr
etc lib modules vendor
Any help with this would be great ^^
So far, it looks like pushing the system directory from a romkitchen rom I built is working... The only problem is that it can't seem to access /sdcard or /sd-ext Can anybody help with this?
The Download mode jigs are cheap? eBay has them for not much at all, especially if you consider the cost of the handset. It's also possible to make them from more common parts. Read the thread, might save you a lot of messing about.

Installing BackTrack5 onto the Motorola Atrix 4G

As I am not allowed to post this where it should be, this seems to be the next best place.
Hardware Needed:
* The Motorola Atrix 4G (without this you wont be going very far)
* Atleast a 4 Gb SD card
* a way of transfering data from your computer onto the SD card (The supplied USB cable or an SD adaptor)
Apps Needed:
* SuperUser (If your on this site, you most likely already have this)
* Just about any Terminal Emulator will work (I used Better Terminal Emulator Pro)
* Any VNC Viewing Client (I used androidVNC)
* A Busybox installer (I used Stericson's BusyBox installer)
Software used:
* I used the BackTrack5 version posted by msullivan, found **HERE**:
I used a slightly edited version of the bt file from the bundle
just copy and paste over the original bt file:
Code:
perm=$(id|cut -b 5)
if [ "$perm" != "0" ];then echo "This script requires root! Type: su"; exit; fi
busybox mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard-ext/BT5
export bin=/system/bin
export mnt=/data/local/bt5
mkdir $mnt
export PATH=$bin:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/usr/local/sbin:/usr/games:$PATH
export TERM=linux
export HOME=/root
if [ -b /dev/loop7 ]; then
echo "Loop device exists"
else
busybox mknod /dev/loop7 b 7 0
fi
#mount -o loop,noatime -t ext2 $kit/bt5.img $mnt
losetup /dev/block/loop7 $kit/bt5.img
mount -t ext2 /dev/block/loop7 $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost bt5" > $mnt/etc/hosts
echo "Ubuntu is configured with SSH and VNC servers that can be accessed from the IP:"
ifconfig eth0
echo " "
busybox chroot $mnt /bin/bash
echo "Shutting down BackTrack ARM"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
losetup -d /dev/loop7
Installation Steps:
1. Make sure you have enough space to work with (atleast 4Gb).
2. Edit the bt file with the above coding.
3. Copy over the BT5 folder onto your SD card however you see fit, I just used a SD to USB adaptor that I got with my SD card.
4. Disconnect the USB cable if you have it connected.
5. open your Terminal emulator and type:
Code:
su <ENTER>
6. Type:
Code:
cd /sdcard-ext/BT5 <ENTER>
7. Type:
Code:
sh bt <ENTER>
8. The bt file should run, and leave you with a red command prompt.
Hit the home button.
9. Open your VNC Viewer and enter the login information.
Code:
Nickname: BackTrack5
Password: root
Address: 127.0.0.1
Port: 5901
The screen size still needs adjusting however as I believe it is set at 800×480 currently.
Sick. Just sick.
Cant wait to crack some Wifi with this. Anyone test this out and get a successful crack?
I haven't looked too far into it, however I do believe that this is almost useless as a "cracking" distro on ARM hardware. AFAIK many things don't/can't work. for instance injecting is a no go (real turn off for me, but that is what a netbook is for).
Until we get better drivers for the wifi, we don't have injection, or monitor mode. I've also found editing scripts can be a ***** because the on screen keyboard is either in the way, or the enter doesn't work as enter if using nano, running vi really hoses things up. My external bluetooth keyboard helps with this, but a bluetooth mouse while it works, is waaaaaaaaaaaaaaay (no really) too sensitive on the Atrix. Hooked up to an external monitor in webtop mode it works much better, but I've not tried running backtrack from there.
Yeah I did not even consider the ARM architecture. Very good point.
Do they make a Rosetta type app for Linux? Anyone know? That could at least help use get past the Architectural limits.
*edit*
Still not thinking straight, that app is for PPC users.
In the beginning where the script says "sdcard-ext/bt5" could I edit that to say "sdcard/bt5" in order to boot it from my internal phone memory?
Sent from my MB860 using XDA App
BravoMotorola said:
In the beginning where the script says "sdcard-ext/bt5" could I edit that to say "sdcard/bt5" in order to boot it from my internal phone memory?
Sent from my MB860 using XDA App
Click to expand...
Click to collapse
Yep.
stupid 10 character limit...
Exthero said:
As I am not allowed to post this where it should be, this seems to be the next best place.
Hardware Needed:
* The Motorola Atrix 4G (without this you wont be going very far)
* Atleast a 4 Gb SD card
* a way of transfering data from your computer onto the SD card (The supplied USB cable or an SD adaptor)
Apps Needed:
* SuperUser (If your on this site, you most likely already have this)
* Just about any Terminal Emulator will work (I used Better Terminal Emulator Pro)
* Any VNC Viewing Client (I used androidVNC)
* A Busybox installer (I used Stericson's BusyBox installer)
Software used:
* I used the BackTrack5 version posted by msullivan, found **HERE**:
I used a slightly edited version of the bt file from the bundle
just copy and paste over the original bt file:
Code:
perm=$(id|cut -b 5)
if [ "$perm" != "0" ];then echo "This script requires root! Type: su"; exit; fi
busybox mount -o remount,rw /dev/block/mmcblk0p5 /system
export kit=/sdcard-ext/BT5
export bin=/system/bin
export mnt=/data/local/bt5
mkdir $mnt
export PATH=$bin:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/usr/local/sbin:/usr/games:$PATH
export TERM=linux
export HOME=/root
if [ -b /dev/loop7 ]; then
echo "Loop device exists"
else
busybox mknod /dev/loop7 b 7 0
fi
#mount -o loop,noatime -t ext2 $kit/bt5.img $mnt
losetup /dev/block/loop7 $kit/bt5.img
mount -t ext2 /dev/block/loop7 $mnt
mount -t devpts devpts $mnt/dev/pts
mount -t proc proc $mnt/proc
mount -t sysfs sysfs $mnt/sys
busybox sysctl -w net.ipv4.ip_forward=1
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost bt5" > $mnt/etc/hosts
echo "Ubuntu is configured with SSH and VNC servers that can be accessed from the IP:"
ifconfig eth0
echo " "
busybox chroot $mnt /bin/bash
echo "Shutting down BackTrack ARM"
umount $mnt/dev/pts
umount $mnt/proc
umount $mnt/sys
umount $mnt
losetup -d /dev/loop7
Installation Steps:
1. Make sure you have enough space to work with (atleast 4Gb).
2. Edit the bt file with the above coding.
3. Copy over the BT5 folder onto your SD card however you see fit, I just used a SD to USB adaptor that I got with my SD card.
4. Disconnect the USB cable if you have it connected.
5. open your Terminal emulator and type:
Code:
su <ENTER>
6. Type:
Code:
cd /sdcard-ext/BT5 <ENTER>
7. Type:
Code:
sh bt <ENTER>
8. The bt file should run, and leave you with a red command prompt.
Hit the home button.
9. Open your VNC Viewer and enter the login information.
Code:
Nickname: BackTrack5
Password: root
Address: 127.0.0.1
Port: 5901
The screen size still needs adjusting however as I believe it is set at 800×480 currently.
Click to expand...
Click to collapse
I get an error when doing "sh bt".
I get "bt: 36: Syntax error: end of file unexpected (expecting "then")"
BravoMotorola said:
I get an error when doing "sh bt".
I get "bt: 36: Syntax error: end of file unexpected (expecting "then")"
Click to expand...
Click to collapse
Is your bt folder on your "internal" or external sd card? If it's the sdcard-ext, you'll need to edit the bt script to point to the correct location.
barry99705 said:
Is your bt folder on your "internal" or external sd card? If it's the sdcard-ext, you'll need to edit the bt script to point to the correct location.
Click to expand...
Click to collapse
Hmm, tried a lot of things, ended up going to the OP of the original Backtrack on Android thread and use his original file instead, working now. But now I have a new problem, (lol) how can I change the screen resolution of the BT5 GUI to match the Atrix's screen? I've looked all over for this. I just can't find out how...
BravoMotorola said:
Hmm, tried a lot of things, ended up going to the OP of the original Backtrack on Android thread and use his original file instead, working now. But now I have a new problem, (lol) how can I change the screen resolution of the BT5 GUI to match the Atrix's screen? I've looked all over for this. I just can't find out how...
Click to expand...
Click to collapse
once you start up backtrack, you need to edit /usr/bin/startvnc . Change that last line to
Code:
vncserver -geometry 940x520
barry99705 said:
once you start up backtrack, you need to edit /usr/bin/startvnc . Change that last line to
Code:
vncserver -geometry 940x520
Click to expand...
Click to collapse
Thanks and yes I did see that somewhere, I just had no clue what file to edit. So is it possible to install things like Flash on Firefox on here or is the no package installer for this? Gosh, sorry I'm asking so much...thanks for the help so far
BravoMotorola said:
Thanks and yes I did see that somewhere, I just had no clue what file to edit. So is it possible to install things like Flash on Firefox on here or is the no package installer for this? Gosh, sorry I'm asking so much...thanks for the help so far
Click to expand...
Click to collapse
Firefox is already installed. Not sure if flash is there since it's so insecure.
Laptop dock
After installing BT5 to Atrix 4G, can the laptop dock be used to run BT5?
I just wanted to throw a thanks out there to Exthero (since you only have 2!) for the start up script. Couldn't get it working until i used yours.
I'm having a blast with this
NISVermeer said:
After installing BT5 to Atrix 4G, can the laptop dock be used to run BT5?
Click to expand...
Click to collapse
easiest way is on wifi:
see what your ip is
Code:
$ ifconfig
example:
eth0: 192.168.1.3
use a vnc server on your computer connect to ip address in ifconfig (port 5901 default for this chroot)
anyone know if or where the atrix wireless drivers are for this?

Arch linux chroot

I started using Arch some months ago and I really enjoying it. Coming from a released based distro, it feels really nice been able to choose exactly what you want to run in your system and always have the packages up to date. For a while I have been planning on running ubuntu in my transformer but I just don't feel too comfortable with ubuntu , so decided to run arch in my transformer. I couldn't find a tutorial so I scavenged the net and found bits and peace that I put together to make this tutorial. What I like about arch is that I am in control of my system and I can run exactly what I want, thanks awesomely documented Arch!
This is a tutorial that will show you how to run Arch Linux in a chrooted environment within your Asus Tarsnformer. I will not provide a simple script that if you run it will do everything for you, instead I will teach you how to make your own installation by grabbing all necessary elements.
You will need:
Arch Live image: Go to http://archlinuxarm.org/developers/downloads and grab the omap 3/4 package.
Install environment: It can be your internal storage or a sd/micro card. Here I will show how to use the micro sd card.
Script for starting the chroot: I grabbed mine from http://forum.xda-developers.com/showthread.php?t=1517993&highlight=chroot and did some modifications. Thanks-miska-
Rooted Asus Transformer(Prime?) with Terminal: You need root to mount the file system and loop devices. In theory this should work in the Prime too.
Linux Machine
Step 1:
For installing arch in a (micro)sd card (I prefer micro as I don't need the dock for using it), first you need to format the card and make two partitions. (I used gparted) Make one partition fat and assign a small amount of space(I have a 4gb micro and assigned 128mb to the fat partition), then make the rest ext4. Make sure the fat partition is first and the ext one is second.
Step 2:
Now as root you need to extract the package in the ext partition of your card. REMEMBER to be root, I got stuck thinking there was something wrong with the package I downloaded but it was that I was unpacking as normal user.
Code:
# tar -c /path/to/extpartition -xzf ArchLinuxARM-omap-smp-latest.tar.gz
Now you have a arch environment in your (micro)sd card.
Step 3:
In your asus transformer create a folder called 'arch' in the root of your internal storage.
Code:
#mkdir /sdcard/arch
Or use a file manager.
Now place this script somewhere in your transformer, I usually keep it in /sdcard/Downloads
Code:
#!/bin/sh
# Modify this according to your needs
DEVICE="/dev/block/mmcblk1p2"
LOOP="no"
# Maybe this as well
MNT_PATH="/mnt/sdcard/arch"
# Modify only if you know, what are you doing
BINDS="dev dev/pts proc sys mnt/sdcard"
ANDROID_BINDS=" /system /data "
TMPS="tmp var/tmp var/log var/run"
MY_MOUNTS=""
unset PS1
# Helper functions
die() {
echo " $1"
exit 1
}
safe_mount() {
mkdir -p "$MNT_PATH""$2"
if [ "$3" ]; then
OPTION=" $3 "
else
OPTION=""
fi
if [ -z "`mount | grep " $MNT_PATH$2 "`" ]; then
mount $OPTION "$1" "$MNT_PATH$2" || die "Can't mount $2!!!"
fi
MY_MOUNTS="$MNT_PATH$2 $MY_MOUNTS"
}
# Real work
[ "`whoami || echo root`" = "root" ] || die "You must be root first!"
LOOP_ARG=""
[ "$LOOP" = "no" ] || LOOP_ARG=" -o loop "
safe_mount $DEVICE "" "$LOOP_ARG -t ext4 "
for i in $BINDS; do
safe_mount "/$i" "/$i" " -o bind "
done
if [ -d /Removable ]; then
for i in /Removable/*; do
[ -d "$i" ] && safe_mount $i /mnt$i " -o bind "
done
fi
for i in $ANDROID_BINDS; do
safe_mount $i /mnt/android$i " -o bind "
done
for i in $TMPS; do
safe_mount none /$i " -t tmpfs "
done
mount -o remount,ro "$MNT_PATH"
chroot "$MNT_PATH" /sbin/fsck.ext2 -y "$DEVICE"
mount -o remount,rw "$MNT_PATH"
# Tweak configuration of the chroot during first start
#if [ \! -f "$MNT_PATH"/etc/profile.d/tweak.sh ]; then
#mkdir -p "$MNT_PATH"/home/opensuse
echo 'nameserver 8.8.8.8' > "$MNT_PATH"/etc/resolv.conf
#echo 'net:x:3003:root,opensuse' >> "$MNT_PATH"/etc/group
#echo 'opensuse:x:1000:100::/home/opensuse:/bin/bash' >> "$MNT_PATH"/etc/passwd
#echo 'opensuse:$1$joWqOQdr$YsapocP32UtdiR3PKBXVM1:15395:0:::::' \
# >> "$MNT_PATH"/etc/shadow
#sed -i 's|^root:.*|root:$1$joWqOQdr$YsapocP32UtdiR3PKBXVM1:15395:0:::::|' \
# "$MNT_PATH"/etc/shadow
#echo '#!/bin/sh
#export TERM=linux
#export LANG="en_US.utf-8"
#export EDITOR="busybox vi"
#alias vi="busybox vi"
#precmd() { :; }
#if [ "`whoami`" = root ]; then
# export HOME=/root
# export USER=root
# hostname -F /etc/HOSTNAME
#fi
#if [ -z "$CHROOTED" ]; then
# export CHROOTED=yes
# export HOME="/home/opensuse"
# export USER="opensuse"
# su opensuse
#fi
#' > "$MNT_PATH"/etc/profile.d/tweak.sh
#fi
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/system/xbin:/system/bin"
# Chroot
chroot "$MNT_PATH" /bin/bash
#chroot "$MNT_PATH" /root/init.sh
# Cleanup
echo "Umount everything"
for i in $MY_MOUNTS; do
umount -l $i
done
Step 4:
Chmod +x the script and run it as root.
Code:
su
#chmod +x scriptname.sh
sh scriptname.sh
The script will mount the ext partition of your (micro)sd card in /sdcard/arch and will chroot into it. It also does other really nice things, such as mounting your android partitions to /mnt so you can access them from within your arch environment. I have disabled some lines that are used to set up a some environment variables, but you should still be able to get a fully functional command-line environment and you can enable them and modify them as you want.
Step 5:
The rest is completely up to you, now you have arch running in your transformer. But what!? You need X?! really???? Ok, so lets create a vnc server so we can remote into it.
Your network connection should work, so the first thing to do is an update
Code:
#pacman -Syu
Now install xorg
Code:
#pacman -S xorg-server xorg-xinit xorg-twm xorg-xclock xterm
Now install a vncserver
Code:
#pacman -S tightvnc
And now this is the tricky part(And I spent a lot of time in this).
I grabbed this script from the UbuntuInstaller post. This is the script they use for setting a resolution at each boot. What I did was to remove the resolution prompt and fix the resolution to 1280x752(fullscreen) and remove some ubuntu stuff. I also added an export for HOME and USER that will allow you to run 'vncserver' as root.
Code:
#!/bin/bash
#############################################
# Asks User to screen size and saves as REZ #
#############################################
#echo "Now enter the screen size you want in pixels (e.g. 800x480), followed by [ENTER]:"
#read REZ
###########################################
# Tidy up previous LXDE and DBUS sessions #
###########################################
#rm /tmp/.X* > /dev/null 2>&1
#rm /tmp/.X11-unix/X* > /dev/null 2>&1
#rm /root/.vnc/localhost* > /dev/null 2>&1
#rm /var/run/dbus/pid > /dev/null 2>&1
############################################################
# enable workaround for upstart dependent installs #
# in chroot'd environment. this allows certain packages #
# that use upstart start/stop to not fail on install. #
# this means they will have to be launched manually though #
############################################################
#dpkg-divert --local --rename --add /sbin/initctl > /dev/null 2>&1
#ln -s /bin/true /sbin/initctl > /dev/null 2>&1
###############################################
# start vnc server with given resolution and #
# DBUS server, (and optionally an SSH server) #
###############################################
export HOME="/root/"
export USER="root"
vncserver :0 -geometry 1280x752
dbus-daemon --system --fork > /dev/null 2>&1
/etc/rc.d/sshd start
#echo
#echo "If you see the message 'New 'X' Desktop is localhost:0' then you are ready to VNC into your ubuntu OS.."
#echo
#echo "If VNC'ing from a different machine on the same network as the android device use the 1st address below:"
##########################################
# Output IP address of android device #
##########################################
ifconfig | grep "inet addr"
#echo
#echo "If using androidVNC, change the 'Color Format' setting to 24-bit colour, and once you've VNC'd in, change the 'input mode' to touchpad (in settings)"
#echo
#echo "To shut down the VNC server and exit the ubuntu environment, just enter 'exit' at this terminal - and WAIT for all shutdown routines to finish!"
#echo
###############################################################
# Spawn and interactive shell - this effectively halts script #
# execution until the spawning shell is exited (i.e. you want #
# to shut down vncserver and exit the ubuntu environment) #
###############################################################
/bin/bash -i
#########################################
# Disable upstart workaround and #
# kill VNC server (and optionally SSH) #
# Rename used xstartup to its first file#
#########################################
vncserver -kill :0
/etc/rc.d/sshd stop
Place this script in /root/, give it the name 'init.sh' and make sure it is executable(chmod +x). Now in the previous script comment the line:
Code:
chroot "$MNT_PATH" /bin/bash
and uncomment the line
Code:
chroot "$MNT_PATH" /root/init.sh
Step 6:
Now you should be able to start a vncserver with twm as your window manager and a xterm.
You can now go to
https://wiki.archlinux.org/index.php/Desktop_Environment
or
https://wiki.archlinux.org/index.php/Window_Manager
and set up the desktop environment that you like the most.
Remember that you need to set up the graphical environment to start manually and not at boot. In a normal environment you would usually use 'startx' which will read the .xinitrc file and run the programs from there. In our case put everything that needs to go into .xinitrc into ~/.vnc/xstartup. An example of my ~/.vnc/xstartup
Code:
#!/bin/bash
xrdb $HOME/.Xresources
exec startfluxblox
This will start an empty fluxbox window manager.

[HOWTO] Add init.d to stock ROM + a few other goodies

I have been resisting the urge to flash a custom ROM for a bit, but I really miss having init.d support. So I read a few threads for other phones and rolled my own.
Warnings
I borrowed bits and pieces from various places. If you don't know what init.d is, you probably don't want to do this. If you aren't willing to take responsibility for bricking your tablet, don't do this. Seriously, the risk of bricking is very low, but if you aren't comfortable booting into an adb shell from recovery, maybe this is not for you. Strongly suggest a nandroid backup before you get started so if you totally bork things you can just hit rewind.
Note: The latest CWM may prompt you on a reboot that the ROM may overwrite the bootloader and offer to fix it for you. Don't do that. The init.d hack takes over the bootloader install script, but does not change your bootloader! If you accidentally do let it fix things for you, just rebuild the install-bootloader.sh file. The other steps should be fine.
Prerequisites
First, you need root, busybox, and some sort of terminal (either adb, or some terminal you like using on the tablet).
I have found that I like Busybox Installer (from the market; https://play.google.com/store/apps/details?id=com.jrummy.busybox.installer) but for some reason it doesn't create new symlinks unless you click advanced install.
Let's get to it!
In the shell (don't type # or anything after #):
Code:
su # get root
mount -o remount,rw /system # get access to /system (4.04 seems to mount ro as is usual; seems like the original mounted rw)
which run-parts # if you don't see /system/xbin/run-parts you need to install/reinstall busybox; if it is somewhere else, note it
mkdir /system/etc/init.d
Create a file called sysinit -- we are going to put it in /system/bin. You can edit it in place with vi, mount your tablet and edit it on your computer, or create it on the computer and push it via adb. Whatever.
Here's the file (you do need the # and the things after it in the file!):
Code:
#!/system/bin/sh
export PATH=/sbin:/system/sbin:/system/bin:/system/xbin
/system/bin/logwrapper /system/xbin/run-parts /system/etc/init.d
Note that if your run-parts is not in /system/xbin (from the which command) then fix the above to reflect your reality.
In the shell, make it executable
Code:
chmod 755 /system/bin/sysinit
Now go in the init.d directory and create some things you want to run at start up. For example:
Code:
cd /system/etc/init.d
echo '#!/system/bin/sh' >99test # note: you do need the first # in this line but not the 2nd!
echo 'date >>/data/tmp/init.d-log.txt' >>99test
chmod 755 99test
Here's a more practical one (yes, you need the # signs). Name it something like 10diskperf -- don't forget to chmod it.
Code:
#!/system/bin/sh
# Set disk read aheads to 1024
chmod 777 /sys/block/mmcblk0/queue/read_ahead_kb
echo "1024" > /sys/block/mmcblk0/queue/read_ahead_kb
chmod 777 /sys/block/mmcblk1/queue/read_ahead_kb
echo "1024" > /sys/block/mmcblk1/queue/read_ahead_kb
chmod 777 /sys/devices/virtual/bdi/179:0/read_ahead_kb
echo "1024" > /sys/devices/virtual/bdi/179:0/read_ahead_kb
Or here is one to tweak some TCP parameters (25sysctl):
Code:
#!/system/bin/sh
sysctl -w net.core.rmem_max=524288
sysctl -w net.core.wmem_max=524288
sysctl -w net.ipv4.tcp_rmem=6144 87380 524288
sysctl -w net.ipv4.tcp_wmem=6144 87380 524288
Whatever files you put in, you need to remember to make them executable (chmod 755).
Finally, you need to kick it all off at start up. The hack for that is we are going to create /system/etc/install-recovery.sh which apparently runs on each boot.
Code:
cd /system/etc
echo '#!/system/bin/sh' >install-recovery.sh
echo '/system/bin/sysinit' >>install-recovery.sh
chmod 755 install-recovery.sh
Tips and troubleshooting
If you are too lazy to cut and paste I have the files here (View attachment init.d-support.zip) that you can just move to the right places and change permission. If you are really lazy there is lightly tested install script below.
I like to try running the whole thing before a reboot to see if I get any errors:
Code:
/system/etc/install-recovery.sh
I'd suggest putting the 99test file in first. Verify that you get the expected file in /data/tmp and then reboot and check again. Then you can remove 99test.
Same goes for adding new scripts. Try running them from the shell to see if they throw errors before you reboot!
If you have trouble, see if this looks right:
Code:
ls -ld /system/etc/install-recovery.sh /system/bin/sysinit /system/etc/init.d /system/xbin/run-parts
-rwxr-xr-x root root 39 2012-07-14 10:00 install-recovery.sh
-rwxr-xr-x root root 140 2012-07-14 10:01 sysinit
drwxrwxrwx root root 2012-07-14 10:10 init.d
lrwxrwxrwx root root 2012-07-14 09:55 run-parts -> /system/xbin/busybox
For the brave
The install-init.d zip file (View attachment install-init.d.zip) contains a lightly tested script that SHOULD do the install steps for you.
Send the file to your android to someplace that can execute code (e.g., /system/xbin; I had to use adb to put it on the sdcard and then move it to /systemxbin in the shell since I don't have the adb root kernel installed).
Code:
cd /system/xbin # or wherever you have it
chmod 755 install-init.d
./install-init.d
It performs rude checks to see if init.d exists, and tries to handle moving or missing busybox. It only installs 99test as a script.
Let me know if this works or doesn't work for you.
For the extra brave: There is no reason this should only work on the Samsung. This ought to work on pretty much most stock ROMs as long as they execute install-recovery.sh on start up.
Scripts
What do you put in your init.d? If you post anything cool I'll put it up here in the op.
One that gave me some real gains in I/O performance required a new version of the tune2fs executable. By default, it is part of busybox but the busybox one only has a few simple options. I've included a stand alone version and the script 10disktune here View attachment disktune.zip. Unpack the zip and put the 10disktune in /system/etc/init.d (don't forget to chmod) and put tune2fs in /system/bin (chmod that too). Note that busybox has one in /system/xbin but the script specifically calls out the one in /system/bin.
Here's one that will zipalign your apks on each boot
Code:
#!/system/bin/sh
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk
ZCHECK=$?
if [ $ZCHECK -eq 1 ]; then
zipalign -f 4 $apk /cache/$(basename $apk)
if [ -e /cache/$(basename $apk) ]; then
cp -p -f /cache/$(basename $apk) $apk
rm /cache/$(basename $apk)
fi;
fi;
done;
Fin
Corrections welcome. I considered using exec or . to load some of this into one shell but given that it runs once at startup, I figured it is fine as is.
All files for reference
View attachment init.d-support.zip
View attachment install-init.d.zip
View attachment disktune.zip
Great guide, gonna try it tonight.
Sent from a GNote, hell yeah!
SirRhor said:
Great guide, gonna try it tonight.
Sent from a GNote, hell yeah!
Click to expand...
Click to collapse
I'm curious how it went. If you ran into any issues, let me know so I can update the op. Thanks!
Hmm did anyone get this to work?
wd5gnr said:
Hmm did anyone get this to work?
Click to expand...
Click to collapse
I did it on my Galaxy Nexus.
It works great, I had a bit of problem with the sysinit file, but when I downloaded your zip file and used your sysinit, it worked, so it must be a problem from my side
Thanks for this, I can finally use "Odex Me"
aavan said:
I did it on my Galaxy Nexus.
It works great, I had a bit of problem with the sysinit file, but when I downloaded your zip file and used your sysinit, it worked, so it must be a problem from my side
Thanks for this, I can finally use "Odex Me"
Click to expand...
Click to collapse
Great, just wanted to be sure I hadn't made any typos/errors in the guide.
A lot of init.d files collected here: http://forum.xda-developers.com/showthread.php?t=1227269
Also build.prop things, etc.
Thanks, I use your guide and worksperfect for my RK3066 devices. Very simple to understand all steps and what we are doing to our system, perfect for me. Thanks again dude
Melch1zedeK said:
Thanks, I use your guide and worksperfect for my RK3066 devices. Very simple to understand all steps and what we are doing to our system, perfect for me. Thanks again dude
Click to expand...
Click to collapse
Glad to help!
What is thhe utility of this?
moliverac8 said:
What is thhe utility of this?
Click to expand...
Click to collapse
Init.d is how Linux and many Android (which is kind of Linux, after all) systems manage executing commands on boot up.
The /etc/init.d files run in numerical order as root and you can do things like change system settings, manipulate the file system, etc.
See the init.d section linked below for some ideas.
http://forum.xda-developers.com/showthread.php?t=1227269
Question? what is the difference in this method and running a script?
wd5gnr said:
Init.d is how Linux and many Android (which is kind of Linux, after all) systems manage executing commands on boot up.
The /etc/init.d files run in numerical order as root and you can do things like change system settings, manipulate the file system, etc.
See the init.d section linked below for some ideas.
http://forum.xda-developers.com/showthread.php?t=1227269
Click to expand...
Click to collapse
I use the "swap memory script" and was wondering if it would also work this way with the init.d If so would there be any benefit this way over the current way of running it one way or the other? One drawback I see running the script as is is that I have to wait once the system has fully booted until the script has run and I see the Smanager screen to let me know that my memory has been remounted.
Thanks for the info and the learning process.
Here is the script and the link.
http://forum.xda-developers.com/showthread.php?t=1961097
Code:
sleep 5
mount -o remount,rw /
mount -t vfat -o umask=0000 /dev/block/vold/179:25 /mnt/sdcard
sleep 5
mount -o bind /data/media /mnt/extSdCard
As long as the device is ready to mount at boot time and doesn't get remounted, ought to work. Backup and try it
External memory wasn't ready
wd5gnr said:
As long as the device is ready to mount at boot time and doesn't get remounted, ought to work. Backup and try it
Click to expand...
Click to collapse
Thanks for the guide, but I think that the external memory was not ready to be mounted at that time. it didn't see the card till after boot. It was worth a shot, Reverted back to the script in /data and all worked again,
Note: I didn't find /system/xbin/run-parts however, I did find /system/bin/run-parts and changed the path to reflect that, I don't think this was an issue but I'm not 100% sure.

Install full Linux OS on note 10.1 2014 using Linux deploy.

If we can install full Linux OS on note 10.1 2014, then it will become the truly laptop replacement.
It seems that Linux deploy is very promising, but it require a truly working root
Someone used Linux deploy to install full Linux OS on note 10.1 2012 and turned note into a full Linux laptop when needed.
https://play.google.com/store/apps/details?id=ru.meefik.linuxdeploy
Can someone savvy give it a try?
I've played around with a few installers and in the terminal by hand for a few hours. I am not able to grant permission to chroot. Even with root. I will look into this in the future.
dasmoover said:
I've played around with a few installers and in the terminal by hand for a few hours. I am not able to grant permission to chroot. Even with root. I will look into this in the future.
Click to expand...
Click to collapse
someone managed to install Linux on note3
https://github.com/meefik/linuxdeploy/issues/77
Since note 10.1 2014 is essentially an enlarged note3, above information maybe helpful for you
Got Linux deploy (linuxonandroid) app working with work
Hello, Sorry meant to say Complete Linux Installer in the topic, not Linux Deploy!
I tried the Linux Deploy project with no luck. The post that was in this thread got me to the point that you need to apply a patch in the source code ShellEnv.java and then recompile. It sets it up so it prefaces all commands in the script with su when run. I was not able to recompile the code nor anyone that could give it to me. So I moved on to the Complete Linux Installer linuxonandroid app http://linuxonandroid.org/ I ran into the same problems but I was able to get around it because the script that is used to starts the Linux distribution is editable it is bootscript.sh placed in /data/data/com/zpwebsites.linuxonandroid/files this script is automatically created when you walk through the setup/install process while you are downloading an image file going through the setup process you can edit this file as it will be created at that point, where ever you see "$bbox and a xxxxx" in the script you change it to "su $bbox and xxxxxxx" so basically you have to preface all these points which there are a lot of with su. This is part of the situation. Second part is that you will need to setup the mount point for the loop directory by hand and you can see this in the script, then you will need to mount the loop directory and then create each directory inside to what is specified in the script.Then unmount the loop directory, or reboot and then you can finish the setup and launch the distribution.
You may run into errors along the way and you will need to correct them as needed. This is no easy task to setup unless you are familiar with linux and what the script is doing. Sorry I have no easy way but I was able to get it running with the Ubuntu small images to even include the display, still having so issues getting the xwindow to display correctly in the other large images which are close to a full distribution.
All my work was done with a terminal emulator, root explorer, a text editor, Complete Linux Installer(linuxonandroid from ZPWebSites), and a VNC client. Oh and using the spen and Bluetooth keyboard helps as it takes more time with just the touch interface and keyboard for what needs to be done.
It is possible to get running but you have to work at it, took me 3 hours to work through all the issues and I am familiar with Linux and its tools.
Hope this gets you in the direction you need because it was important to me to get this working for what I do. I have sent updates to the developer to hope he can automate this in the future. With Samsung's Android implementation with multiple user config it messes with the security context of scripts because each command can be run through an interactive terminal session. But the script needs to pass SU with the commands to get it to work.
I have a Samsung Galaxy Note 10.1 2014 WIFI P600 and should work with the other models too because not specific to a model. Seems this work with a Galaxy S4 as well since they are setup the same in the OS from what I have found.
quser1 said:
Hello, Sorry meant to say Complete Linux Installer in the topic, not Linux Deploy!
I tried the Linux Deploy project with no luck. The post that was in this thread got me to the point that you need to apply a patch in the source code ShellEnv.java and then recompile. It sets it up so it prefaces all commands in the script with su when run. I was not able to recompile the code nor anyone that could give it to me. So I moved on to the Complete Linux Installer linuxonandroid app http://linuxonandroid.org/ I ran into the same problems but I was able to get around it because the script that is used to starts the Linux distribution is editable it is bootscript.sh placed in /data/data/com/zpwebsites.linuxonandroid/files this script is automatically created when you walk through the setup/install process while you are downloading an image file going through the setup process you can edit this file as it will be created at that point, where ever you see "$bbox and a xxxxx" in the script you change it to "su $bbox and xxxxxxx" so basically you have to preface all these points which there are a lot of with su. This is part of the situation. Second part is that you will need to setup the mount point for the loop directory by hand and you can see this in the script, then you will need to mount the loop directory and then create each directory inside to what is specified in the script.Then unmount the loop directory, or reboot and then you can finish the setup and launch the distribution.
You may run into errors along the way and you will need to correct them as needed. This is no easy task to setup unless you are familiar with linux and what the script is doing. Sorry I have no easy way but I was able to get it running with the Ubuntu small images to even include the display, still having so issues getting the xwindow to display correctly in the other large images which are close to a full distribution.
All my work was done with a terminal emulator, root explorer, a text editor, Complete Linux Installer(linuxonandroid from ZPWebSites), and a VNC client. Oh and using the spen and Bluetooth keyboard helps as it takes more time with just the touch interface and keyboard for what needs to be done.
It is possible to get running but you have to work at it, took me 3 hours to work through all the issues and I am familiar with Linux and its tools.
Hope this gets you in the direction you need because it was important to me to get this working for what I do. I have sent updates to the developer to hope he can automate this in the future. With Samsung's Android implementation with multiple user config it messes with the security context of scripts because each command can be run through an interactive terminal session. But the script needs to pass SU with the commands to get it to work.
I have a Samsung Galaxy Note 10.1 2014 WIFI P600 and should work with the other models too because not specific to a model. Seems this work with a Galaxy S4 as well since they are setup the same in the OS from what I have found.
Click to expand...
Click to collapse
Can you upload the edited script?
dasmoover said:
Can you upload the edited script?
Click to expand...
Click to collapse
Yes, I will try. One thing is that the script is producing errors when you try to Exit the running distro with syntax errors on a couple of commands and I have not been able to fix them, they looks like script issues from the generated script, still need investigation and I have contacted the developer. Only way I have been able to get the system to unmount the loop device after an exit is to restart the tablet because of the script errors. Also you will need to create all the file system in the loop directory as the script is not doing it automatically.
---------- Post added at 09:43 AM ---------- Previous post was at 09:26 AM ----------
Tried to attach file so keep getting error so pasting the script here. Just so you know this is an auto created script on setup so not sure if it is different for each install.
###########################################
# Linux boot script V8 for Android v4.3 #
# Built by Zachary Powell (zacthespack) #
# and Martin Møller (Tuxling) #
# Thanks to: #
# Johan Vromans #
# Marshall Levin #
# Vaykadji #
# and to everyone at XDA! #
# Feel free to edit/use this script as you#
# like but credit Linuxonandroid.org #
###########################################
# $ver: V8 #
###########################################
###########################################
# This is a function we use to stop the #
# script in case of errors #
###########################################
error_exit() {
echo "Error: $1"
exit 1
}
###########################################
# Set up variables #
###########################################
if [ -f /data/data/com.zpwebsites.linuxonandroid/files/busybox ]; then
export bbox=/data/data/com.zpwebsites.linuxonandroid/files/busybox
elif [ -f /data/data/com.zpwebsites.linuxonandroid.opensource/files/busybox ]; then
export bbox=/data/data/com.zpwebsites.linuxonandroid.opensource/files/busybox
else
export bbox=/system/xbin/busybox
fi
export usermounts=android # Base folder all user mounts are done in, should be moved to app later
export imgfile=$(dirname $0)/ubuntu.img # Default image file, another can be set by using an argument
export bin=/system/bin
export mnt=/data/local/mnt
export USER=root
if [[ ! -d $mnt ]]; then mkdir $mnt; fi
export PATH=$bin:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/usr/local/sbin:/usr/games:$PATH
export TERM=linux
export HOME=/root
###########################################
# Handle arguments if present #
###########################################
if [ $# -ne 0 ]; then
if [ -f $1 ]; then # Is full path present?
imgfile=$1
elif [ -f $(dirname $0)/$1 ]; then # Is only a filename present?
imgfile=$(dirname $0)/$1
else
error_exit "Image file not found!($1)"
fi
fi
###########################################
# If a md5 file is found we check it here #
###########################################
if [ -f $imgfile.md5 ]; then
echo "MD5 file found, use to check .img file? (y/n)"
read answer
if [ $answer == y ]; then
echo -n "Validating image checksum... "
$bbox md5sum -c -s $imgfile.md5
if [ $? -ne 0 ];then
echo "FAILED!"
error_exit "Checksum failed! The image is corrupted!"
else
echo "OK"
rm $imgfile.md5
fi
fi
fi
################################
# Find and read config file #
# or use defaults if not found #
################################
use_swap=no
cfgfile=$imgfile.config # Default config file if not specified
if [ -f $imgfile.config ]; then
source $imgfile.config
fi
###########################################
# Set Swap up if wanted #
# #
###########################################
if [ $use_swap == yes ]; then
if [ -f $imgfile.swap ]; then
echo "Swap file found, using file"
echo "Turning on swap (if it errors here you do not have swap support"
swapon $imgfile.swap
else
echo "Creating Swap file"
dd if=/dev/zero of=$imgfile.swap bs=1048576 count=1024
mkswap $imgfile.swap
echo "Turning on swap (if it errors here you do not have swap support"
swapon $imgfile.swap
fi
fi
###########################################
# Set up loop device and mount image #
###########################################
echo -n "Checking loop device... "
if [ -b /dev/block/loop255 ]; then
echo "FOUND"
else
echo "MISSING"
# Loop device not found so we create it and verify it was actually created
echo -n "Creating loop device... "
su $bbox mknod /dev/block/loop255 b 7 255
if [ -b /dev/block/loop255 ]; then
echo "OK"
else
echo "FAILED"
error_exit "Unable to create loop device!"
fi
fi
su $bbox losetup /dev/block/loop255 $imgfile
if [ $? -ne 0 ];then error_exit "Unable to attach image to loop device! (Image = $imgfile)"; fi
su $bbox mount -t ext4 /dev/block/loop255 $mnt
if [ $? -ne 0 ];then error_exit "Unable to mount the loop device!"; fi
###########################################
# Mount all required partitions #
###########################################
su $bbox mount -t devpts devpts $mnt/dev/pts
if [ $? -ne 0 ];then error_exit "Unable to mount $mnt/dev/pts!"; fi
su $bbox mount -t proc proc $mnt/proc
if [ $? -ne 0 ];then error_exit "Unable to mount $mnt/proc!"; fi
su $bbox mount -t sysfs sysfs $mnt/sys
if [ $? -ne 0 ];then error_exit "Unable to mount $mnt/sys!"; fi
su $bbox mount -o bind /sdcard $mnt/sdcard
if [ $? -ne 0 ];then error_exit "Unable to bind $mnt/sdcard!"; fi
if [[ ! -d $mnt/root/cfg ]]; then mkdir $mnt/root/cfg; fi
su $bbox mount -o bind $(dirname $imgfile) $mnt/root/cfg
su $bbox mount -o bind /sys/fs/selinux $mnt/selinux
###########################################
# Checks if you have a external sdcard #
# and mounts it if you do #
###########################################
if [ -d /sdcard/external_sd ]; then
su $bbox mount -o bind /sdcard/external_sd $mnt/external_sd
fi
if [ -d /Removable/MicroSD ]; then
su $bbox mount -o bind /Removable/MicroSD $mnt/external_sd
fi
# This is for the HD version of the Archos 70 internet tablet, may be the same for the SD card edition but i dont know.
if [ -d /storage ]; then
su $bbox mount -o bind /storage $mnt/external_sd
fi
###########################################
# Mount all user defined mounts if any #
###########################################
if [ -f $imgfile.mounts ]; then
olddir=$(pwd)
echo "Mounting user mounts"
cd $mnt
if [[ ! -d $mnt/$usermounts ]]; then su $bbox mkdir -p $usermounts; fi
echo "# Script to unmount user defined mounts, do not delete or edit!" > $imgfile.shutdown
echo "cd $mnt/$usermounts" > $imgfile.shutdown
cd $mnt/$usermounts
for entry in $(cat "$imgfile.mounts"); do
ANDROID=${entry%;*}
LINUX=${entry#*;}
if [[ -d $ANDROID ]]; then
echo -n "Mounting $ANDROID to $usermounts/$LINUX... "
if [[ ! -d $mnt/$usermounts/$LINUX ]]; then su $bbox mkdir -p $LINUX; fi
su $bbox mount -o bind $ANDROID $mnt/$usermounts/$LINUX &> /dev/null
if [ $? -ne 0 ];then
echo FAIL
if [[ -d $mnt/$usermounts/$LINUX ]]; then su $bbox rmdir -p $LINUX; fi
else
echo OK
echo "su $bbox umount $mnt/$usermounts/$LINUX" >> $imgfile.shutdown
echo "su $bbox rmdir -p $LINUX" >> $imgfile.shutdown
fi
else
echo "Android folder not found: $ANDROID"
fi
done
echo "cd $mnt" >> $imgfile.shutdown
echo "su $bbox rmdir -p $usermounts" >> $imgfile.shutdown
cd $olddir
else
echo "No user defined mount points"
fi
###########################################
# Sets up network forwarding #
###########################################
su $bbox sysctl -w net.ipv4.ip_forward=1
if [ $? -ne 0 ];then error_exit "Unable to forward network!"; fi
# If NOT $mnt/root/DONOTDELETE.txt exists we setup hosts and resolv.conf now
if [ ! -f $mnt/root/DONOTDELETE.txt ]; then
echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
if [ $? -ne 0 ];then error_exit "Unable to write resolv.conf file!"; fi
echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
echo "127.0.0.1 localhost" > $mnt/etc/hosts
if [ $? -ne 0 ];then error_exit "Unable to write hosts file!"; fi
fi
###########################################
# Chroot into ubuntu #
###########################################
su $bbox chroot $mnt /root/init.sh $(basename $imgfile)
###########################################
# Shut down ubuntu #
###########################################
echo "Shutting down Linux ARM"
#for pid in `lsof | grep $mnt | sed -e's/ / /g' | cut -d' ' -f2`; do kill -9 $pid >/dev/null 2>&1; done
for pid in `su $bbox lsof | su $bbox grep $mnt | su $bbox sed -e's/ / /g' | su $bbox cut -d' ' -f2`; do su $bbox kill -9 $pid >/dev/null 2>&1; done
sleep 5
###########################################
# Unmount all user defined mounts if any #
###########################################
if [ -f $imgfile.shutdown ]; then
echo "Unmounting user defined mounts"
sh $imgfile.shutdown
rm $imgfile.shutdown
fi
su $bbox umount $mnt/root/cfg
su $bbox umount $mnt/sdcard
su $bbox umount $mnt/external_sd
su $bbox umount $mnt/dev/pts
su $bbox umount $mnt/dev
su $bbox umount $mnt/proc
su $bbox umount $mnt/sys
su $bbox umount $mnt/selinux
su $bbox umount $mnt
su $bbox losetup -d /dev/block/loop255 &> /dev/null
for those brave enough ,try SELinux Permissive Kernel,maybe all problems will be solved.
http://forum.xda-developers.com/showthread.php?t=2590311
robertchow said:
for those brave enough ,try SELinux Permissive Kernel,maybe all problems will be solved.
http://forum.xda-developers.com/showthread.php?t=2590311
Click to expand...
Click to collapse
Yes the kernel in the thread you posted allows for Linux function in Complete Linux Installer. After the kernel is installed either use Wanam Xposed and disabling SELinux to set as always Permissive, or using "setenforce 0" in terminal(this is only for the session and once the system reboots will go back to Enforcing or if "setenforce 1")
At that point if you use getenforce at a terminal will show as Permissive and Linux will boot normally with full function.
My hat goes off to the developer of the kernel because now I have everything on the tablet I need.
FYI on my Ubuntu large installs I am running into a new SELinux issue, even with it in Permissive doing an apt-get upgrade, causes issues with an error related to invalid security context selinux, cant remember the full error. I am not seeing this with the Fedora large image. When this happens with the Ubuntu ones it breaks the KDE GUI and the Application menu ends up blank. The error occurs when install packages try to address the Ubuntu Group security, packages like colord is just an example which do a security group change. Still plowing through how to fix. Till then using Fedora which I haven't used in years
Hi,
I tried with the large Ubuntu image and get an error as well with apt-get update...not being too conversant on Linux on Android, I would like to find out if you had a fix or a resolution from the developers? Might have to stay with the Xperia Z Tablet for Linux in the meantime...
Fedora 19 via Complete Linux Installer. Have Selinux Permissive Kernel, Selinux Mode Changer, and root of course. Otherwise FW is stock MJ6.
Just a few remarks:
The Fedora image is a bit small for a full blown Linux desktop. I copied the contents to a larger 8 GB image. Had to reformat the SD card with exFAT in order to store the image there. Copying was done on a desktop computer because MTP connection just stops at 4 GB.
Changes to scripts include changing the mount command for external_sd to /storage/extSdCard in boot script. Once Linux is up and running, change /root/init.sh, find the line that starts vncserver and append -dpi 300, otherwise fonts in Linux are barely readable. Wigdets are still kind of small but at least the fonts are readable now.
If you get a connection refused in AndroidVNC, you may have to set a password on the Linux terminal for user, that is su - fedora, then vncpasswd.
Todo: find out why second start of Linux fails on loop mount busy and why shutdown complains about umount of dev.
So, my note happily runs KDE desktop, LibreOffice, and kile for LaTeX. The latter was the main reason for putting Linux on the note.
caferick said:
Fedora 19 via Complete Linux Installer. Have Selinux Permissive Kernel, Selinux Mode Changer, and root of course. Otherwise FW is stock MJ6.
Just a few remarks:
The Fedora image is a bit small for a full blown Linux desktop. I copied the contents to a larger 8 GB image. Had to reformat the SD card with exFAT in order to store the image there. Copying was done on a desktop computer because MTP connection just stops at 4 GB.
Changes to scripts include changing the mount command for external_sd to /storage/extSdCard in boot script. Once Linux is up and running, change /root/init.sh, find the line that starts vncserver and append -dpi 300, otherwise fonts in Linux are barely readable. Wigdets are still kind of small but at least the fonts are readable now.
If you get a connection refused in AndroidVNC, you may have to set a password on the Linux terminal for user, that is su - fedora, then vncpasswd.
Todo: find out why second start of Linux fails on loop mount busy and why shutdown complains about umount of dev.
So, my note happily runs KDE desktop, LibreOffice, and kile for LaTeX. The latter was the main reason for putting Linux on the note.
Click to expand...
Click to collapse
Thanks for the post. I played around with linux on my note 2 and have been waiting to get it running on my 2014. How well does it handle linux?
Sent from my SM-P600 using XDA Premium 4 mobile app
Duly.noted said:
How well does it handle linux?
Click to expand...
Click to collapse
It runs reasonably well. I guess the limiting factor is disk I/O, or SD I/O in this case. I run KDE 4 in desktop mode with graphical desktop effects disabled and most of the KDE services like indexing disabled. It takes about 15-20 seconds from finished boot to desktop. Once the desktop is up and running, opening apps like LibreOffice is fast enough. Feels like with the first generation Atom netbooks. KDE is a resource hog, it would probably make sense to go for something that is lighter on resources but I chose KDE for girlfriend compatibility. She only knows KDE and I won't force her to learn the XFCE way or something even more obscure like Gnome3 http://forum.xda-developers.com/images/smilies/tongue.gif .
Vncserver runs at native full screen, ie 2560x1600 at 300 dpi. There was a noticable screen redraw lag when closing windows. That was easily fixed by disabling the desktop background image. I have not yet done any high load tasks. Only opened LibreOffice and kile for a quick check.
I have a cheapo foldable bluetooth keyboard. Need to get a small bluetooth mouse. Any recommendations? Or a small keyboard/touchpad combo I can take with me when traveling.
To Caferick - Fedora 19 step by step
Hi can you explain step by step how u got the Fedora 19 to wor pleasek? where i can find the bootscript?
Amadyl said:
Hi can you explain step by step how u got the Fedora 19 to wor pleasek? where i can find the bootscript?
Click to expand...
Click to collapse
Hum, a step by step guide would be rather longish. To answer the question: Complete Linux Installer scripts are located in /data/data/com.zpwebsites.linuxonandroid/files. There is the bootscript.sh. However, editing it is not strictly necessary. It should work as is. Alright, let's see
Preliminaries:
* need root on your device along with the usual suspects like busybox and terminal emulator (both on Google Play)
* need selinux set to permissive -> flash selinux permissive kernel (to be found in xda forums) and install something like SELinuxModeChanger (Play) set to always change SELinux mode to permissive, check by rebooting and then Configuration > General > Device Info, it should say Permissive
* useful apps include a decent file manager (I like TotalCommander), ZIP extractor (ZArchiver), text editor (Jota), these make things somewhat easier
* required app: AndroidVNC (Play)
1. Install Complete Linux Installer from Play
* start the app and open the menu by touching the < sign at the top left
* choose installation guides (or the like, my interface is not English)
* choose Fedora 19, there are four tabs, work through them in sequence, second tab presents a download button, if you have not yet installed Terminal and AndroidVNC you can use the two other buttons to do it now
* third tab asks you to unzip the downloaded image, the ZIP will probably be in /storage/emulated/0/download, move it to the root of your external SD card, unzip with Zarchiver
* there should now be a new folder fedoraXXXXX with two files in it, the fedora-*.img and an md5 file, you can safely delete the md5 file and maybe rename the image to something like fedora.img, likewise for the enclosing folder
* read the rest of tab 3 and 4
2. Start Linux
* go back to CompLinInstaller menu and push the second entry labeled Start
* a page will open and probably say Ubuntu in the drop down combo box above the Start button, change it to Fedora and type in the path to the image, like /storage/extSdCard/fedora/fedora.img
* push the Start button
* a terminal will open and a few lines will fly by. If everything goes well, you will be asked to set passwords two times, just use a trivial one like 12345678, you can change it later if you are paranoid about passwords
* you will be asked to set the resolution for VNC, type 2560x1600 which is the native resolution of the tab
* you will be asked whether you want to autostart VNC, type y
* you will be asked whether you want to start SSH server, type n
* your choice will be saved right beside the image file, in my case the file is called fedora.img.config, you can change it with any text editor
3. In the chroot terminal
* still in the terminal, the prompt should now say [email protected]
* while you are there, type su - fedora , the prompt should change to [email protected]
* type vncpasswd to set a password for VNC access, just use the same password as above, then type exit
* you are back at [email protected] If you have a keyboard (bluetooth or USB), you can edit the file init.sh with vi and append -dpi 300 to vncserver startup line. This setting will take effect at next start because vncserver. If you do not have a keyboard or do not know vi editor, you can skip this for now.
4. VNC
* start AndroidVNC, Nick: fedora, Password: 12345678, Address: localhost, Port: 5900, Color Format: 24-bit color (4bpp), Connect
* you should now see a linux desktop with tiny fonts
* hit the tabs config button to bring up AndroidVNC options, change input mode to touchpad
* you can now move the linux pointer with your finger on the display
5. Shutdown
* in VNC Linux logout just as you would log out of any other Linux desktop
* terminate VNC session by choosing Disconnect from AndroidVNC config menu
* switch to the still running terminal and type exit
* Linux now stops, wait a few seconds and close the terminal
There are still some minor problems with shutdown which I am trying to trace. A subsequent start of Linux will not work because of busy devices. So best reboot the tab and try again.
That's it for the base setup. Uh, the text is long indeed. Has it worked for you so far? Next comes customization
Corrections welcome, I typed this down from memory...
script
So we need to create script ourselves, when i've done it, i was set resolution to my tablet's resolution, then all is poor to see, that words and windows is too small to work, so it's horrible at the moment, but else works good enough. Is anyone know how to get normal UI on that big resolution? Sorry for my bad english.
Hey guys is there a walk through on how to increase the IMG size for fedora in a windowc pc ? i al ready have the SD partitioned just need to encrease the size to 10 GB
sits at boot up
My device is rooted, chroot installed, vnc installed, and busybox installed.
I install SELinux Permissive and systems sits at bootup screen. never boots to OS at any point. Just sits and the Samsung screen.
I have the Galaxy Note 10.1 SM-P600 (2014 Edition).
How long does it sit at the Samsung Boot screen before finally booting the rest of the way?
I installed using Odin 3.09.
I have running Ubuntu (xfce) on my Note 3 with Linux Deploy. VNC is not the way, it is slow. You should use framebuffer mode and you will be astonished how nice its running. Also, I modified xorg.conf for the phone to only react to stylus input and the stylus button to be right click. This setup is also working on my Note 10.1 old edition.
mdalacu said:
I have running Ubuntu (xfce) on my Note 3 with Linux Deploy. VNC is not the way, it is slow. You should use framebuffer mode and you will be astonished how nice its running. Also, I modified xorg.conf for the phone to only react to stylus input and the stylus button to be right click. This setup is also working on my Note 10.1 old edition.
Click to expand...
Click to collapse
Can we use it without linux deploy, because it doesn't work on sm-p605? Can you point us to some guide or documentation? Thanks.

Categories

Resources