RSS Amplifier

lukasz.bromirski.net · Jul 30, 2025

SMB and Other Remote Filesystems

0
Sign in to vote or save

Łukasz Bromirski · lukasz.bromirski.net

when working with FreeBSD daily, the ability to mount remote filesystems is super handy. if you’re into NFS, this post isn’t for you — in this post I’m more interested in SMB (CIFS) and SSH (yep, really!).

to use these protocols, you can either go with dedicated tools or take advantage of the nice abstraction layer provided by FuseFS — including its dedicated kernel module available on FreeBSD.

FuseFS

To access a CIFS-shared filesystem from FreeBSD, you used to rely on the Samba package. Unfortunately, things have moved on, and our trusty old mount_smbfs hasn’t kept up:

STANDARDS
     mount_smbfs offers support for SMB/CIFS/SMB1.  It does not support newer
     versions of the protocol like SMB2 and SMB3.  SMB2 and SMB3 are supported
     by software available in the ports(7) collection.

     The list of supported SMB servers includes:
     -   Samba
     -   Windows 95/98/ME/2000/NT4.0 (SPs 4, 5, 6)
     -   IBM LanManager
     -   NetApp

so, per the recommendation, let’s pick the right FuseFS module from the vast collection:

fusefs-afuse-0.5.0             File system automounting implemented in user-space using FUSE
fusefs-befuse-1.2              Read/Write FUSE server for BeFS
fusefs-bindfs-1.17.7_2         FUSE based bindfs implementation way more powerful than nullfs
fusefs-chironfs-1.1.1_3        FUSE based filesystem with replication at the filesystem level
fusefs-cryptofs-0.6.0_7        Encrypted filesystem for FUSE
fusefs-curlftpfs-0.9.2_8       Mount remote FTP directories
fusefs-davfs2-1.7.1            FUSE filesystem to access WebDAV servers
fusefs-encfs-1.9.5_11          Encrypted pass-through FUSE filesystem
fusefs-exfat-1.4.0_1           Full-featured exFAT FS implementation as a FUSE module
fusefs-ext2-0.0.11_2           FUSE module to mount ext2, ext3 and ext4 with read write support
fusefs-gphotofs-0.5.20181029   Mount PTP camera as a file system
fusefs-hfsfuse-0.242           FUSE driver for HFS+ filesystems
fusefs-httpdirfs-1.2.7_2       FUSE filesystem to mount HTTP directory listings, with a permanent cache
fusefs-ifuse-1.1.4_2           FUSE-based filesystem for mounting iOS devices over USB
fusefs-jmtpfs-g20190420        MTP device filesystem
fusefs-libs-2.9.9_2            FUSE allows filesystem implementation in userspace
fusefs-libs3-3.17.1_1          FUSE library version 3 for filesystems implemented in userspace
fusefs-lkl-4.16.g20180628_4    Full-featured Linux BTRFS, Ext4, XFS as a FUSE module
fusefs-mergerfs-2.40.2         Featureful FUSE based union filesystem
fusefs-mhddfs-0.1.37_1         Multi HDD [FUSE] File System
fusefs-mp3fs-1.1.1_1,1         FUSE-based filesystem for transcoding FLAC to MP3 on the fly
fusefs-nbt-20250506            Editing Named Binary Tag (NBT) as using a file system
fusefs-ntfs-2022.10.3_1        Mount NTFS partitions (read/write) and disk images
fusefs-ntfs-compression-1.0    NTFS-3G plugin for reading XPRESS or LZX compressed files
fusefs-pod-0.5.2_16            FUSE-based filesystem for iPod
fusefs-rar2fs-1.29.7_4         Mount RAR archives as file system
fusefs-s3backer-1.5.4_1        FUSE filesystem that uses Amazon S3 as a backing store
fusefs-s3fs-1.95               FUSE-based file system backed by Amazon S3
fusefs-sandboxfs-0.2.0_48      Virtual file system for sandboxing
fusefs-securefs-1.1.1          Filesystem in userspace with transparent encryption and decryption
fusefs-simple-mtpfs-0.4.0_1    Simple MTP fuse filesystem driver
fusefs-smbnetfs-0.6.3_1        Mount smb shares (Fuse filesystem)
fusefs-squashfuse-0.5.2_2      Mount a squashfs archive and treat it like a local file system
fusefs-sshfs-3.7.3_3           Mount remote directories over ssh
fusefs-ufs-0.5.0_1             FUSE driver for FreeBSD's UFSv2
fusefs-unionfs-2.2_1           FUSE based implementation of the well-known unionfs
fusefs-unreliablefs-0.2.0      FUSE-based fault injection filesystem
fusefs-webdavfs-g20200520_27   FUSE filesystem for WEBDAV shares
fusefs-xfuse-0.4.4_9           Read-only FUSE server implementing XFS

…and install it:

admin@system:/home/admin $ sudo pkg install fusefs-smbnetfs-0.6.3_1

The following 61 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        avahi-app: 0.8_6
        cyrus-sasl: 2.1.28_5
        dbus: 1.16.2_3,1
        dbus-glib: 0.114
        fusefs-libs: 2.9.9_2
        fusefs-smbnetfs: 0.6.3_1
        gamin: 0.1.10_10
        gmp: 6.3.0
        gnome_subr: 1.0
        gnutls: 3.8.9
        [...]

next, load the kernel module and (potentially) allow regular users to mount filesystems:

admin@system:/home/admin # kldload fusefs
admin@system:/home/admin # kldstat | egrep "Name|fuse"
Id Refs Address                Size Name
13    1 0xffffffff8263a000    12dc8 fusefs.ko

admin@system:/home/admin # sysctl vfs.usermount=1
vfs.usermount: 0 -> 1

now we can mount a wide variety of filesystems. let’s start with one of the more annoying (yet popular) ones:

SMB — or rather, CIFS.

Server Message Block (SMB), including the Common Internet File System (CIFS), is the obvious choice if you’ve got a NAS or Windows boxes on your network.

depending on the mounting tool you choose, you can authenticate either inline or via a config file. I went the lazy route and copied the sample config to my home dir:

$ mkdir ~/.smb
$ cp /usr/local/share/doc/smbnetfs-0.6.3/smbnetfs.conf ~/.smb/

storing passwords in plaintext is definitely not best practice (seriously, don’t do it!), but the daemon does at least ensure that the file permissions are tight, as you’ll see:

auth            "username" "password"

you can provide general credentials or directory-specific ones if you’re juggling multiple remote shares.

now, depending on your terminal setup, the daemon might complain about unsafe file permissions and refuse to work:

$ mkdir _zdalny_zasob
$ smbnetfs _zdalny_zasob
32039->reconfigure_read_config_file: Error: Insecure config file permission.
Can't apply 'auth' directive.
Run 'chmod 600 /home/user/.smb/smbnetfs.conf' to fix it.
mount_fusefs: /dev/fuse on /usr/home/user/_zdalny_zasob: Operation not permitted

so let’s fix the permissions as advised:

$ chmod 600 ~/.smb/smbnetfs.conf

and try again:

$ smbnetfs _zdalny_zasob

now your directory is under FuseFS’s control — just cd into the remote path:

$ cd _zdalny_zasob/nazwa_lub_IP_zdalnego_serwera/konkretny_zasob_na_tym_serwerze

you should now see the contents, like:

user@system:~/_zdalny_zasob/serwer_lukasza/fajne_pliki $ ls
01katalog            02katalog              03katalog
gry                  systemy                innefajne
muzyka               sztuka                 wideo
foto                 swiat                  wszechswiat
zobacz_to            zobacz_tamto

other tools like df should reflect the mounted filesystem properly:

$ df -gh | egrep "Filesystem|smbnetfs"
Filesystem            Size    Used   Avail Capacity  Mounted on
smbnetfs                0B      0B      0B   100%    /usr/home/user/_zdalny_zasob

SSH

now let’s take a look at another module — this time using good old SSH to map filesystems. install it like so:

$ sudo pkg install fusefs-sshfs-3.7.3_3

mount the remote dir — depending on your auth method (password vs. key), you’ll be prompted accordingly:

user@system1:~ $ mkdir _zdalny_zasob2
user@system1:~ $ sshfs user@system2.gdzies.w.swiecie.tld:/home/user/katalog_zdalny _zdalny_zasob2/
(user@system2.gdzies.w.swiecie.tld) Password for user@system2.gdzies.w.swiecie.tld: *tu_wpisalem_tajne_haslo*

once mounted, you’ll see remote files locally:

szopen@ns2:~ $ cd _zdalny_zasob2
szopen@ns2:~/_zdalny_zasob2 $ ls
fajny_plik_zdalny1.pdf                  fajny_plik_zdaln2.mp3                   jakis_nudny_log.log
wielkie_sekrety_swiata.txt              wielkie_sekrety_illuminati.docx         jakis_fajny_skrypt.sh

and just like before, you can work with those files as if they were local.

happy mounting — and may your remote shares be ever reliable! 😄

Read the original on lukasz.bromirski.net

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.