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...

  • Toufiq Ibna Mustafiz

    thanks for caring us :D

SUBSCRIBE

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