FAT32 : Amovible supports

Hi
Newbies with freebsd 12. I've installed it on a DELL Latitude E6410.
But I've got problem to access to the amovible supports as usb keys
I've installed xorg and xfce4, but seems have a problem with the usb keys
If I insert a key, a icon appears on the xfce desktop. I can do a left click with the mouse and choose "mount", but If I do "open", a little wheel turn and turn but nothing... As weel, the menu displays always MOUNT and never UMOUNT ...

My configuration

I've installed theses packages
Code:
pkg install automount fusefs-ntfs fusefs-simple-mtpfs

The modules are loaded

Code:
$ kldstat
Id Refs Address                Size Name
1   53 0xffffffff80200000  243cd00 kernel
2    1 0xffffffff8263d000     c7e0 aesni.ko
3    1 0xffffffff82821000   12d290 i915kms.ko
4    1 0xffffffff8294f000    858b0 drm.ko
5    4 0xffffffff829d5000    104f0 linuxkpi.ko
6    3 0xffffffff829e6000    13f30 linuxkpi_gplv2.ko
7    2 0xffffffff829fa000      6c0 debugfs.ko
8    1 0xffffffff829fb000     9c08 fuse.ko
9    1 0xffffffff82a05000    16a78 ext2fs.ko
10    1 0xffffffff82a1c000     1800 uhid.ko
11    1 0xffffffff82a1e000     23a8 ums.ko
12    1 0xffffffff82a21000      fe0 cpuctl.ko
13    1 0xffffffff82a22000    39960 linux.ko
14    2 0xffffffff82a5c000     2e28 linux_common.ko
15    1 0xffffffff82a5f000    33c50 linux64.ko
16    1 0xffffffff82a93000      acf mac_ntpd.ko
17    1 0xffffffff82a94000     1a20 fdescfs.ko

Code:
$ cat /usr/local/etc/automount.conf
MNTPREFIX="/media"
USERUMOUNT=YES
ATIME=NO
REMOVEDIRS=YES
FM="thunar"
USER=ragnarok
ENCODING=fr_FR.UTF-8
CODEPAGE=cp858

Code:
$ groups
ragnarok wheel tty operator video dialer


Code:
$ cat /etc/sysctl.conf
# $FreeBSD: releng/12.0/sbin/sysctl/sysctl.conf 337624 2018-08-11 13:28:03Z brd $
#
#  This file is read when going to multi-user and its contents piped thru
#  ``sysctl'' to adjust kernel values.  ``man 5 sysctl.conf'' for details.
#

# Uncomment this to prevent users from seeing information about processes that
# are being run under another UID.
#security.bsd.see_other_uids=0
vfs.usermount=1


Code:
$ cat /etc/devfs.rules
[localrules=5]
add path 'da*'       mode 0660 group operator
add path 'cd*'       mode 0660 group operator
add path 'uscanner*'    mode 0660 group operator
add path 'xpt*'     mode 660 group operator
add path 'pass*'    mode 660 group operator
add path 'md*'         mode 0660 group operator
add path 'msdosfs/*'     mode 0660 group operator
add path 'ext2fs/*'     mode 0660 group operator
add path 'ntfs/*'     mode 0660 group operator
add path 'usb/*'     mode 0660 group operator


Code:
$ sudo devfs rule show
Mot de passe :
100 path da* group operator mode 660
200 path cd* group operator mode 660
300 path uscanner* group operator mode 660
400 path xpt* group operator mode 660
500 path pass* group operator mode 660
600 path md* group operator mode 660
700 path msdosfs/* group operator mode 660
800 path ext2fs/* group operator mode 660
900 path ntfs/* group operator mode 660
1000 path usb/* group operator mode 660

Code:
$ sudo dmesg
ugen1.5: <Verbatim STORE N GO> at usbus1
umass0 on uhub2
umass0: <Verbatim STORE N GO, class 0/0, rev 2.10/2.00, addr 5> on usbus1
umass0:  SCSI over Bulk-Only; quirks = 0xc100
umass0:5:0: Attached to scbus5
(probe0:umass-sim0:0:0:0): REPORT LUNS. CDB: a0 00 00 00 00 00 00 00 00 10 00 00
(probe0:umass-sim0:0:0:0): CAM status: SCSI Status Error
(probe0:umass-sim0:0:0:0): SCSI status: Check Condition
(probe0:umass-sim0:0:0:0): SCSI sense: ILLEGAL REQUEST asc:20,0 (Invalid command operation code)
(probe0:umass-sim0:0:0:0): Error 22, Unretryable error
da0 at umass-sim0 bus 0 scbus5 target 0 lun 0
da0: <Verbatim STORE N GO 1.00> Removable Direct Access SPC-4 SCSI device
da0: 40.000MB/s transfers
da0: 7500MB (15360000 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>
 
I forgotten this, sorry
Code:
 sudo cat /var/log/automount.log 
2019-02-12 13:41:42 /dev/da0: random wait for '1.4' seconds before 'attach' action
2019-02-12 13:41:42 /dev/da0: attach
2019-02-12 13:41:42 /dev/da0: filesystem not supported or no filesystem
2019-02-12 13:41:43 /dev/da0s1: random wait for '1.2' seconds before 'attach' action
2019-02-12 13:41:43 /dev/da0s1: attach
2019-02-12 13:41:45 /dev/da0s1: fsck_msdosfs ** /dev/da0s1
2019-02-12 13:41:45 /dev/da0s1: fsck_msdosfs ** Phase 1 - Read and Compare FATs
2019-02-12 13:41:45 /dev/da0s1: fsck_msdosfs ** Phase 2 - Check Cluster Chains
2019-02-12 13:41:45 /dev/da0s1: fsck_msdosfs ** Phase 3 - Checking Directories
2019-02-12 13:41:45 /dev/da0s1: fsck_msdosfs ** Phase 4 - Checking for Lost Files
2019-02-12 13:41:45 /dev/da0s1: fsck_msdosfs 13 files, 2066132 free (516533 clusters)
2019-02-12 13:41:45 /dev/da0s1: mount (fat)
2019-02-12 13:41:45 /dev/da0s1: duplicated '/var/run/automount.state'*
 
OK I've changed the title of this thread
All works fine with ntfs and ext file system format but the problem is for the fat32 format.
In the doc, I saw I need this package fusefs-exfat but seems not available in pkg.

Is there an way to use fat32 on freebsd 12 ?
 
Thx but if I use a command
Code:
mount -t msdosfs /dev/ada0sN    /mnt
The usk key is well mounted on /mnt and I can list the files of the key.
The groups attached are root and wheel
My user is in the wheel group
But I've got a problem of right , I can't have a right to write (wheel : r-x)
How to fix the right problem so ?
 
Just see that fusefs-exfat no present in the precompiled packages but available in the ports. I'll try with it.
Thanx ;)
 
The groups attached are root and wheel
My user is in the wheel group
But I've got a problem of right , I can't have a right to write (wheel : r-x)
How to fix the right problem so ?
Code:
     -u uid  Set the owner of the files in the file system to uid.  The
             default owner is the owner of the directory on which the file
             system is being mounted.

     -g gid  Set the group of the files in the file system to gid.  The
             default group is the group of the directory on which the file
             system is being mounted.
mount_msdosfs(8)
 
sysutils/automount version 1.5.8 has been out of date in the package repository, since FreeBSD 12.0. Vermaden posted something a little while back, about having delays in getting his upgrades into the FreeBSD repositories, saying we need version 1.6.0 or better for FreeBSD 12.0, and recommended using this Github link to install the upgrade manually.

I tried version 1.6.0 with Plasma5-plasma and LXDE and it worked okay for me, whereas the older version 1.5.8 we get using pkg install automount worked okay with FreeBSD 11.2, but didn't work with FreeBSD 12.0. Haven't tried version 1.6.1 yet, since I'm now using BSDISKS option in Plasma5-plasma for auto-mounting, but would assume that it works, and would try it if I still needed it.

Edited to add: vermaden's sysutils/automount is not the same thing as the base system's automount command, which uses autofs for auto-mounting. The automount entry and related entries in the FreeBSD manual apply only to the base system's automount, and have nothing to do with vermaden's automount port, which doesn't require any changes to devfs, sysctl.conf, etc.
 
Hello
Thanks for your answers
OK I know what's UID and GID ;) (I used Linux Debian since many years and I just like to change of SE and try FreesBSD to try and learn another things)
So with the good option of the mask of mount_msdos works so fine. Thx Thanks a lot, alright, I would have to read the RTFM, sorry.

And now, I found why it doesn't work : I don't have launch automatically the dsbmc-client of the startup of the X session

And I've compiled too the fusefs-expat from the ports.

Big thanks, it's solved
 
HI
So after several tests, the dsbmc-client method works relatively well but I've got problems to halt the system (long time to wait)... And use sometimes many resources of the CPU
Finally the automount version on the Vermaden gith works very well. I keep it. https://github.com/vermaden/automount
 
I am afraid there is a little misunderstanding that hasen't been fixed yet

syustils/fusefs-exfat is for EXFAT not FAT32. ExtFat is a 64 bit evolution of FAT32 handling big file size (> 4 GB the current limitation of FAT32, supporting UTF8 etc etc). At this moment this format is protected by Microsoft Intellectual Property, so you won't find a native support, for this reason there is only a FUSEFS alternative.

FAT32 is now in public domain and is supported NATIVELY (no need to use port, you won't find anything) by almost all systems
You mount FAT32 with the internal command mount_msdosfs

Personal advice : for automount operations, setup autofs. This is in base system, and the default script (see the extension "special_media") supports by default FAT32. To make autofs support exfat, ext3, ext4, xfs, btfrs .... this can be done easily

In /etc/autofs I have reworked the default special_media script, back it up in /etc/autofs/special_newmedia

Code:
#!/bin/sh
###############################################################################
#                                                                             #
#                   FreeBSD 12.0 : Mobile Filesystem Autofs Plug              #
#                                  -=== x ===-                  #
#                                                                             #
#                           In<= /etc/autofs                                  #
#                           Owner=    0:0                      #
#                           Rights=    755                      #
#                           Profile=    Parameters/FreeBSD/AUTOFS             #
#                                                                             #
###############################################################################
#
# special reworked media plug
#

# Print newline-separated list of devices available for mounting.
# If there is a filesystem label - use it, otherwise use device name.
print_available() {
    local _fstype _fstype_and_label _label _p

    for _p in ${providers}; do
        _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
        if [ $? -ne 0 ]; then
            # Ignore devices for which we were unable
            # to determine filesystem type.
            continue
        fi

        _fstype="${_fstype_and_label%% *}"
        if [ "${_fstype}" != "${_fstype_and_label}" ]; then
            _label="${_fstype_and_label#* }"
            # Replace plus signs and slashes with minuses;
            # leading plus signs have special meaning in maps,
            # and multi-component keys are just not supported.
            _label="$(echo ${_label} | sed 's,[+/],-,g')"
            echo "${_label}"
            continue
        fi
        echo "${_p}"
    done
}

# Print a single map entry.
print_map_entry() {
    local _fstype _p ext2fs_flag e2fsprog_flag

    _fstype="$1"
    _p="$2"

    ext2fs_flag=$(kldstat | grep ext2fs.ko)
    [ -z "$ext2fs_flag" ] && ext2fs_flag=0
    [ -n "$ext2fs_flag" ] && ext2fs_flag=1
  
    e2fsprogs_flag=1
    [ ! -f /usr/local/sbin/blkid ] && e2fsprogs_flag=0
    [ ! -f /usr/local/sbin/tune2fs ] && e2fsprogs_flag=0

    case "${_fstype}" in
    "exfat")
        if [ -f "/usr/local/sbin/mount.exfat" ]; then
            echo "-mountprog=/usr/local/sbin/mount.exfat,fstype=${_fstype},nosuid    :/dev/${_p}"
        else
            /usr/bin/logger -p info -t "special_newmedia[$$]" \
            "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-exfat first"
            exit 1
        fi
        ;;
    "ntfs")
        if [ -f "/usr/local/bin/ntfs-3g" ]; then
            echo "-mountprog=/usr/local/bin/ntfs-3g,fstype=${_fstype},ro,nosuid    :/dev/${_p}"
        else
            /usr/bin/logger -p info -t "special_newmedia[$$]" \
                "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-ntfs first"
            exit 1
        fi
        ;;

    "hfs")
        if [ -f "/usr/local/bin/hfsfuse" ]; then
            echo "-mountprog=/usr/local/bin/hfsfuse,fstype=${_fstype}    :/dev/${_p}"
        else
            /usr/bin/logger -p info -t "special_newmedia[$$]" \
            "Cannot mount ${_fstype} formatted device /dev/${_p}: Install sysutils/fusefs-hfsfuse first"
            exit 1
        fi
        ;;

    "msdosfs")
        echo "-fstype=${_fstype},nosuid,async    :/dev/${_p}"
        ;;

    "ufs")
        echo "-fstype=${_fstype},nosuid    :/dev/${_p}"
        ;;

        *)
          
        if [ "$_fstype" = "ext2fs" -a $e2fsprogs_flag -eq 0 -a $ext2fs_flag -eq 1 ]; then

#         Use FreeBSD mounter with ext2fs Kernel module in read only mode
#               as base system is unable to identify ext subtype and journaling
#     
        echo "-fstype=${_fstype},nosuid,ro,async    :/dev/${_p}"

        fi

#               Use blkid to identify ext subtype
#               Use tune2fs to identify journal and void writting  
#        Use e2fsck to replay and clean journal for ext2/ext3/ext4

        if [ $e2fsprogs_flag -eq 1 ]; then

        RWO="rw"
        LinuxType=$(/usr/local/sbin/blkid /dev/"$_p" | cut -w -f4 | cut -d"=" -f2 | cut -d\" -f2)
        [ "$LinuxType" = "ext2" -o "$LinuxType" = "ext3" -o "$LinuxType" = "ext4" ] && /usr/local/sbin/e2fsck /dev/"$_p"
  
        Journal_flag=$(/usr/local/sbin/tune2fs -l /dev/"$_p" | grep "Filesystem features" | grep "has_journal")
  
        if [ -z "$Journal_flag" ]; then
  
        Journal_flag=0
  
        else
  
        Journal_flag=1

        fi

        [ $Journal_flag -eq 1 ] && RWO="ro"  
  
            case "$LinuxType" in

            "ext2")

                if [ $ext2fs_flag -eq 1 ]; then

#                 Use FreeBSD mounter with ext2fs Kernel module in read and write mode
                echo "-fstype=${_fstype},$RWO,nosuid,async    :/dev/${_p}"

                elif [ -f "/usr/local/bin/lklfuse" ]; then

#                Revert to fuse LKL in Read/Write mode
                echo "-mountprog=/usr/local/bin/lklfuse,fstype=${_fstype},type=$LinuxType,$RWO    :/dev/${_p}"

                 elif [ -f "/usr/local/bin/fuse-ext2" ]; then
#                Revert to fuse-ext2 (specify rw+ for read and write)
                [ "$RWO" = "rw" ] && RWO="rw+"
                echo "-mountprog=/usr/local/bin/fuse-ext2,fstype=${_fstype},$RWO    :/dev/${_p}"
          
                else
          
                /usr/bin/logger -p info -t "special_newmedia[$$]" \
                "Cannot mount ext2 formatted device /dev/${_p}: Kernel load ext2fs or Install sysutils/fusefs-ext2, sysutils/fusefs-lkl"
                exit 1

                fi
                ;;

        "ext3" | "ext4")
          
                if [ $ext2fs_flag -eq 1 ]; then

#                 Use FreeBSD mounter with ext2fs Kernel module in read only mode
                echo "-fstype=${_fstype},$RWO,nosuid,async    :/dev/${_p}"

                elif [ -f "/usr/local/bin/lklfuse" ]; then

#                Revert to Fuse LKL in readonly mode if journaling
                echo "-mountprog=/usr/local/bin/lklfuse,fstype=${_fstype},type=$LinuxType,$RWO    :/dev/${_p}"

                 elif [ -f "/usr/local/bin/fuse-ext2" ]; then

#                Revert to fuse-ext2 (read only)
#                               Ext3/Ext4 writting mode are experimental

                [ "$RWO" = "rw" ] && RWO="rw+"
                echo "-mountprog=/usr/local/bin/fuse-ext2,fstype=${_fstype},ro    :/dev/${_p}"

                 elif [ -f "/usr/local/bin/ext4fuse" -a "$LinuxType" = "ext4" ]; then

#                Revert to fuse-ext4fuse (read only, no write capability)
                echo "-mountprog=/usr/local/bin/ext4fuse,fstype=${_fstype},ro    :/dev/${_p}"


                else

                /usr/bin/logger -p info -t "special_newmedia[$$]" \
                "Cannot mount ${_LinuxType} formatted device /dev/${_p}: Install sysutils/fusefs-ext2 or sysutils/fusefs-lkl first"
                exit 1

                fi
                ;;

        "xfs" | "btrfs")

                if [ -f "/usr/local/bin/lklfuse" ]; then

                echo "-mountprog=/usr/local/bin/lklfuse,fstype=${_fstype},type="$LinuxType",ro    :/dev/${_p}"

                else

                /usr/bin/logger -p info -t "special_newmedia[$$]" \
                "Cannot mount ${_LinuxType} formatted device /dev/${_p}: Install sysutils/fusefs-lkl first"
                exit 1

                fi
                ;;
            esac
        else

#            Exit per default when file system is unknown

            /usr/bin/logger -p info -t "special_newmedia[$$]" \
            "Cannot mount ${_fstype} formatted device /dev/${_p}: unknown filesystem"
            exit 1
  
        fi
        ;;

    esac

}

# Determine map entry contents for the given key and print out the entry.
print_one() {
    local _fstype _fstype_and_label _label _key _p

    _key="$1"

    _fstype="$(fstyp "/dev/${_key}" 2> /dev/null)"
    if [ $? -eq 0 ]; then
        print_map_entry "${_fstype}" "${_key}"
        return
    fi

    for _p in ${providers}; do

        _fstype_and_label="$(fstyp -l "/dev/${_p}" 2> /dev/null)"
        if [ $? -ne 0 ]; then
            # Ignore devices for which we were unable
            # to determine filesystem type.
            continue
        fi

        _fstype="${_fstype_and_label%% *}"
        if [ "${_fstype}" = "${_fstype_and_label}" ]; then
            # No label, try another device.
            continue
        fi

        _label="${_fstype_and_label#* }"
        # Replace plus signs and slashes with minuses;
        # leading plus signs have special meaning in maps,
        # and multi-component keys are just not supported.
        _label="$(echo ${_label} | sed 's,[+/],-,g')"
        if [ "${_label}" != "${_key}" ]; then
            # Labels don't match, try another device.
            continue
        fi

        print_map_entry "${_fstype}" "${_p}"
    done

    # No matching device - don't print anything, autofs will handle it.
}

# Obtain a list of (geom-provider-name, access-count) pairs, turning this:
#
# z0xfffff80005085d00 [shape=hexagon,label="ada0\nr2w2e3\nerr#0\nsector=512\nstripe=0"];
#
# Into this:
#
# ada0 r2w2e3
#
# XXX: It would be easier to use kern.geom.conftxt instead, but it lacks
#      access counts.
pairs=$(sysctl kern.geom.confdot | sed -n 's/^.*hexagon,label="\([^\]*\)\\n\([^\]*\).*/\1 \2/p')

# Obtain a list of GEOM providers that are not already open - not mounted,
# and without other GEOM class, such as gpart, attached.  In other words,
# grep for "r0w0e0".  Skip providers with names containing slashes; we're
# not interested in geom_label(4) creations.
providers=$(echo "$pairs" | awk '$2 == "r0w0e0" && $1 !~ /\// { print $1 }')

if [ $# -eq 0 ]; then
    print_available
    exit 0
fi

print_one "$1"
exit 0


In /etc/auto_master, instead of activating the default script media, I activate my script newmedia

Code:
# Automount NFS share
/mnt/autofs/net-nfs        -hosts        -nobrowse,nosuid,intr

# Automount SMBFS share
/mnt/autofs/net-cifs        -cifs2        --timeout=300,--ghost,--soft

# Automount Media devices
# When using the -media special map, make sure to edit devd.conf(5)
# to move the call to "automount -c" out of the comments section
/mnt/autofs/media        -newmedia        -nosuid,noatime

# Mount filesystems in fstab marked as noauto
#/-        -noauto

/mnt/autofs/mtp            -simple-mtpfs    -allow_other


Now, install :

sysutils/fusefs-exfat
sysutils/fusefs-lkl
sysutils/fusefs-ntfs
sysutils/fusefs-hfsfuse
sysutils/fusefs-ntfs-compression
sysutils/e2fsprogs

Note : Linux e2fsprogs package
  • blkid binary is used to identify some subtypes of OS that FreeBSD internal command fstyp is unable to do
  • e2fsck binary is used to recheck ext3/ext4 before mounting. FreeBSD kernel module ext2fs often fails to mount ext3/ext4 because it is unable to replay the journal and to reflag the filesystem as clean.
  • tune2fs binary is used to grab info on ext filesystem activated options. It identifies if journalisation is active on ext3/ext4 media
In any case, sysutils/fusefs-lkl requires sysutils/e2fsprogs as a dependency

So this automount script support : FAT32, extfat, ufs, ext2, ext3, ext4, hfs, xfs, btrfs, ntfs

How to start autofs :

Activate rcd scripts in rc.conf (see /etc/defaults/rc.conf to get info) to autostart services at boot
or by hand

service automountd onestart
service autounmoutd onestart
service automount onestart

and matching devices will appear in /mnt/autofs/media

Read the script newmedia and change it according to your use.

For example :
  • by default, script mount NTFS in read only mode, but you can modify the behaviour if you want
  • By default, the script will attempt to use FreeBSD kernel module (as ext2fs), and will revert to fusefs modules.
If it detects an ext3/ext4 drive without journal, the script uses ext2fs kernel module to mount it in RW mode.
If package fusefs-lkl is not detected, the script will mount any ext3/ext4 with journalised filesystem in Read Only mode via ext2fs
Ext3/ext4 with journal will be only mounted in Read/Write mode with fusefs-lkl if package is detected

etc etc... modifying the script, anyone can adapt the strategy as he wants
 
Last edited:
Back
Top