From owner-freebsd-questions@FreeBSD.ORG Tue Jun 12 00:17:48 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 93AE316A400 for ; Tue, 12 Jun 2007 00:17:48 +0000 (UTC) (envelope-from wmoran@potentialtech.com) Received: from mail.potentialtech.com (internet.potentialtech.com [66.167.251.6]) by mx1.freebsd.org (Postfix) with ESMTP id 62C7313C45A for ; Tue, 12 Jun 2007 00:17:48 +0000 (UTC) (envelope-from wmoran@potentialtech.com) Received: from working (c-71-60-105-193.hsd1.pa.comcast.net [71.60.105.193]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.potentialtech.com (Postfix) with ESMTP id 2E38AEBC78; Mon, 11 Jun 2007 20:17:35 -0400 (EDT) Date: Mon, 11 Jun 2007 20:17:14 -0400 From: Bill Moran To: Modulok Message-Id: <20070611201714.35153d92.wmoran@potentialtech.com> In-Reply-To: <64c038660706111652p311c6d84i1ec295edcfc16994@mail.gmail.com> References: <64c038660706111652p311c6d84i1ec295edcfc16994@mail.gmail.com> X-Mailer: Sylpheed 2.4.2 (GTK+ 2.10.12; i386-portbld-freebsd6.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: umount -f X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2007 00:17:48 -0000 Modulok wrote: > > Couple questions for anyone on the list who has a moment (and the answer to > any of these): > > Objective: I need to kick people off of a storage drive (we'll say > /dev/ad4), without corrupting the file system and without bringing the > entire system down. I need to safely umount the file systems, even if my > users have processes which have files open. > > 1. If I use "umount -f /dev/ad4s1a" to forcefully umount a file system, does > this jeopardize the integrity of said file system? Like...will it jerk the > run out from under a process in the middle of a disk write, thus leaving a > half written file, or will it wait until the write is complete? (I guess > this would largely depend on the disk controller?) I don't believe there are any guarantees if your -f it. The filesystem will probably be OK, but I would expect files to get corrupt. > 2. How do I get a list of processes that are accessing a specific file > system, e.g. /dev/ad4s1a? fstat(1) is your friend. > 3. Is there any safe way to unconditionally umount a file system, even if a > run-away process is writing to it (as bad of an idea as this is)? I would write a script that pulls fstat data, then kills any processes with files open, then attempts to unmount the filesystem. If that fails, go through the fstat data again and kill -9 the processes this time. If all that fails, you can finally choose to umount -f. You could also try some looping constructs, kill/umount four or five times before switching to kill -9/umount, etc. It all depends on how desperate you are to get the filesystem unmounted, how long you're willing to wait, how much data you're willing to lose, etc. -- Bill Moran http://www.potentialtech.com