Section 9.3. Disk Utility


9.3. Disk Utility

The primary tool for working with disks and filesystems is the Disk Utility (found in /Applications/Utilities), shown in Figure 9-5. The Disk Utility can be used to configure, format, eject, and partition disks of all kinds. On the left side of Disk Utility's interface is a list of the disks attached to your machine and the volumes that exist on those disks. Additionally, if you have any disk images mounted, a list of the most recently accessed files appears at the bottom of the left column. On the right side of the interface is a set of panels that give you access to the actions that you can accomplish with a drive. At the bottom of the window is a status display that gives you all sorts of information about the disk or volume you have selected.

Figure 9-5. Disk Utility


Some of the tasks you can perform with Disk Utility are:

  • Mount and eject disks, including hard drives, CDs, and disk images.

  • Get the type, format, capacity, and room available for any disk attached to your computer.

  • Check and repair disks (other than the boot disk).

  • Check and repair disk permissions.

  • Erase a disk, including erasure by writing random data to a disk.

  • Partition a disk into multiple volumes that subdivide the drive into multiple logical disks.

  • Create and work with disk images.

  • Restore the contents of a disk image to a disk.

  • Set up a Redundant Array of Independent Disks (RAID).

A command-line interface tool called diskutil can be used to perform all the features of the Disk Utility program and more. To get a list of the disks attached to your computer, execute the command diskutil list, as shown in Example 9-2.

Example 9-2. Getting a list of drives using the diskutil command
 $ diskutil list /dev/disk0    #:                   type name               size      identifier    0: Apple_partition_scheme                    *74.5 GB  disk0    1:    Apple_partition_map                    31.5 KB   disk0s1    2:              Apple_HFS Macintosh HD       74.4 GB   disk0s3 /dev/disk1    #:                   type name               size      identifier    0: Apple_partition_scheme                    *1.0 GB   disk1    1:              Apple_HFS iDisk              1.0 GB    disk1s2 /dev/disk2    #:                   type name               size      identifier    0: Apple_partition_scheme                    *37.3 GB  disk2    1:    Apple_partition_map                    31.5 KB   disk2s1    2:         Apple_Driver43                    28.0 KB   disk2s2    3:         Apple_Driver43                    28.0 KB   disk2s3    4:       Apple_Driver_ATA                    28.0 KB   disk2s4    5:       Apple_Driver_ATA                    28.0 KB   disk2s5    6:         Apple_FWDriver                    256.0 KB  disk2s6    7:     Apple_Driver_IOKit                    256.0 KB  disk2s7    8:          Apple_Patches                    256.0 KB  disk2s8    9:              Apple_HFS Iron               37.3 GB   disk2s9

This view gives you much more information than the list of drives and volumes on the left side of the Disk Utility application. In particular, it shows you that more than just a single volume is associated with a disk. In fact, there are several parts, sometimes called slices, to a disk, each with an identifier. The first slice of the disk holds the partition map. This is a key to where everything is located on the rest of the disk. Then a group of other partitions follows. In the case of Example 9-2, slices 2 through 8 of disk2 hold disk drivers used by Mac OS 9, and slice 9 is the actual HFS+ volume of the drive. The Mac OS 9 drivers are installed by default when you a format a disk. If you format an internal boot drive without the OS 9 drivers, you'll see something like the output listed for disk0.

9.3.1. Examining a Disk

To take a closer look at a device attached to your computer or a volume associated with a device, select the disk or volume and then click the Info button in Disk Utility's toolbar. A window pops up listing all sorts of information about the device or volume, as shown in Figure 9-6. The following are some of the fields that you'll see in the Info window for a disk:


Name

The name of the device or volume. In the case of a volume, this is the name you gave the volume and is that which appears in the Finder. In the case of a device, this is the hardware name of the disk, such as Hitachi IC25N080ATMR04-0.

Figure 9-6. Disk Utility's Disk Info window


Disk Identifier

The label by which the operating system refers to the disk. For example, the primary boot disk in most Macs is identified as disk0. A volume on the drive has an additional set of characters identifying the partition on the drive it occupies, such as disk0s9. The disk identifier is also the filename in the /dev directory under which programs may access the drive directly.


Connection Bus

The kind of bus that the device is attached to. The internal disk in a PowerBook will show "ATA" for this field while an external FireWire drive will show "FireWire."


Device Tree

The identifier in the system's device tree that the device occupies. This is the same identifier that shows up in the Open Firmware device tree.


Writable

Indicates whether the device can be written to.


Ejectable

Indicates whether the device can be ejected.


Total Capacity

The amount of data that the device can hold.


S.M.A.R.T. Status

Many disks made in the last few years contain a set of onboard diagnostic functions known as S.M.A.R.T., which stands for Self-Monitoring, Analysis, and Reporting Technology. These disks monitor disk calibration, cyclic redundancy check (or CRC) errors, disk spin-up time, rotation speed of the disk, distance between the head and the disk, and the temperature of the drive. The values you see in this field are either "Verified," which means everything is okay; "About to Fail," which means the disk needs to be replaced immediately; or "Not Supported," which means the drive doesn't support S.M.A.R.T.

If you examine a volume on a disk with the Info button, you'll see more information about the disk, including:


File System

The type of filesystem that the volume is formatted to use.


Capacity, Free Space, Used

The total amount of data that can be stored on the volume, the amount of additional data that can be stored on the volume, and how much space the current contents of the volume occupy.


Number of Files, Number of Folders

The number of files and folders on the volume.


Permissions Enabled, Can Turn Permissions Off, Can Repair Permissions

Indicates whether the system keeps and enforces permission information on files. This setting will always be "Yes" for the internal boot drive of your machine and is usually "No" for external drives where it is expected that you'll be moving data between machines. For disks that support permissions, the "Can Repair Permissions" setting indicates whether you can use Disk Utility to set the permissions of a disk to work with the current system.


Supports Journaling, Journaled

Indicates whether the volume supports journaling and whether it is enabled.

You can also get information on a disk by using the diskutil tool. Two commands that can be used with diskutil are:

     diskutil info device     diskutil info mountpoint

The first command uses a disk identifier, such as disk0, to locate the disk to obtain the information on. The second command uses the location in the filesystem where the device is mounted, such as /. Example 9-3 shows the result of running diskutil info against the boot drive of a machine.

Example 9-3. Getting disk information for the boot drive by using the disk identifier
 $ diskutil info disk0 Device Node:        /dev/disk0    Device Identifier:  disk0    Mount Point:    Volume Name:    Partition Type:     Apple_partition_scheme    Bootable:           Not bootable    Media Type:         Generic    Protocol:           ATA    SMART Status:       Verified    Total Size:         74.5 GB    Free Space:         0.0 B    Read Only:          No    Ejectable:          No    OS 9 Drivers:       No    Low Level Format:   Not Supported

Example 9-4 shows the information about the volume mounted at /.

Example 9-4. Getting disk information for the root volume by using the mountpoint
 $ diskutil info / Device Node:        /dev/disk0s3    Device Identifier:  disk0s3    Mount Point:        /    Volume Name:        Macintosh HD    File System:        Journaled HFS+                        Journal size 8192 k at offset 0x256000    Owners:             Enabled    Partition Type:     Apple_HFS    Bootable:           Is bootable    Media Type:         Generic    Protocol:           ATA    SMART Status:       Verified    UUID:               FE6998DC-19E4-3CF0-81E9-FC3BE0318265    Total Size:         74.4 GB    Free Space:         3.1 GB    Read Only:          No    Ejectable:          No

From this output, you can see that the filesystem is formatted as Journaled HFS+, and that the journal size is a mere 8192 KB. Even though it is modest in size, the journal has a large impact on the integrity of the filesystem and allows for many performance optimizations.

9.3.2. Verifying and Repairing Disk Permissions

One of the most common things that can go wrong with a disk is that the permissions for the various files and directories on it get set incorrectly. Although the permissions for a disk should never get out of whack, quite a few installers that require an administrator's password seem to set the permissions on various directories of your disk to what they think they should be. This is one reason why many system administrators abhor old-style software installers and prefer to install software distributed on disk images, which can be drag-and-dropped into the Applications folder without harm.

To see if the permissions on your disk are correct for your system, select the disk or volume you want to check and click the Verify Disk Permissions button in the First Aid panel of the Disk Utility interface. This determines what the correct file permissions are for your system and then checks your disk against those permissions. If your permissions are not set correctly, you should strongly consider repairing them by clicking the Repair Disk Permissions button.

To check permissions from the command line, use the following syntax to diskutil:

     diskutil verifyPermissions [diskid | mountpoint]

For example, to verify the permissions of the boot volume, you would use the following command:

     $ diskutil verifyPermissions /

To repair permissions, use the following:

     $ diskutil repairPermissions /

Disk Utility determines the correct permissions by examining data left by Mac OS X's Installer (found in the /Library/Receipts folder). Because drag-and-drop installation and custom application installers do not make use of Mac OS X's Installer, Disk Utility cannot determine if the permissions are set properly for programs installed by other means. Additionally, since user files and data also aren't handled by Mac OS X's Installer, the permissions on a user's data are not taken into account.


9.3.3. Verifying and Repairing Disks

To ensure that the filesystem on a disk is working correctly, select the disk or volume that you want to check and click the Verify Disk button. This scans the various parts of the filesystem to make sure they are intact. If any problems are reported, you should use Disk Utility's Repair Disk button to correct the issues.

To verify or repair a disk, Disk Utility must first unmount the drive, which removes the ability to access the files on the disk while it performs its work. This means you can't verify or repair the disk you booted from, and in most cases, that's the disk that you want to verify. There are two solutions to this problem, and they work equally well:

  • Boot off Mac OS X Tiger's install DVD. When the Installer shows up, select Installer Open Disk Utility from the menu bar so you can work on the local disk.

  • If Disk Utility runs into a problem it can't handle, you'll need to enlist the help of another application such as Drive 10 from Micromat (http://www.micromat.com) or Disk Warrior from Alsoft (http://www.alsoft.com/DiskWarrior).

    To verify and repair a disk from the command line using diskutil, you can use one of the following:

         diskutil verifyDisk [diskid | mountpoint]     diskutil repairDisk [diskid | mountpoint]

    Example 9-5 shows the command you should use to repair a FireWire disk named Backup.

    Example 9-5. Repairing a disk using the diskutil command
     $ diskutil repairDisk /Volumes/Backup Started verify/repair on disk disk1s3 Backup Checking HFS Plus volume. Checking Extents Overflow file. Checking Catalog file. Checking Catalog hierarchy. Checking volume bitmap. Checking volume information. The volume Backup Alpha appears to be OK. Verify/repair finished on disk disk1s3

    If for some reason you don't have Tiger's Install DVD or another computer to connect to your Mac, you can attempt to fix filesystem problems using fsck. The filesystem checker is a traditional Unix tool that performs many of the same tasks of diskutil's repairDisk mode. To use fsck, you'll first need to boot your Mac into single-user mode (discussed in Chapter 5). Once you're at the command-line prompt, enter the command:

         # /sbin/fsck -fy /

    This forces fsck to check the boot volume for errors and to automatically correct them. If any issues crop up during the check, fsck notifies you that the filesystem was modified. If no problems are found, fsck tells you that the volume appears to be OK. You may need to run fsck several times before it comes back clean.




Running Mac OS X Tiger
Running Mac OS X Tiger: A No-Compromise Power Users Guide to the Mac (Animal Guide)
ISBN: 0596009135
EAN: 2147483647
Year: 2004
Pages: 166

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