Skip to content

Latest commit

 

History

History
301 lines (262 loc) · 12.2 KB

File metadata and controls

301 lines (262 loc) · 12.2 KB

Mounting setup.

Allow access to a variety of disks and input/output devices.

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:
    less /var/run/dmesg.boot
    
    and also
    ls /dev
    
  • For device name look at Table 3.3
  1. Below shows the vi /etc/devfs.conf file 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
  • perm /dev/tuner0 0666
  • perm /dev/dvb/adapter0/demux0 0666
    • Permission for demultiplexer for the tuner. About demultiplexer see this and this.
  • perm /dev/pass0 0666
  • perm /dev/xpt0 0666
  1. For devices that may be connected post-boot, we add an entry to a devfs.rules ruleset. 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:

2.2. Enable the ruleset in vi /etc/rc.conf

devfs_system_ruleset="devfsrules_common"

Mount external HDD (via usb).

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.

  1. vi /etc/fstab file will set the procfs and fdescfs filesystem.
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
  1. If you neglected to add your personal user account to the wheel and operator groups during installation, now is a good time to do so. In this example my user is joe.
  • If it not done already done assigning wheel membership lets you use su to become root
pw usermod joe -G wheel
  • If the operator membership is required for device permissions in this configuration do
pw usermod joe -G operator
  1. Confirm that the username (here, joe) is in both wheel and operator groups.
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
... ...
  1. Ensure that operator is 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 da for usb? Look at Table 3.3 for device name.

  • enable the ruleset in vi /etc/rc.conf

devfs_system_ruleset="localrules"
vfs.usermount=1
  1. Identify the device.
less /var/run/dmesg.boot

Here it was identified as ada0

  1. Wipe the HDD clean
gpart destroy –F ada0
  1. Create the GPT partition scheme and then add a single partition.
gpart create -s GPT ada0
  1. 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
  1. See disk partition information.
gpart show ada0
  1. Create file system in the new partition on the new disk.
newfs –U /dev/ada0p1
  1. 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
  1. Add an entry to /etc/fstab so 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

Mount usb drives.

Setup to mount usb drives (especially for non-root users) Carefully read the pre-requisite.

  1. List the HDD's and any usb-pen drive connected.
camcontrol devlist
  1. List the connected usb-pen drives, i.e. all the connected da's, i.e., da*.
ls /dev/da*
  1. 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
  1. Get the name of the connected usb.
ls /dev/da*

Here it was identified as da0s1.

  1. Get the format type of the usb named da0s1.
file –s /dev/da0s1
  1. Mounts the FAT formatted da0s1 usb to the /flashmedia folder.
mount_msdosfs /dev/da0s1 /mnt/flashmedia
  1. 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
  1. Unmount the usb device.
umount /mnt/flashmedia

Automount

Install automount

pkg install automount

Activate automount

service devd restart