How to Mount Samba Shares inside Chrooted Debian

This tutorial is only for arm routers like RT-AC56U, RT-AC68U, RT-AC87U, RT-AC3200, RT-AC5300...
Usefull for PlexMediaServer, MiniDlna, Transmission...

 

1 - Setup Debian Jessie from here

2 - Enter chrooted debian with:

debian enter

3 - Update Debian

apt update && apt upgrade -y

4 - Install cifs-utils

apt install cifs-utils

- Create mount directory

mkdir -p /mnt/samba

- Add ip address of samba share, user and password to /etc/fstab (change values in red)

cat >> /etc/fstab << 'EOF'
//192.168.1.100/shared_folder /mnt/samba cifs user=share_username,password=share_password,uid=1000,umask=000 0 0
EOF

Press ENTER

- Create /etc/init.d/samba-mount startup script

cat >> /etc/init.d/samba-mount << 'EOF'
#! /bin/sh
### BEGIN INIT INFO
# Provides: mount
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 6
# Short-Description: Mount Samba Shares
# Description:
# Author: TeHashX / contact@hqt.ro
# Version: 1.1
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/lsb/init-functions
do_stop () {
log_action_msg "Umounting shares"
umount -a
}
case "$1" in
start)
log_action_msg "Mounting shares"
mount -a
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
do_stop
;;
status)
exit 0
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
EOF

Press ENTER

- Set permissions

chmod +x /etc/init.d/samba-mount

- Exit Debian

exit

10 - Add samba-mount to chrooted services list

echo "" >>/opt/etc/chroot-services.list
echo "samba-mount" >>/opt/etc/chroot-services.list
chmod 755 /opt/etc/chroot-services.list

Press ENTER
11 - Restart Debian

debian restart

Now your shared folder should be mounted under /mnt/samba inside debian, verify with

ls /opt/debian/mnt/samba

Should see files and directories list :)

Enjoy...

  • Василий Нуштакин

    after #debian restart

    Stopping chroot'ed Debian services...
    /etc/init.d/samba-mount: 19: /etc/init.d/samba-mount: Syntax error: ")" unexpected (expecting "}")
    umount: can't unmount /tmp/mnt/FLASH/entware-ng.arm/debian/dev/pts: No such file or directory
    Restarting chroot'ed Debian services...
    /etc/init.d/samba-mount: 19: /etc/init.d/samba-mount: Syntax error: ")" unexpected (expecting "}")
    Done.

    How to fixit?

    • You done something wrong to /etc/init.d/samba-mount
      Enter Debian
      Delete /etc/init.d/samba-mount file
      Try again step 7

  • Toufiq Ibna Mustafiz

    thanks for caring us :D

Get Email Notification When a Server or Port is Unreachable
SoftEther VPN Running on AsusWRT Routers
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Minidlna UPnP Media Server through Debian Jessie Arm
How to Mount Samba Shares inside Chrooted Debian
Spreed WebRTC server and web client
Asterisk VoIP Server running on AsusWRT Routers
Get Email Notification When a Server or Port is Unreachable
SoftEther VPN Running on AsusWRT Routers
NZBGet through Entware
Minidlna UPnP Media Server through Debian Jessie Arm

SUBSCRIBE

To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...