mount /unmount

Ian Smith smithi at nimnet.asn.au
Tue Jul 5 05:30:44 UTC 2011


In freebsd-questions Digest, Vol 370, Issue 2, Message: 19
On Mon, 04 Jul 2011 20:43:23 +0100 Matthew Seaman <m.seaman at infracaninophile.co.uk> 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


More information about the freebsd-questions mailing list