blog'o thnet

To content | To menu | To search

Tuesday 24 October 2006

devfs.conf, or... devfs.rules

If you are using a USB thumbdrive, it may be interesting to be able to mount it as a normal user, i.e. without the need for a privileged account. The question is how to set these rights for devices not available at boot time?... Just use devfs.rules(5), it serves the same purpose than /etc/devfs.conf, but is specifically well suited for removable devices.

Here is an example of setting the mode and group (in which must resides the desired user(s)) for a USB removable key, seen as an SCSI device of the direct access class:

$ cat /etc/devfs.rules
[devfsrules_allow_usb=10]
add path 'da*' mode 0660 group usb

# Devices usually not available at boot time.
[devfsrules_allow=100]
add include $devfsrules_allow_usb

Many thanks to Roland Smith for its particular interesting notes on that subject and for contributing the devfs.conf(5) and devfs.rules(5) manual pages to the FreeBSD project.

Thursday 24 August 2006

ZFS on a USB Disk (removable Media)

With a relatively recent versions of Solaris or OpenSolaris (say Nevada build 36, Solaris Express 4/06 and Solaris 10 6/06 release), here is how it is possible to use ZFS as the backing file system for such a removable device, easily.

The first step is certainly to disable the vold(1M) SMF service, for the operating system not trying to mount it automatically each time this device will be plugged in:

# svcadm disable volfs

Knowing that Solaris USB driver presents any USB storage device as removable media, it can be seen using both the format command in expert mode, and the rmformat program:

# format -e < /dev/null
Searching for disks...done

AVAILABLE DISK SELECTIONS:
       0. c1d0 <DEFAULT cyl 9720 alt 2 hd 255 sec 63>
          /pci@0,0/pci-ide@7/ide@0/cmdk@0,0
       1. c2d0 <ST325082-         4ND0XKT-0001-232.89GB>
          /pci@0,0/pci-ide@7/ide@1/cmdk@0,0
       2. c3t0d0 <ST940211-5A-0000-37.26GB>
          /pci@0,0/pci108e,5347@2,1/storage@3/disk@0,0
Specify disk (enter its number):
#
# rmformat
Looking for devices...
     1. Logical Node: /dev/rdsk/c0t0d0p0
        Physical Node: /pci@0,0/pci-ide@6/ide@0/sd@0,0
        Connected Device: LITE-ON  DVD SOHD-16P9S   F3S2
        Device Type: DVD Reader
        Bus: IDE
        Size: <Unknown>
        Label: <Unknown>
        Access permissions: <Unknown>
     2. Logical Node: /dev/rdsk/c3t0d0p0
        Physical Node: /pci@0,0/pci108e,5347@2,1/storage@3/disk@0,0
        Connected Device: ST940211 5A               0000
        Device Type: Removable
        Bus: USB
        Size: 38.2 GB
        Label: <Unknown>
        Access permissions: Medium is not write protected.

Now that the device name is clearly identified, it possible to create a specialized pool:

# zpool create rmzp c3t0d0
# zpool list rmzp
NAME                    SIZE    USED   AVAIL    CAP  HEALTH     ALTROOT
rmzp                     37G   28.6M   37.0G     0%  ONLINE     -

Since the purpose of this disk is, among other things, to be a backup of my home directory, here is how to do so.

First, create the correct zfs hierarchy on the USB disk:

# zfs create rmzp/home
# zfs set compression=on rmzp/home

Take a snapshot of current home directory, send and restore it on the fly to the new pool:

# zfs snapshot datazp/home/jgabel@rmzp.0
# zfs send datazp/home/jgabel@rmzp.0 | zfs receive rmzp/home/jgabel
# zfs destroy rmzp/home/jgabel@rmzp.0
# zfs list -r rmzp
NAME                   USED  AVAIL  REFER  MOUNTPOINT
rmzp                  28.6M  36.4G  25.5K  /rmzp
rmzp/home             28.5M  36.4G  26.5K  /rmzp/home
rmzp/home/jgabel      28.5M  36.4G  28.5M  /rmzp/home/jgabel

Then, when you are ready to take it away, just export the pool as with a classical disk:

# zpool export rmzp
# zpool list rmzp
cannot open 'rmzp': no such pool
# zpool import
  pool: rmzp
    id: 1670601809438763813
 state: ONLINE
action: The pool can be imported using its name or numeric identifier.
config:

        rmzp        ONLINE
          c3t0d0    ONLINE

Wow! What an easy and powerful way to do backups on removable media, isn't it?

Since there is new ZFS porting work on the way (e.g. ZFS on FUSE/Linux and ZFS on FreeBSD), we can expect to share this kind of devices between Unix-like OSes very quickly.

Thursday 18 August 2005

Update the Notebook to FreeBSD 6.0-BETA2

I decided to take advantage of this three days week-end (at least in France) to upgrade the Notebook to FreeBSD 6.0-BETA2 and follow the RELENG_6 branch testing the upcoming FreeBSD release.

In fact, i hope this one may help me in two areas... more precisely: fix a very annoying bug resulting in a USB interrupt storm and help on the wifi side, based on the work done to incorporate the wpa_supplicant code from ports(7).

The installation went smooth and well, although there is no package yet (it is a beta release, not a release candidate) and all third party need to be compile from sources. So, i installed the minimum required. In the same time, update (one more time) the installation notes, notably regarding the DHCP part (this branch switched from the ISC DHCP client v3.x to the OpenBSD DHCP client which was based on ISC DHCP v2.x). The biggest problem was to figure how to set it up in order to be able to update its DNS records obtained from the DHCP server. The solution is very simple: don't let the client do this setting (as in RELENG_5 with ISC DHCP) but do it on the server side level. It has the other advantage not to care how to do this on multiple heterogeneous clients (UNIX, Unix-like, Windows, etc.).

On the other side, there is one problem though. Because this release needs testing, the default kernel comes with debugging options enable (INVARIANTS and WITNESS(4) in particular) which have the side effect of slowing down the machine, really. These options help debugging and lightning some problems that may appeared in the development process. One of this is called a LOR and i encountered two of them. They are already known to the developers, but we don't know yet the real impact of these: harmless or not. Here is the thread about this on current@.

Go testing. I will try to reproduce the panic i encountered before to know the code path where this happens.