linuxdeploy icon indicating copy to clipboard operation
linuxdeploy copied to clipboard

mount a sd cart on startup

Open jaum20 opened this issue 2 years ago • 12 comments

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?

jaum20 avatar May 22 '23 21:05 jaum20

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

qianbinbin avatar Jun 14 '23 14:06 qianbinbin

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

jaum20 avatar Jun 16 '23 13:06 jaum20

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 avatar Jun 16 '23 13:06 qianbinbin

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

qianbinbin avatar Jun 16 '23 13:06 qianbinbin

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

Yes. I had to do this everytime I start LD

jaum20 avatar Jun 16 '23 18:06 jaum20

whats your sysv script like if you dont mind? did you try /etc/rc.local?


From: jaum20 @.> Sent: Saturday, June 17, 2023 2:11:34 AM To: meefik/linuxdeploy @.> Cc: Binbin Qian @.>; Comment @.> Subject: Re: [meefik/linuxdeploy] mount a sd cart on startup (Issue #1360)

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

Yes. I had to do this everytime I start LD

— Reply to this email directly, view it on GitHubhttps://github.com/meefik/linuxdeploy/issues/1360#issuecomment-1595084311, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB36AKG2MGY4CIAZ6QDU4WTXLSOVNANCNFSM6AAAAAAYK7GWAY. You are receiving this because you commented.Message ID: @.***>

qianbinbin avatar Jun 16 '23 18:06 qianbinbin

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

jaum20 avatar Jun 16 '23 19:06 jaum20

  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?

qianbinbin avatar Jun 17 '23 03:06 qianbinbin

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?

jaum20 avatar Jun 18 '23 17:06 jaum20

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.

qianbinbin avatar Jun 18 '23 18:06 qianbinbin

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

jaum20 avatar Jun 21 '23 19:06 jaum20

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.

qianbinbin avatar Jun 22 '23 06:06 qianbinbin