Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mount a sd cart on startup #1360

Open
jaum20 opened this issue May 22, 2023 · 12 comments
Open

mount a sd cart on startup #1360

jaum20 opened this issue May 22, 2023 · 12 comments

Comments

@jaum20
Copy link

jaum20 commented May 22, 2023

I am using LD with the image install (Ubuntu 18)
I have tried:

add an entry to fstab
add an entry to cron to be executed @reboot
add a SysVinit service

If I run 'sudo mount -a' it will mount the sd, but I can't make it mount automatically at startup. Any tips?

@qianbinbin
Copy link

Why not use the mount option in the APP?

If you don't want Android to mount your SD card during startup so that LP can mount it, check out https://gist.github.com/qianbinbin/e93e19940dda264cc5cd2ebdddbe565e

@jaum20
Copy link
Author

jaum20 commented Jun 16, 2023

If you don't want Android to mount your SD card during startup so that LP can mount it, check out https://gist.github.com/qianbinbin/e93e19940dda264cc5cd2ebdddbe565e

Infortunally I can not install magisk root

Why not use the mount option in the APP?

Any tips on how to do that? My sd is listed inside LD as /dev/block/mmcblk1

@qianbinbin
Copy link

The mount option in the APP is for folders already mounted by Android, but I'm not sure if it's suitable for a partition: bottom right button -> properties -> mounts, enable it and add a mount point like /sdcard - /mnt/sdcard.

The @reboot option seems not working with LP cron, since it's a non-standard option.

@qianbinbin
Copy link

Does mount -a work if a mount point added in fstab?

@jaum20
Copy link
Author

jaum20 commented Jun 16, 2023

Does mount -a work if a mount point added in fstab?

Yes. I had to do this everytime I start LD

@qianbinbin
Copy link

qianbinbin commented Jun 16, 2023 via email

@jaum20
Copy link
Author

jaum20 commented Jun 16, 2023

I created a /etc/init.d/mount_sd.sh script:

mount UUID=affdaccf-8998-4853-b2da-dd96bb45f78e /home/android/sd
but didn't work.

Fstab is UUID=affdaccf-8998-4853-b2da-dd96bb45f78e /home/android/sd ext4 defaults 0 0

@qianbinbin
Copy link

  1. Does full path (mount -> /usr/bin/mount) work?
  2. Does mount UUID=affdaccf-8998-4853-b2da-dd96bb45f78e /home/android/sd work if run manually?
  3. Did you enable the script by update-rc.d?
  4. Normally sysv scripts don't look like this, did your try /etc/rc.local?

@jaum20
Copy link
Author

jaum20 commented Jun 18, 2023

Does full path (mount -> /usr/bin/mount) work?

Didn't work

  • Does mount UUID=affdaccf-8998-4853-b2da-dd96bb45f78e /home/android/sd work if run manually?

yes

  • Did you enable the script by update-rc.d?

yes

4. Normally sysv scripts don't look like this, did your try /etc/rc.local?

there are not rc.local in etc. Must I create it?

@qianbinbin
Copy link

there are not rc.local in etc. Must I create it?

Not really, but it's useful when you want to run some scripts during startup. Create /etc/init.d/rc.local and enable it:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
        if [ -x /etc/rc.local ]; then
                [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
                /etc/rc.local
                ES=$?
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Create /etc/rc.local and chmod +x /etc/rc.local:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Mount your SD card here:
/usr/bin/mount UUID=affdaccf-8998-4853-b2da-dd96bb45f78e /home/android/sd

exit 0

You can add some commands in /etc/rc.local before exit 0 to test if it's executed, like /usr/bin/touch /tmp/it_worked.

@jaum20
Copy link
Author

jaum20 commented Jun 21, 2023

there are not rc.local in etc. Must I create it?

Not really, but it's useful when you want to run some scripts during startup. Create /etc/init.d/rc.local and enable it:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          rc.local
# Required-Start:    $all
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:
# Short-Description: Run /etc/rc.local if it exist
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
        if [ -x /etc/rc.local ]; then
                [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)"
                /etc/rc.local
                ES=$?
                [ "$VERBOSE" != no ] && log_end_msg $ES
                return $ES
        fi
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Create /etc/rc.local and chmod +x /etc/rc.local:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Mount your SD card here:
/usr/bin/mount UUID=affdaccf-8998-4853-b2da-dd96bb45f78e /home/android/sd

exit 0

You can add some commands in /etc/rc.local before exit 0 to test if it's executed, like /usr/bin/touch /tmp/it_worked.

Thank you for your help, bur didn't worked :(. The SD is not mounted at startup neither /tmp/it_worked is created

@qianbinbin
Copy link

OK, maybe something wrong with your sysv service, but you can always mount your SD card (requiring FAT32 or exFAT I guess?) on Android, then mount the directory in the APP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants