Wiki

Samba Shares

Cách gắn Samba Shares bên trong Chroot Debian

  1. Nhập debian chroot với:
debian enter
  1. Cập nhật Debian
apt update && apt upgrade -y
  1. Cài đặt cifs-utils
apt install cifs-utils
  1. Tạo thư mục mount
mkdir -p /mnt/samba
  1. Thêm địa chỉ ip của chia sẻ samba, người dùng và mật khẩu vào /etc/fstab (thay đổi giá trị màu đỏ )
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

Bấm phím Enter

  1. Tạo tập lệnh khởi động /etc/init.d/samba-mount
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

Bấm phím Enter

  1. Đặt quyền
chmod +x /etc/init.d/samba-mount
  1. Thoát khỏi Debian
exit
  1. Thêm samba-mount vào danh sách dịch vụ chroot
echo "" >>/opt/etc/chroot-services.list
echo "samba-mount" >>/opt/etc/chroot-services.list
chmod 755 /opt/etc/chroot-services.list

Nhấn ENTER

  1. Khởi động lại Debian
debian restart

Bây giờ thư mục dùng chung của bạn sẽ được gắn trong /mnt/samba bên trong debian, xác minh bằng

ls /opt/debian/mnt/samba

Nên xem danh sách tệp và thư mục :). Thưởng thức...