From owner-freebsd-stable@FreeBSD.ORG Tue Nov 28 21:35:57 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2327416A47B for ; Tue, 28 Nov 2006 21:35:57 +0000 (UTC) (envelope-from chris@vindaloo.com) Received: from corellia.vindaloo.com (corellia.vindaloo.com [64.51.148.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7BF2643CA9 for ; Tue, 28 Nov 2006 21:35:34 +0000 (GMT) (envelope-from chris@vindaloo.com) Received: from yavin.vindaloo.com (yavin.vindaloo.com [172.24.144.34]) by corellia.vindaloo.com (Postfix) with ESMTP id 314895C4C; Tue, 28 Nov 2006 16:35:21 -0500 (EST) Received: from dagobah.vindaloo.com (dagobah.vindaloo.com [172.24.145.68]) by yavin.vindaloo.com (Postfix) with ESMTP id B88372536E; Tue, 28 Nov 2006 16:35:20 -0500 (EST) Received: from localhost.vindaloo.com (localhost.vindaloo.com [IPv6:::1]) by dagobah.vindaloo.com (8.13.8/8.13.8) with ESMTP id kASLYpAH001241; Tue, 28 Nov 2006 16:34:51 -0500 (EST) (envelope-from chris@vindaloo.com) From: Christopher Sean Hilton To: Roland Smith In-Reply-To: <20061125164008.GA5008@slackbox.xs4all.nl> References: <45686A63.6030708@mail.zedat.fu-berlin.de> <20061125164008.GA5008@slackbox.xs4all.nl> Content-Type: text/plain Date: Tue, 28 Nov 2006 16:34:50 -0500 Message-Id: <1164749690.1074.33.camel@dagobah.vindaloo.com> Mime-Version: 1.0 X-Mailer: Evolution 2.6.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: "O. Hartmann" , FreeBSD Stable Subject: Amd and UFS mounts X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Nov 2006 21:35:57 -0000 It's dim but I seem to remember that amd had no problems mounting a UFS volume but it would never time it out. This may be the bug that Oliver is referring to. This caused problems when using UFS on a USB stick since the drive would never be dismounted so it was never safe to remove from the USB port. I've just retested this and amd doesn't automatically time out a ufs volume unless you ask it to by using the amq command. If I remember my research correctly this is a feature, not a bug. It's important to be able to get these volumes to unmount automatically. The reason I researched this before was because I would continually forget to unmount the usb stick before I suspended my computer. Before I implemented this I was fscking my usb stick an average of twice a day. After that I only had to fsck usb attached storage once every two weeks. Although my current laptop won't suspend/resume cleanly I still find it useful. The usb hub in the docking station triggers bugs in FreeBSD's usb subsystem. Every once in a while the usb subsystem will hiccup. Normally this isn't a problem but if a drive is plugged in and mounted at the time of the hiccup then the drive won't detach properly and on system shutdown you get a stuck buffer which causes a need for a background fsck on the regular drives and a full fsck on the usb drive. I worked around the UFS mounts problem by using program mounts in amd. >From time to time I am tempted to write a "How-To" on getting amd to work with pendrives going all the way through using fdisk, disklabel, and newfs to put a native FreeBSD filesystem on a USB stick or portable hard drive but I always chicken out at the point where I'm telling the user how to modify /etc/fstab for fear that if someone slips up with vi they end up with an unusable FreeBSD install. In any case here's how I'm using amd with my pendrives: I've standardized on MSDOS FAT filesystems in s1 and FreeBSD filesystem in s2. Amd handles the e partition on on the FreeBSD slice. So the first usb drive will usually be device: /dev/da0. Under my system the MS-DOS slice on that drive will be /dev/da0s1 and can be accessed by any user via the amd by doing: ls -l /amd/msdos0 On a successful mount the user gets a symlink listing. The user can unmount the command by doing: amq -u /amd/msdos0 This will only work if there are no processes accessing the drive. If the user forgets amd does this automatically after 30 seconds. The utility FreeBSD partition, /amd/da0s2e is available as /amd/ufs0 and works the same as the msdos partition. ---------------------------------------------------------------------------- ***** Startup Options ***** I run amd with a conf file because on some machines I use it as a means of nfs mounting my home directories. $ grep amd /etc/rc.conf ## amd amd_enable="YES" # Run amd service with $amd_flags (or NO). amd_flags="-F /etc/amd.conf" ***** Amd Configuration options ***** Nothing really special here. $ cat /etc/amd.conf [ global ] browsable_dirs = no map_type = file mount_type = nfs search_path = /etc auto_dir = /.amd cache_duration = 30 log_file = syslog:daemon log_options = info print_pid = yes pid_file = /var/run/amd.pid restart_mounts = yes selectors_in_defaults = no [ /amd ] map_name = /etc/amd.map ***** Map files ***** Here's how amd maps a directory to a filesystem. $ cat /etc/amd.map # $FreeBSD: src/etc/amd.map,v 1.9 2002/05/15 22:24:29 obrien Exp $ # ## /defaults type:=host;fs:=${autodir}/${rhost}/host;rhost:=${key} ## * opts:=rw,grpid,resvport,vers=3,proto=udp,nosuid,nodev ## To use: ## mkdir -p /amd /.amd /.amd/cdrom /.amd/disk0 /.amd/disk1 ## chmod 755 /.amd/* ## chmod 555 /.amd /amd ## ## Hotpluggable disks: Firewire, USB, etc. All the work gets done by ## setting up the appropriate entry in /etc/fstab. Ex. My firewire ## enclosures appear as { da0, and da1 } my convention is to put the ## msdos filesystem, if any, in slice 1 and the hotpluggable FreeBSD ## filesystem, if any, in partition e of slice 2. The system expects ## that the hotpluggable freebsd filesystem will have all "autorun" ## scripts. So, the first firewire drive needs the following entries ## in /etc/fstab: ## ## /dev/da0s1 /.amd/msdos0 msdos rw,noauto 0 0 ## /dev/da0s2e /.amd/ufs0 ufs rw,nosuid,nodev,noauto 0 0 msdos0 type:=program;fs:=${autodir}/${key};\ mount:="/sbin/mount mount ${fs}";\ unmount:="/sbin/umount umount ${fs}" ufs0 type:=program;fs:=${autodir}/${key};\ mount:="/sbin/mount mount ${fs}";\ unmount:="/sbin/umount umount ${fs}" ***** Fstab entrys ***** Careful here. If you want to be really paranoid here add noexec to the mount flags. ... /dev/acd0 /.amd/cdrom cd9660 ro,noauto 0 0 /dev/da0s1 /.amd/msdos0 msdos rw,longnames,noauto 0 0 /dev/da0s2e /.amd/ufs0 ufs rw,nosuid,nodev,noauto 0 0 ...