Relax default permissions on the device filesystem to allow normal users access to a variety of disks and input/output devices.
- Permissions for devices existing at boot time are set in
devfs.conf. - Each line defines a full device path and octal permission value.
- To see the devices:
and also
less /var/run/dmesg.bootls /dev - For device name look at Table 3.3
- Below shows the
vi /etc/devfs.conffile allowing access to various disks and input/output devices.
# Allow all users to access optical media
perm /dev/acd0 0666
#perm /dev/acd1 0666
perm /dev/cd0 0666
#perm /dev/cd1 0666
# Allow all two USB Devices to be mounted
perm /dev/da0 0666
perm /dev/da1 0666
# Misc other devices
perm /dev/pass0 0666 # not sure
perm /dev/xpt0 0666 # not sure
perm /dev/uscanner0 0666
perm /dev/video0 0666 # permission for webcam
#perm /dev/tuner0 0666 # permission for capturing using tuner as source
#perm /dev/dvb/adapter0/demux0 0666 # permission for demultiplexer for the tuner
#perm /dev/dvb/adapter0/dvr 0666 # part of tuner setup
#perm /dev/dvb/adapter0/frontend0 0666 # part of tuner setup
Note:
perm /dev/uscanner0 0666- Permission for USB scanners.
perm /dev/tuner0 0666- Permission for TV tunners.
perm /dev/dvb/adapter0/demux0 0666perm /dev/pass0 0666perm /dev/xpt0 0666
- For devices that may be connected post-boot, we add an entry to a
devfs.rulesruleset. Rulesets must have a unique name and number, and their rules are composed of a path or quoted path glob and octal permission value.
2.1. Below shows the vi /etc/devfs.rules
[devfsrules_common=7]
add path 'ad[0-9]\*' mode 0660 group operator
add path 'ada[0-9]\*' mode 0660 group operator
add path 'da[0-9]\*' mode 0660 group operator
add path 'acd[0-9]\*' mode 0660 group operator
add path 'cd[0-9]\*' mode 0660 group operator
add path 'mmcsd[0-9]\*' mode 0660 group operator
add path 'pass[0-9]\*' mode 0660 group operator
add path 'xpt[0-9]\*' mode 0660 group operator
add path 'ugen[0-9]\*' mode 0660 group operator # generic usb support
add path 'usbctl' mode 0660 group operator
add path 'usb/\*' mode 0660 group operator
add path 'lpt[0-9]\*' mode 0660 group operator # generic printer device driver
add path 'ulpt[0-9]\*' mode 0660 group operator # USB printer support
add path 'unlpt[0-9]\*' mode 0660 group operator # in case of problems with ulpt
add path 'fd[0-9]\*' mode 0660 group operator # file descriptor files accessible through the file system
add path 'uscan[0-9]\*' mode 0660 group operator # scan upstream sources for new released of software
add path 'video[0-9]\*' mode 0660 group operator
#add path 'tuner[0-9]*' mode 0660 group operator
#add path 'dvb/\*' mode 0660 group operator # for Digital TV (DVB, ATSC)
#add path 'cx88*' mode 0660 group operator # video capture driver
#add path 'cx23885*' mode 0660 # CX23885-family stream configuration device
#add path 'iicdev*' mode 0660 group operator # for inter IC devices
#add path 'uvisor[0-9]*' mode 0660 group operator # USB support for the PalmOS based PDAs
Note:
add path 'ugen[0-9]\*' mode 0660 group operator- Permission rule for generic usb support
add path 'lpt[0-9]\*' mode 0660 group operator- Permission rule for generic printer device driver
add path 'ulpt[0-9]\*' mode 0660 group operator- Permission rule for usb printer support
add path 'fd[0-9]\*' mode 0660 group operator- File descriptor files which can be accessed through the file system.
add path 'uscan[0-9]\*' mode 0660 group operatoradd path 'cx88*' mode 0660 group operator- Video capture driver also see.
add path 'cx23885*' mode 0660- CX23885-family stream configuration device
- cx23885 webcamd driver for TV tuner boards.
add path 'iicdev*' mode 0660 group operator- Permission rule for inter IC devices.
- Also see this and this.
add path 'uvisor[0-9]*' mode 0660 group operator- USB support for the PalmOS based PDAs
- Also see this.
2.2. Enable the ruleset in vi /etc/rc.conf
devfs_system_ruleset="devfsrules_common"
The procfs and
fdescfs
virtual filesystems are not a default part of BSD
but they are frequently required for compatibility with programs and environments
written with Linux in mind, such as GNOME/MATE and KDE.
The FreeBSD equivalent is sysctl, but you can mount /proc too if you plan to use software requiring it.
Some special filesystems like fdescfs must be mounted late on ZFS-rooted systems because
the location of their mountpoint won't exist until late in the boot process.
vi /etc/fstabfile will set theprocfsandfdescfsfilesystem.
proc /proc procfs rw 0 0
fdesc /dev/fd fdescfs rw,auto,late 0 0
Note:
fstab(/etc/fstab) is of the format:
device /mount-point fstype options dumpfreq passno
- If you neglected to add your personal user account to the
wheelandoperatorgroups during installation, now is a good time to do so. In this example my user is joe.
- If it not done already done assigning
wheelmembership lets you usesuto becomeroot
pw usermod joe -G wheel
- If the
operatormembership is required for device permissions in this configuration do
pw usermod joe -G operator
- Confirm that the username (here, joe) is in both
wheelandoperatorgroups.
Contents of the cat /etc/group will be of the format |
This should be corrected to |
|---|---|
wheel:*:root |
wheel:*:root,joe |
... |
... |
operator:*:5:root |
operator:*:5:root,joe |
... |
... |
- Ensure that
operatoris able to read and write the device by writing the ruleset below for device configuration
- write the ruleset below in
vi /etc/devfs.rules
[localrules=5]
add path 'da*' mode 0660 group operator
-
Why
dafor usb? Look at Table 3.3 for device name. -
enable the ruleset in
vi /etc/rc.conf
devfs_system_ruleset="localrules"
- let users mount the disk by enabling it in
vi /etc/sysctl.conf
vfs.usermount=1
less /var/run/dmesg.boot
Here it was identified as ada0
- Wipe the HDD clean
gpart destroy –F ada0
- Create the GPT partition scheme and then add a single partition.
gpart create -s GPT ada0
- To improve performance on newer disks with larger hardware block sizes, the partition is aligned to one megabyte boundaries.
gpart add -t freebsd-ufs -a 1M ada0
- See disk partition information.
gpart show ada0
- Create file system in the new partition on the new disk.
newfs –U /dev/ada0p1
- Create an empty directory as a mountpoint; a location for mounting the new disk in the original disk's file system.
mkdir /my_second_hdd
- Add an entry to
/etc/fstabso that the new disk will be mounted automatically at startup.
/dev/ada0p1 /my_second_hdd ufs rw 2 2
Note: If there is a typo in fstab reboot will result in single-user-mode, i.e. read-only. To correct the fstab file
mount -u rw / # without rw you will be unable to save the edited file
zfs mount -a # change to ufs if the drive with the OS use this filesystem
vi /etc/fstab
Setup to mount usb drives (especially for non-root users) Carefully read the pre-requisite.
- List the HDD's and any usb-pen drive connected.
camcontrol devlist
- List the connected usb-pen drives, i.e. all the connected
da's, i.e.,da*.
ls /dev/da*
- Change owner (
chown); below gives username (joe) in the group (operator) the folder (/flashmedia) access.
chown joe:operator /mnt/flashmedia
Note that the group name is operator because /etc/devfs.rules has the line
add path 'da[0-9]\*' mode 0660 group operator
ls /dev/da*
Here it was identified as da0s1.
file –s /dev/da0s1
- Mounts the FAT formatted
da0s1usb to the /flashmedia folder.
mount_msdosfs /dev/da0s1 /mnt/flashmedia
- For NTFS
First install
fusefs-ntfs
pkg install fusefs-ntfs
Then,
echo -e "fuse_load=\"YES\"" >> /boot/loader.conf
Now you can mount with
ntfs-3g /dev/da0s1 /mnt/flashmedia
or
mount -t ntfs-3g /dev/da0s1 /mnt/flashmedia
- Unmount the usb device.
umount /mnt/flashmedia
Install automount
pkg install automount
Activate automount
service devd restart