meefik / linuxdeploy

Install and run GNU/Linux on Android
https://meefik.github.io/linuxdeploy
GNU General Public License v3.0
5.09k stars 681 forks source link

Not working on note 3 Android 4.3 #106

Open hmourad opened 10 years ago

hmourad commented 10 years ago

First of all I would like to say that I love this app. meefik has done a great job on this one

In fact I loved this app so much on mys Samsung S2 that I went and bought the Note 3 to enjoy this app on it.

Unfortunatelly I ran through a lot of problems. the application would not work as expected with the default settings.

THe first issue I had was that updating configuration always failed. I refered to the issues section and was able to get it working by changing the env directory to /data/local/ru.meefik.linuxdeploy/linux. I don't know why other directories will fail when I am running as root

Unfortunatelly after this the intall will not work and I get a lot of access denies in the debug output. I managed to work around this by modifying the linuxdeploy script to use /system/bin/sh instead of the default. also all chroots needed to be called from /system/xbin.

this had the linuxdeploy script running from the terminal, it was not possible to keep this changes whenver the app UI is used because it would revert the shell to the default path.

I used linuxdeploy install command and was able to have the img file created, mount successful, and first stage debootstrap ok (pkg downloads were ok, although I am not sure were they were downloaded to) unfortunatelly 2nd stage fail as the chroot command can not find /debootstrap/debootstrap

I was stuck at this stage and was not able to move forward.

I am not sure if this is 4.3 related or there is another reason. I even removed knox completely so that it doesn't interfer with the app but with no luck

I was wondering if any one made it work with the Note 3, or if a newer version that would resolve this problem is planned

any thoughts?

feifel commented 10 years ago

Hi hmourad I have also the Note 3 and run into similar problems. I have tried a lot of things but I finally had it working. I used fedora20 and used custom install to a directory (no image/partition). I was able to get X-Server running, I had not tried VNC, but had no success with framebuffer. Finally I have tried so many things, that I could not say what was necessary and what not. So I decided to revert everything back and do it again to find out which changes are really required and which one not. Unfortunately it does not work anymore. I must have something changed, which I now can't remember. But I will find it again as soon as I have a bit more time... Regarding your problem with chroot command, I think had this as well when I tried to run "/bin/ls -al" and believe that besides the /system/xbin/chroot must be used, the PATH variable in the linuxdeploy script must also be changed. I once made a small scripts to test exactly this issue:

!/system/bin/sh

export TERM=linux export HOME=/root export PATH=/usr/bin:/usr/sbin:/bin:$PATH mount -o bind /data/data/ru.meefik.linuxdeploy/fedora20 /data/data/ru.meefik.linuxdeploy/fedora20.mnt /system/xbin/busybox chroot /data/data/ru.meefik.linuxdeploy/fedora20.mnt/ /bin/ls -al umount -l /data/data/ru.meefik.linuxdeploy/fedora20.mnt

For the moment I just can tell you that at least fedora20 is working with this method on Note 3 after some tweeks. Once I'm able to reproduce the successful installation I will report again and will ask meefik to integrate it. (btw. I'm on MJ4 and have rooted with kingoapp and knox flag is not triggered).

hmourad commented 10 years ago

Hello feifel,

Thanks for your feedback

Do you happen to know what is the right sequence for the linuxdeploy commands

Will it be install first or do you need to run other commands first (prepare, configure, etc)

Let me know when you reinstall fedora, and if possible ask meefik for his plans for the 4.3 support

Cheers

feifel commented 10 years ago

Hi hmourad Yes, if you want to create a new installation you only need to call "install". This includes the steps (prepare, mount, "install", configure). If you afterwards want to change a configuration (e.g. XServer instead of VNC) you can just call "configure", which installs then only the required components on an installed base-system. Cheers

feifel commented 10 years ago

How to install Fedora 20 on Samsung Galaxy Note 3 with linux deploy:

Unfortunately the linuxdeploy script has some issues on the Galaxy Note 3, but I have figured out how to workaround them. Basically there are only 2 major issues: 1) The included busybox binaries are not working on gn3, but the one installed by stericson.busybox works fine. Therefore the first line of the linuxdeploy script and the PATH variable inside it must be modified. 2) The default installation to an image file on /storage/emulated/0/linux.img won't work and must be changed to e.g. /data/data/ru.meefik.linuxdeploy/linux

Besides that I also found some Fedora 20 specific issues: 1) Package mirror does not exists anymore the following must be used instead: http://dl.fedoraproject.org/pub/fedora/linux/releases/ 2) The package list contains some packages which no longer exists, but some others are missing. 3) The LXDE Desktop could not be started since the ~/.xsession is missing.

My approach is to provide a script called patch.sh which fixes those issues in the linuxdeploy script. Unfortunately the linuxdeploy script is overwritten by the linuxdeploy JAVA GUI if you changed some settings. This is a bit annoying if you want to use the GUI (although it is not really needed to use it, you can just call the linuxdeploy script directly from command line). But to be able to use the GUI as well, I have found a special hack that calls the patch.sh whenever the JAVA GUI has overwritten it. Please find the patch.sh in the end of my post.

Here is the step by step description of what is needed to run Fedora 20 with LXDE over XServer:

Here is the patch.sh script:

DIR=`dirname $0`
# run linuxdeploy as /system/bin/sh script
sed -i '/#!\//s@.*@#!/system/bin/sh@g' $DIR/env/bin/linuxdeploy
# ensure that /system/xbin/busybox and its links are used!
sed -i '/^PATH=/s@=\$@=/system/xbin:\$@g' $DIR/env/bin/linuxdeploy
# fix some fedora 20 issues with packages:
sed -i 's/libsss_sudo/sssd-common/g' $DIR/env/bin/linuxdeploy
sed -i -r '/20)/,/;;/s/libgssglue|libsss_sudo|nss-myhostname|systemd-sysv//g' $DIR/env/bin/linuxdeploy
sed -i -r '/20)/,/;;/s/zlib"/zlib p11-kit-trust kbd-legacy sssd-ad sssd-common-pac sssd-ipa sssd-krb5 sssd-ldap sssd-proxy pyxattr libmetalink libverto python-sssdconfig libsss_nss_imap dbus-x11 lxde-common"/g' $DIR/env/bin/linuxdeploy
# fix that ~.xsession is missing:
sed -i -r '/lxde)/,/;;/s#xstartup$#xstartup; chroot $MNT_TARGET su - $USER_NAME -c "ln -s /bin/lxsession ~/.xsession"#g' $DIR/env/bin/linuxdeploy                                                                                            
# hack so that update env applies this patch:
sed -i 's@CUSTOM_SCRIPTS=.*@CUSTOM_SCRIPTS="\\"|g'\'';../patch.sh"@g' $DIR/env/etc/deploy.conf

If you want to login as root via ssh, you can set a root password, by using the script setrootpw.sh:

#!/system/xbin/ash
export PATH=/usr/bin:/usr/sbin:/bin:/system/xbin
mount -o bind /data/data/ru.meefik.linuxdeploy/fedora20 /data/data/ru.meefik.linuxdeploy/env/mnt
chroot /data/data/ru.meefik.linuxdeploy/env/mnt/ passwd
umount /data/data/ru.meefik.linuxdeploy/env/mnt
hmourad commented 10 years ago

Thanks feifel for the valuable information and scripts. I will try it out after tweaking it a little bit with Kali linux

Have you ever figured out why it fails when running in a different directory.

My plan was to install this on a 64 gb sdcard that I bought specially for this purpose. Do you think the external sdcard will work. Should I unmount it amd remount it to a directory inside this path

Thanks again for all the information you shared On 17 Feb 2014 00:22, "feifel" notifications@github.com wrote:

How to install Fedora 20 on Samsung Galaxy Note 3 with linux deploy:

Unfortunately the linuxdeploy script has some issues on the Galaxy Note 3, but I have figured out how to workaround them. Basically there are only 2 major issues: 1) The included busybox binaries are not working on gn3, but the one installed by stericson.busybox works fine. Therefore the first line of the linuxdeploy script and the PATH variable inside it must be modified. 2) The default installation to an image file on /storage/emulated/0/linux.img won't work and must be changed to e.g. /data/data/ru.meefik.linuxdeploy

Besides that I also found some Fedora 20 specific issues: 1) Package mirror does not exists anymore the following must be used instead: http://dl.fedoraproject.org/pub/fedora/linux/releases/ 2) The package list contains some packages which no longer exists, but some others are missing. 3) The LXDE Desktop could not be started since the ~/.xsession is missing.

My approach is to provide a script called patch.sh which fixes those issues in the linuxdeploy script. Unfortunately the linuxdeploy script is overwritten by the linuxdeploy JAVA GUI if you changed some settings. This is a bit annoying if you want to use the GUI (although it is not really needed to use it, you can just call the linuxdeploy script directly from command line). But to be able to use the GUI as well, I have found a special hack that calls the patch.sh whenever the JAVA GUI has overwritten it. Please find the patch.sh in the end of my post.

Here is the step by step description of what is needed to run Fedora 20 with LXDE over XServer:

  • install Busybox, Linux Deploy,XServer SXDL,Terminal Emulator from playstore
  • open Terminal Emulator get root and do:
    • cp patch.sh setrootpw.sh /data/data/ru.meefik.linuxdeploy/
    • chmod +x /data/data/ru.meefik.linuxdeploy/*.sh
    • mkdir /data/data/ru.meefik.linuxdeploy/fedora20
    • open linuxdeploy and do:
    • create a new config (e.g. fedora20)
    • goto Settings:
    • set ENV directory: /data/data/ru.meefik.linuxdeploy/env
    • select Debug mode
    • select Trace mode
    • select Logging
    • Log file /storeage/emulated/0/linuxdeploy.log
    • run Update ENV
      • goto Properties and select:
    • Distribution: Fedora
    • Distrubution suite: 20
    • Architecture: armhfp
    • Mirror URL: http://dl.fedoraproject.org/pub/fedora/linux/releases/
    • Installation type: Custom
    • Installation path: /data/data/ru.meefik.linuxdeploy/fedora20
    • Unser name: android
    • DNS server: Automatic detection
    • Localization: en_US.UTF-8
    • Desktop environment: LXDE
    • Select components:
      • Desktop Environment
      • SSH server
      • VNC server
      • X server
      • SSH: true
      • Port: 22
      • GUI: true
    • Graphics subsystem: X Window System
    • GUI seettings:
      • Display: 0
      • X server address: localhost
      • Select Custom scripts
    • List of scripts: add the following (hack to ensure that update env does apply the patch.sh) \"|g' etc/deploy.conf;../patch.sh;echo'
      • select install and wait for completion (~1-2h)
      • start XServer SXDL
  • in linuxdeploy press start
  • When you switch back to the XServer you see the LXDE Desktop

Here is the patch.sh script: DIR=dirname $0 run linuxdeploy as /system/bin/sh script

sed -i '/#!\//s@.*@#!/system/bin/sh@g' $DIR/env/bin/linuxdeploy ensure that /system/xbin/busybox and its links are used!

sed -i '/^PATH=/s@=\$@=/system/xbin:\$@g https://github.com/g' $DIR/env/bin/linuxdeploy fix some fedora 20 issues with packages:

sed -i 's/libsss_sudo/sssd-common/g' $DIR/env/bin/linuxdeploy sed -i -r '/20)/,/;;/s/libgssglue|libsss_sudo|nss-myhostname|systemd-sysv//g' $DIR/env/bin/linuxdeploy sed -i -r '/20)/,/;;/s/zlib"/zlib p11-kit-trust kbd-legacy sssd-ad sssd-common-pac sssd-ipa sssd-krb5 sssd-ldap sssd-proxy pyxattr libmetalink libverto python-sssdconfig libsss_nss_imap dbus-x11 lxde-common"/g' $DIR/env/bin/linuxdeploy fix that ~.xsession is missing:

sed -i -r '/lxde)/,/;;/s#xstartup$#xstartup; chroot $MNT_TARGET su - $USER_NAME -c "ln -s /bin/lxsession ~/.xsession"#g' $DIR/env/bin/linuxdeploy hack so that update env applies this patch:

sed -i 's@CUSTOM_SCRIPTS=.*@CUSTOM_SCRIPTS="\"|g'\'';../patch.sh"@ghttps://github.com/g' $DIR/env/etc/deploy.conf

If you want to login as root via ssh, you can set a root password, by using the script setrootpw.sh:

!/system/xbin/ash

export PATH=/usr/bin:/usr/sbin:/bin:/system/xbin mount -o bind /data/data/ru.meefik.linuxdeploy/fedora20 /data/data/ru.meefik.linuxdeploy/env/mnt chroot /data/data/ru.meefik.linuxdeploy/env/mnt/ passwd umount /data/data/ru.meefik.linuxdeploy/env/mnt

Reply to this email directly or view it on GitHubhttps://github.com/meefik/linuxdeploy/issues/106#issuecomment-35218142 .

feifel commented 10 years ago

I think the reason why the ENV directory must be changed is SELinux, but I'm not sure about this. And the reason why the installation folder could not be in /storage/sdcard0 is because it's file system type is sdcardfs which does not support file permission, symlink etc. This is for sure a problem if you want to install it to a folder, thats what I did, but i'm not sure if it works if you install to an image. So I'm not sure if you could install it to the sdcard, you have to try it, I'm sorry.

erenoglu commented 10 years ago

I managed to get it work on the SM-P605 Note 10.1 LTE, which has same hardware as Note 3 LTE. The trick is:

I don't know why many permission denied problems occur when executables (ie busybox, dd, mke2fs, linuxdeploy, debootstrap) are run from /data/local/linux/bin directly.

smollvrn commented 10 years ago

"Too many levels of symbolic links"

ghost commented 10 years ago

I was able to install linuxdeploy on my Galaxy Note 3 and my Galaxy Tab Pro running Kitkat 4.4 This is easy :

-1- Install Busybox somewhere (/system/xbin is fine)

-2- Change ENV Directory (in linuxdeploy/settings) from /data/local/linux to /data/data/ru.meefik.linuxdeploy/linux and hit Update ENV

-3- In a terminal : $ su -

cd /data/data/ru.meefik.linuxdeploy/linux/bin

rm sh chroot

ln -s /system/bin/mksh sh

ln -s /system/xbin/busybox chroot

-4- Install your linux. It should work. And start your vserver.

-5- In a terminal $ su -

. /data/data/ru.meefik.linuxdeploy/linux/bin/linuxdeploy shell

You are now in your vserver logged as root. You can change your password and add your user "android" in /etc/sudoers

erenoglu commented 10 years ago

On Samsung kernel, if you recompile it without the Samsung security flags (prevent root, prevent setuid) then it seems Linux deploy starts to work properly (and selinux can now be set to permissive)

siriom commented 9 years ago

feifel or anyone who has managed to install this on a rooted note 3 and actually has root access please mail me at siriom@gmail.com . would really appreciate it . Thanks.

siriom commented 9 years ago

Followed feifels instructions but i cant log as root , i run the root script lines and i still get authentication failed with the new password set. Any help plz ?

erenoglu commented 9 years ago

As I said in previous posts, you need to use a kernel with Samsung security features disabled, one of them prevents setuid which is needed to use sudo.

But I think you can set root password with sudo passwd root and then login with root user over ssh (without using setuid function).

siriom commented 9 years ago

greetings. First of all thanks for replying . Ok so here goes. I really need linux on my phone and it would really help with my job at the moment. So I've tried 2 setups.

Complete Linux installer.

When running the script it simply wont run when i click "start linux" So i tried running the lines in the script , 1 by 1 and they work. Yet when running the script it says not found or not allowed. OBviously somethings wrong with the paths or the permissions or both. I tried for a while and sort of gave up. It did show me it is possible though .. and i dont want to have to run a start script by hand every time i want to run linux.

Linux deploy. I run the instructions by feifel on https://github.com/meefik/linuxdeploy/issues/106 Except i get permission denied when i try installing so i $ su -

cd /data/data/ru.meefik.linuxdeploy/env/bin

rm sh chroot

ln -s /system/bin/mksh sh

ln -s /system/xbin/busybox chroot

and it completely installs. The only doubt i have is if the script , patch.sh is run I create a new script and enter in \"|g' etc/deploy.conf;../patch.sh;echo' exactly .... but im guessing its not running the patch.sh anyways .... So I get fedora installed I connect via xserver or vnc or whatever. It seems to work , the user android password seems to work. I cant get root . I simply dont know the SU password . Not having root screws me over totally. Heres where it gets weird. If i try changing the password of user android i get a token error. If i mount and chroot ....../fedora20 passwd , it asks me for a new password. I enter in a new password for root , it accepts "all token updated" I unmount , reboot and ... password doesnt work. I have the ability to setuid , I have root on my phone and everything seems to be working except well .... i dont have root on the installed fedora. Please help , any suggestions are welcome. Im at the end of my patience with this right now . ive read tons of forums and tried a bunch of things and it just doesnt make sense anymore... Much thanks

On Mon, Aug 4, 2014 at 12:00 PM, Emre Erenoglu notifications@github.com wrote:

As I said in previous posts, you need to use a kernel with Samsung security features disabled, one of them prevents setuid which is needed to use sudo.

But I think you can set root password with sudo passwd root and then login with root user over ssh (without using setuid function).

— Reply to this email directly or view it on GitHub https://github.com/meefik/linuxdeploy/issues/106#issuecomment-51046109.

erenoglu commented 9 years ago

Again, are you using a special kernel on your Android that unlocks Samsung special restrictions? Yes or no? If no, even if you can get root, it won't let you setuid. The token errors you are getting because your user is trying to become root when trying to change password and it's rejected by kernel.

I own a note 3. I had all sorts of problems with Linux Deploy. The busybox related errors are also due to kernel restrictions and selinux restrictions. The solution is either a custom built kernel with the security related lines disabled or use another kernel which does not use these or use Cyanogenmod (if you have hlte, ie snapdragon version).

siriom commented 9 years ago

Did a reinstall . 2 things to add. I added the script \"|g' etc/deploy.conf;../patch.sh;echo' as instructed. now when it boots it says "/etc/init.d/myscript no such file or directory" Meaning the script command replaced the original myscript the program installs with ? Doing a sudo passwd root now replies with "sudo: effective uid is not 0 , is /bin/sudo on a file system with the no suid option set or nfs file syem with root ?" (inside the freshly installed fedora 20 with the sugested script) any sugestions ?

siriom commented 9 years ago

screenshot_2014-08-04-22-45-06 screenshot_2014-08-04-22-44-58 I believe i am setting setuid ?

siriom commented 9 years ago

My model is SM-N9005 (hltexx) (internaltional version i believe ? ) and yes its a Snapdragon. One last thing to add : In a terminal su . /data/data/ru.meefik.linuxdeploy/linux/bin/linuxdeploy shell This got me logged on as root. I do a passwd , it asks for a password , enter it in twice. "passwd : all authentication tokens set successfully."

I log in Xserver xsdl and the password i just set ( 123 ) doesnt work. This no longer makes any sense to me so just tell me what kernel DOES work and ill get it installed. Thanks and sorry for the extra large images , didnt know it would turn out so big . my bad.

erenoglu commented 9 years ago

These don't mean anything since this is blocked at kernel level if you are using a Samsung kernel. What you show is simply application level stuff, they believe they setuid but when it actually comes to running the process with root user it gets blocked by the kernel.

I won't respond anymore since you are not answering my questions. I tried many things, managed to install Linux with bypassed execution limitations with symlinking to /system/xbin/busybox, moving other binaries there, but I could not use sudo even if I recompiled sudo binary with some patches. It did not work. So Don't spend your time if you won't use a specially compiled kernel or cyanogenmod. At least this is my experience. When you use a kernel without Samsung Security limitations and with possibility to disable selinux, then there are no errors at all. (Ps samsung kernel don't let you set selinux permissive neither, even if you are root)

siriom commented 9 years ago

Forgot to answer your question but yeah i am on a samsung kernel . Its rooted and a couple of items removed but yes its samsung.

I believe you chief , im an idiot at all of this. Can you point me in the direction of a specially compiled kernel ? I really dont want to do it myself , Its not that im lazy but yeah ... im gonna mess it up. Do you know if cyanogen works for my model ? ill go have a look maybe ill get lucky ...

erenoglu commented 9 years ago

Try some kernels from xda-developers note 3 n9005 android development threads, ask them if they disabled the setuid limitations and selinux or if you want to make the switch (like me) to Cyanogenmod, have a look at this : http://forum.xda-developers.com/showthread.php?t=2653028

faalkhah commented 7 years ago

And in my device Galaxy Tab S2 SM-T715Y can't sudo for none root users.