From owner-freebsd-questions@FreeBSD.ORG Tue Jul 5 05:30:44 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6AA5A106566C for ; Tue, 5 Jul 2011 05:30:44 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) by mx1.freebsd.org (Postfix) with ESMTP id BB77E8FC0A for ; Tue, 5 Jul 2011 05:30:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id p655UdVx027061; Tue, 5 Jul 2011 15:30:41 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Tue, 5 Jul 2011 15:30:39 +1000 (EST) From: Ian Smith To: Matthew Seaman In-Reply-To: <20110705042728.409431065745@hub.freebsd.org> Message-ID: <20110705150337.N84785@sola.nimnet.asn.au> References: <20110705042728.409431065745@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: tethys ocean , freebsd-questions@freebsd.org Subject: Re: mount /unmount 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, 05 Jul 2011 05:30:44 -0000 In freebsd-questions Digest, Vol 370, Issue 2, Message: 19 On Mon, 04 Jul 2011 20:43:23 +0100 Matthew Seaman wrote: > On 04/07/2011 15:53, tethys ocean wrote: > >> If a partition was not unmounted cleanly (eg. the machine crashed, or > >> > the power was cut off suddenly) then fsck(8) should be used to check and > >> > fix any problems on the filesystem. If you've booted into single-user > >> > mode, then definitely fsck any partitions before trying to mount them. > >> > > > *I guess If I can do fsck without unmount partition I can lost all my data > > isn't it?* > > fsck on an unmounted partition will change on-disk data structures in > ways that the kernel doesn't expect. So, yes, one consequence is that > you can lose or corrupt data. You probably wouldn't lose everything in > the partition -- but you would tend to cause corruption predominantly in > files that are more actively used. > > So don't do that. Actually fsck is smarter than to damage data on mounted partitions; it forces the -n switch (NO WRITE) on a mounted partition so is perfectly safe to use, as long as you're aware that it can't correct any errors, and indeed will most often list some apparent errors that are merely temporary inconsistencies in the present state of the filesystem such as open files, viz: sola# mount -p /dev/ad0s2a / ufs rw 1 1 devfs /dev devfs rw 0 0 /dev/ad0s2d /var ufs rw,noatime 2 2 /dev/ad0s2e /usr ufs rw,noatime 2 2 devfs /var/named/dev devfs rw 0 0 sola# fsck /var ** /dev/ad0s2d (NO WRITE) ** Last Mounted on /var ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts UNREF FILE I=24 OWNER=mysql MODE=100600 SIZE=0 MTIME=Feb 6 23:59 2011 CLEAR? no UNREF FILE I=60 OWNER=mysql MODE=100600 SIZE=0 MTIME=Feb 6 23:59 2011 CLEAR? no UNREF FILE I=86 OWNER=mysql MODE=100600 SIZE=0 MTIME=Feb 6 23:59 2011 CLEAR? no UNREF FILE I=24830 OWNER=root MODE=140666 SIZE=0 MTIME=Mar 2 03:32 2011 CLEAR? no ** Phase 5 - Check Cyl groups 2579 files, 96883 used, 29956 free (1132 frags, 3603 blocks, 0.9% fragmentation) sola# fsck /usr ** /dev/ad0s2e (NO WRITE) ** Last Mounted on /usr ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts UNREF FILE I=804237 OWNER=smithi MODE=100640 SIZE=0 MTIME=Jun 29 20:29 2011 CLEAR? no ** Phase 5 - Check Cyl groups 401132 files, 8584016 used, 3155190 free (88926 frags, 383283 blocks, 0.8% fragmentation) cheers, Ian