brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mount an SMB share from the Unraid terminal with a credentials file

Unraid
~/tips/tip-unraid-mount-cifs-credentials-file

username=youruser

Mounts a Windows or Linux network share on the Unraid server using a protected credentials file.

Sometimes the quickest way to get files onto Unraid is to pull them from another machine in the terminal. The Unraid docs show a way that keeps the password out of your shell history.

Run all of this as root, in the web terminal or over SSH. Start with a temporary mount point, and create /root/.cifscredentials with two lines:

username=youruser
password=yourpassword

Then lock the file down and mount the share with it:

mkdir /work
chmod 600 /root/.cifscredentials
mount -t cifs //workstation/share /work -o credentials=/root/.cifscredentials,iocharset=utf8

The docs give an interactive variant too, with username=youruser in the options, which prompts for the password. They recommend the credentials file for scripts and automation. They also warn against password=... on the command line, because arguments can end up in shell history. The iocharset=utf8 option keeps international file names intact.

Copy with progress and clean up afterwards:

rsync -av --progress /work/ /mnt/user/media/
umount /work
rmdir /work

The docs example targets /mnt/disk1. I aim at a user share instead, since the shares docs say never to copy between a user share and a disk share with the same folder name. The credentials file holds a plain text password, so keep the chmod 600 and remove the file when you are done.

Further reading: Unraid docs: command line interface, Unraid docs: shares

Going deeper: Guide: your Unraid cache is full and Docker stopped, how to find out why and fix it

More Unraid tips Change the RAID profile of a Unraid BTRFS pool with Balance Replace a disk in a redundant Unraid pool from the Main tab Test every Unraid drive with the DiskSpeed container See the XML behind a VM with the inline XML view in Unraid 7 Choose where a new VM's disk image is created with Unraid's storage override All Unraid tips (77) All topics

Link