Monitoring and Troubleshooting


This section describes some techniques for monitoring file systems and for correcting problems related to file systems. You will learn some techniques for dealing with dot files in folders you copy to Windows computers. You will learn how to use fsck to check a file system for issues and how to determine why a mounted local volume cannot be ejected. You will also learn two command-line utilities for determining file space utilization.

Dot Files in Windows

As you learned earlier in this lesson, Mac OS X folders sometimes contain shadow files. In addition, they often contain .DS_Store files. The Finder creates a file called .DS_Store in every folder it visits. The Finder uses the .DS_Store files to keep track of folder view options, icon positions, and other visual information about folders. You can safely delete these files.

When you copy a folder from your Mac OS X computer to a Windows computer, shadow files and .DS_Store files become visible, as the following figure illustrates, because the Windows graphical user interface does not hide filenames that begin with a period (dot).

If you want to delete the .DS_Store files before you transfer folders to a Windows computer, you can use a command in Terminal. For example, you could run the command

sudo find / name ".DS_Store" depth exec rm {} \;


You could substitute name `._*' in the command line to delete shadow files, but remember that you might want the shadow files if you copy the folder back to a Mac OS X computer.

Sometimes when you copy files back and forth between Mac OS X and Windows, files lose their custom icons. You can restore a file's custom icon if you have another file that has the same icon. Just copy and paste the icon from one Get Info window to another.

If you do not want these files to show up, add the following line to the Global section of the /etc/smb.conf file:

hide dot files = yes

The next time you start the computer or restart Windows file sharing, these files will not appear to Windows users.

Check for File-System Issues With fsck

A crash, power failure, or other sudden shutdown can render a nonjournaled file system unusable. The startup script, rc, runs fsck during system startup to repair such a situation.

If the volume is HFS or HFS Plus, the fsck command invokes fsck_hfs. By default, the fsck_hfs command does not check journaled HFS Plus file systems. Occasionally, however, a journaled HFS Plus file system becomes unusable during normal usage. You can use fsck_hfs f to force the command to check and repair a journaled HFS Plus file system with the following commands:

$ sudo fsck_hfs /dev/disk0s2 fsck_hfs: Volume is journaled. No checking performed. fsck_hfs: Use the -f option to force checking. $ sudo fsck_hfs -f /dev/disk0s2 ** Checking HFS Plus volume. ** Checking Extents Overflow file.


To get fsck_msdos to run on a flash memory device, connect the device, then use the umount command to unmount it.

$ sudo fsck_msdos /dev/disk2s1 ** Phase 1 - Read FAT ** Phase 2 - Check Cluster Chains ** Phase 3 - Checking Directories ** Phase 4 - Checking for Lost Files


The fsck command invokes fsck_msdos on MS-DOS file systems.

Getting Information About Open Files

Sometimes when you try to eject a disk, you get an error message such as "The disk 'Data' is in use and could not be ejected," as shown in the following figure. The best way to resolve this problem is to determine whether a file on the disk is open and, if so, close the file from the application or utility that opened it. If you don't know which application or utility is using a file on the disk, you can find out by using the lsof command.

daves-mac:~ david$ lsof /dev/disk1s2

COMMAND

PID

USER

FD

TYPE

DEVICE

SIZE/OFF

NODE

NAME

Finder

145

david

14r

VDIR

14,5

68

351

/Volumes/Data/.Trashes/501

Finder

145

david

16r

VDIR

14,5

4182

35

/Volumes/Data/com.apple.iChat.plist

Finder

145

david

18r

VDIR

14,5

714

2

/Volumes/Data


Run lsof as root (using sudo) to see processes you do not own. You can use grep to find processes using files on a specific volume. For example, if Preview is using file /Volume/ Data/MyDir/MyFile.pdf, the output of

sudo lsof | grep "/Volumes/Data"


might contain the following line:

Preview 721 student17 54r VREG 14,15 448581 559 26 /Volumes/Data   MyDir/MyFile.pdf


The command fs_usage is useful for showing which files an application uses. Type

sudo fs_usage | grep Application

where Application is the name of the application you are interested in. You will see all file-system activity related to that application, including the pathnames of files while they are being read or written.

Alternatively, to show files used by a specific process, use ps or Activity Monitor to get the process identifier (PID) of an executing application. Then type

sudo fs_usage pid

where pid is the PID of that application.

Getting Disk Usage Information

Use the df command to view disk capacity and the amount of free and available disk space on file systems. By default, values display in 512-byte blocks. Use the h option to display values in a format that is easier to read, with unit suffixes such as kilobytes and megabytes instead of 512-byte blocks. Use the l option to restrict output to local disks.

$ df -lh Filesystem    Size  Used  Avail  Capacity  Mounted on /dev/disk0s2  37G   13G   24G    36%       / /dev/disk2s2  88G   44G   44G    50%       /Volumes/HD2


Use the du command to view the file-system block usage for each file specified as an argument. By default, every file in the hierarchy is listed under each folder argument. Use the s option to get summary totals for folders. Use the h option to display values in a format that is easier to read.

$ du -sh * 660K Documents 108M Library 8.0K Movies


Disk space needs vary, depending on the types of files users store on disk. Movies, for example, can consume much more disk space than other types of files.

Computers shared by multiple users need more home folder space if home folders are local. You can use shared volumes for home folders. You can also use shared volumes for files that are accessed by multiple users instead of providing individual copies to each user.

Some jobs or businesses require more work space. Video files, for instance, might require more disk space.




Apple Training Series. Mac OS X System Administration Reference, Volume 1
Apple Training Series: Mac OS X System Administration Reference, Volume 1
ISBN: 032136984X
EAN: 2147483647
Year: 2005
Pages: 258
Authors: Schoun Regan

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net