The wiki shows how to install a Samba server on an LXC container running under the Alpine OS. In addition, external storage is set up via the USB port for the container and made available for use by the Samba client.
The wiki was tested with router software 5.0.0.101 and the LXC container with alpine armhf 3.23
Activate the LXC container on the router
In the second step the image of the LXC container in this case a alpine 3.23.
The easiest way to do this is to install the whole thing over the Internet. However, the router requires a mobile connection to the Internet.
From a Jenkins server you get the current image for the container
* Jenkins Server Page image-alpine tinycloud / Link
The “armhf” tab is important here
Here you can get a alpine image for 3.21, 3.22, 3.23 or newer.
The image is the “rootfs.tar.xz” which is required. With a right click you can copy the link.
It would be structured like this:
When the “Apply” button is pressed, Debian will be installed.
Set up the LXC container further. A network interface is enabled here.
The container has now also been assigned an IP address.
Always assign a fixed IP address for the LXC container via the DHCP server.
Log in to the LXC container and test whether it can access the Internet.
The container is installed and set up. Now you can set up further tools on the container.
Enable USB administration on the router
When the USB device is plugged in, it is mounted by the router and stored in the system as device part “/dev/sda1“.
In order to release the device in the container, I need to know what kind of device it is: “b” is a block device, major number “8” and minor number “1”.
With this information, we can adjust the LXC configuration so that we have access to the device from within the container.
This change is made directly in the router software. When updating the router software, this entry must be made again because it is not part of the official software.
lxc.cgroup.devices.allow = b 8:1 rwm lxc.mount.entry = /dev/sda1 /dev/sda1 none bind,optional,create=file
Simply add these four entries to the LXC configuration file. Please ensure that you fill them in with your own parameters. Restart the router for these changes to take effect.
Now the USB device can be connected to the container and used.
The “mkdir” command is used to set up an area in the file system for access.In the second step, change the permissions of the file.
$ mkdir -p /mnt/home/data
$ chgrp -R users /mnt/home/ $ chmod -R 770 /mnt/home/
Check whether the rights have been set.
In order to access data via a Windows system, a Samba server must now be installed and set up on the container. Several program packages are required for this.
samba-common samba samba-client cifs-utils ntfs-3g fuse-exfat
The missing functions can be installed using the command “apk add <program package>”.
The Samba configuration file now needs to be adjusted. To do this, the existing “smb.conf” file is backed up and a new one is created.
With this command, we can back up old configurations.
$ mv /etc/samba/smb.conf /etc/samba/smb.conf.backup
Now set up the Samba configuration file with new parameters.
Create a user in the LXC container, but without a home drive. In the second step, set the password in Linux.
$ adduser -G users loidl --no-create-home $ smbpasswd -a loidl
Configure the Samba server as a service in AlpineOS so that it starts automatically.
The whole thing is integrated via a cron job, so that it is always available when the router is restarted.
Queries with which file system the external storage was formatted.
First, we create a script file called “$ vi samba_release.sh”.
The entry for the vfat file system:
mknod /dev/sda1 b 8 1 mount -t vfat /dev/sda1 /mnt/home/data -o uid=1000,gid=1000,umask=000
The entry for the exfat file system:
mknod /dev/sda1 b 8 1 mount -t exfat /dev/sda1 /mnt/home/data -o uid=1000,gid=1000,umask=000
For the NTFS file system, please use this mount point.
mknod /dev/sda1 b 8 1 mount -t ntfs-3g /dev/sda1 /mnt/home/data -o uid=1000,gid=1000,umask=000
We still need to change the permissions for this file so that it is executable.
“chmod a+x samba_release.sh”
To test it, you can now simply run this file.
Now the whole thing has to be saved as a cron job. To do this, call up the command “crontab -e” and save this line there.
The crond service must still be stored as a service in alpineOS so that it can be called up.
“$ rc-update add crond”
After completing the setup, please reboot the router again so that all settings and changes are applied by the Linux system.
The device can first be tested directly under Linux to see whether access to the external memory is possible.
mount -t cifs -o user=loidl,gid=1000,uid=1000 //192.168.1.100/data /mnt/home/exchange
If you can connect to the storage device, you can then integrate it into Windows in the second step.
The IP address of the LXC container and the Samba directory are stored under the “Folder” option.
\\192.168.1.100\data
The stored Samba user was used again as the user and password.