Jesus 'n Jim
A mainly PC (some Mac) site w/Software, Computer Repair Info, How-To's on Using Computers
Technical Support 1-360-521-2060 (my business line cell)

repair filesystem (chkdsk /f)

 

Overview

after using the computer for 3-6 months, or after turning off the computer hard (without shutting down), you should fix the filesystem, or especially if you have filesystem corruption (hardware doesn't seem to be working). here's how.

with DOS it doesn't matter about turning off the computer unless you happen to be writing to the disk at the time you are turning off the computer. but with other OS's, it matters!

I have recently discovered that, at least with Windows XP, it makes a difference if you defrag after repairing the filesystem (the cmd-shell method to repair is chkdsk /f c:).

you do not want to defrag if you have an SSD or hybrid drive on that drive letter, a defrag will shorten its lifespan in a hurry.

MSDOS/FreeDOS/OpenDOS/other DOS

MS-DOS and I maybe IBMDOS2000 have no provision for fixing the filesystem. If it's hosed you're out of luck.

FreeDOS has a number of filesystem fixing tools. FreeDOS uses I think 3 different filesystems, FAT12, FAT16, and FAT32. that program would have to support those. and the FAT32 is not a normal version of FAT32, it's modified.

so that means if it messes up your filesystem, I am warning you beforehand (and so does the documentation). it would be your own fault.

with DOS it matters about rebooting the computer, because the OS doesn't know about what you are doing to the filesystem. it MIGHT have something cached in memory. I like to do this as a safety precation after modifying the filesystem from underneath the OS's feet. fixing the filesystem or defragging is like pulling the rug out from underneath your feet, at least to the OS, and it needs to be restarted. these utilities seem to directly modify the disk, especially since there are no OS hooks to fix the filesystem.

I *think* these tools work with FAT16 as well as FreeDOS' FAT32.

  1. in freedos: fsck.exe -cd -cf or chkdsk.exe /f c: (chkdsk is currently at version 092 as of 4/15/2012 and very windows-NT/xp/2000/vista/7/8-like). msdos does not have any of these tools, sorry. IBMPCDOS2000 might have something -see help or info. there are 2 kinds of scandisk.exe, and diskscan.exe as well in freedos also. I really don't know which is the preferred method.
  2. ctrl-alt-del or do your usual shutdown procedure (especially if you have disk cache) as a safety precaution.
  3. defrag.exe if you have freedos. this program can use the mouse and it has a TUI, F1 for help.
  4. ctrl-alt-del or do your usual shutdown procedure (especially if you have disk cache) as a safety precaution.

9x/ME

I highly suggest you first read defragging virtual memory. the idea is to basically disable VM, chkdsk /f, defrag, and then turn your VM back on with its original settings (write them down). Unless you were having problems with "out of virtual memory" errors before at some point, I would suggest you do this if yo uhave a lot of thrashing. If you have LOTS of RAM, you don't need VM and you can if ignore this paragraph.

  1. hit f8 repeatedly during boot immediately after memory count (if you have one, else just press repeatedly during logo screen) like mad during boot and do one of 2 things: ...
    1. ...choose safe mode.
    2. start, control panel, display,screen saver, disable the thing completely!!! it will interrupt scandisk and defrag forever!
    3. double-click My Computer
    4. right click on c:, pick properties
    5. Tools tab
    6. check now
    7. turn on "Automatically fix file system errors" (the other is purely optional,turn it on if your disk is 5 years old or more and consider replacing/upgrading the drive using fssdev.com's casper 7.0 iso - you must also buy $60 windows version to have $10 bootable iso)
    8. click OK
    9. definitely reboot if it asks!
    10. F8 repeatedly to go back into safe mode again.
    11. double-click My Computer again
    12. right click on c:, pick properties again
    13. Tools tab again
    14. click Defragment Now... (this will make your deleted files inaccessible, by the way)
    15. start, control panel, display, screen saver, re-enable the screen saver if you still want it.
    16. restart or shut down
    1. ...choose safe mode msdos prompt
    2. type in scandisk.exe /autofix /all and hit Enter
    3. exit
    4. ctrl-alt-del
    5. shut down
    6. NOTE:defrag should NOT be done within safe mode command prompt. it should be done from safe mode.

2000/xp/vista/7/8

I highly suggest you first read defragging virtual memory. the idea is to basically disable VM, chkdsk /f, defrag, and then turn your VM back on with its original settings (write them down). Unless you were having problems with "out of virtual memory" errors before at some point, I would suggest you do this if yo uhave a lot of thrashing. If you have LOTS of RAM, you don't need VM and you can if ignore this paragraph.

you do not want to defrag if you have an SSD or hybrid drive on that drive letter, a defrag will shorten its lifespan in a hurry.

  1. close any open programs and things in the notification area/system tray
  2. start, control panel, display,screen saver, disable the thing completely!!! it will interrupt scandisk and defrag forever!
  3. start, My Computer
  4. right click on c:, pick properties
  5. Tools tab
  6. Error Checking, check now
  7. turn on "Automatically fix file system errors"
  8. click ok
  9. definitely reboot if it asks! (reboot after it's done anyway)
  10. go back into safe mode, except this time f you see a defrag option in that same tools tab, use it.
  11. close any open programs and things in the notification area/system tray
  12. start, My Computer
  13. right click on c:, pick properties
  14. Tools tab
  15. Defrag
  16. Analyze
  17. Choose Defrag, even if it says you don't need to (this will make your deleted files inaccessible, by the way)
  18. restart the computer as a safety precaution
  19. start, control panel, display, screen saver, re-enable the screen saver if you still want it.

Mac OS X

Socks is a shareware system maintenance and repair utility program. use it to fix your volumes. also, this pdf from Apple talks about how to schedule "repair a volume" using cron.

UNIX/linux/bsd/bsdi/*ix/debian

Actually, with ubuntu and most linuxes, and modern kernels, these steps are not necessary anymore! especially if the filesystem is a jounrlaing filesystem, like efs4. it fixes itself. sorry, ntfs-3g from tuxera.com which everyone wants to use is not so automatic.

boot a livecd. start an xterm. list the devices you have using ls /dev/sda* then mkdir a directory under /mnt/ such as mkdir /mnt/c then mount -t ext4 /dev/sda1 /mnt/c then see if you can do the following commands safely:

su root (enter password)
sync;sync;fsck
exit

Isn't UNIX user-friendly? It was meant to be a developer's system (and still is), it was never meant to be a user OS. I still don't think it's gotten anywhere near becoming a user-friendly desktop windows replacement yet. Not with critical oversights like this.

most often, though, Ubuntu will fix itself on boot. this is good, that eliminated these steps. I have not tried pulling the plug on other OS's yet to see what they do.