keepcalculator

06 Numbers and Powers

Solaris Format Disk: How to Format in Oracle Solaris

Card No. 06·64153 · Updated · Standard formula, shown below

To format a disk in Oracle Solaris, you use the format command, which provides an interactive menu for selecting a disk, creating a partition table (VTOC or EFI), and formatting the disk with a file system. This article explains the entire process, from identifying the disk to verifying the result, and covers the common pitfalls and alternatives.

Understanding the format Command

The format command is the primary tool for disk management in Solaris. It is a menu-driven utility that lets you:

  • List all disks connected to the system
  • Select a specific disk to work on
  • Create or modify the partition table (VTOC for disks up to 2 TB, EFI for larger)
  • Format the disk (write sector headers and check for defects)
  • Label the disk with a name and geometry
  • Analyze and repair bad blocks

The command is usually run as root or with sudo privileges. It is available in all modern Solaris versions, including Oracle Solaris 11 and Solaris 10.

How to Format a Disk in Solaris

Here is the step-by-step process to format a disk using the format command:

  1. Identify the disk: Run format with no arguments. It will list all disks, e.g., c0t0d0, c1t1d0. Note the target number (0, 1, etc.) of the disk you want to format.
  2. Select the disk: Type the target number and press Enter. The prompt will change to format>.
  3. Check current partition table: Type partition to enter the partition menu. Use print to see the current layout. This is important to avoid accidentally erasing the wrong disk.
  4. Create a new partition table (if needed): In the partition menu, type modify to create a new VTOC or EFI label. You can also use create to make a default layout. For disks larger than 2 TB, you must use EFI (GPT) labels. Choose the option to create a new label when prompted.
  5. Define partitions: After creating the label, you can assign partitions (slices) with sizes and tags. For example, slice 0 for root, slice 1 for swap, etc. For a simple data disk, you might use slice 2 for the whole disk (VTOC) or slice 0 for the entire disk (EFI).
  6. Exit partition menu: Type quit to return to the format> prompt.
  7. Format the disk: Type format again (or fdisk on x86 systems to create a Solaris partition first). The format command will write sector headers and optionally scan for defects. You can specify a quick format with format -q or a full format with format (which is slower).
  8. Label the disk: Type label to write the disk label. This is essential for the system to recognize the disk.
  9. Create a file system: After formatting, you need to create a file system with newfs (for UFS) or zfs create (for ZFS). For example: newfs /dev/rdsk/c0t0d0s0 or zpool create mypool c0t0d0.
  10. Mount the file system: Finally, mount the file system to a mount point, e.g., mount /dev/dsk/c0t0d0s0 /mnt.

Choosing the Right Partition Table: VTOC vs. EFI

Solaris supports two disk label formats:

  • VTOC (Volume Table of Contents): The traditional Solaris format, supporting up to 8 partitions (slices) and a maximum disk size of 2 TB. It is used for boot disks and smaller disks.
  • EFI (Extensible Firmware Interface) / GPT: The modern format, supporting up to 128 partitions and disks larger than 2 TB. It is required for disks over 2 TB and is the default on newer systems.

When you format a disk, the format command will ask which label you want to use. For a new disk, choose EFI if the disk is larger than 2 TB or if you need more than 8 partitions. For a boot disk on x86 systems, you may need to use fdisk to create a Solaris partition before using format.

Common Problems and How to Avoid Them

  • Formatting the wrong disk: Always double-check the disk identifier (cXtYdZ) before proceeding. Use format to list disks and cross-reference with iostat -En to see serial numbers.
  • Disk is in use: If the disk is mounted or part of a ZFS pool, the format command will refuse to work. You must unmount the file system or export the ZFS pool first.
  • Disk larger than 2 TB with VTOC: If you try to use VTOC on a large disk, you will get an error. Use EFI instead.
  • Formatting takes too long: A full format can take hours for large disks. Use format -q for a quick format if you don’t need a defect scan.
  • File system not recognized: After formatting, you must create a file system with newfs or zfs. The format command only prepares the disk at the sector level.

Alternatives to the format Command

For many tasks, you may not need the interactive format command:

  • ZFS: If you are using ZFS, you can simply add a disk to a pool with zpool create or zpool add. ZFS manages the partitioning and formatting automatically. You do not need to run format first.
  • fdisk (x86 only): On x86 systems, you may need to run fdisk to create a Solaris partition before using format. This is often done automatically during installation.
  • Solaris Installation: When installing Solaris, the installer handles disk formatting automatically. You only need to manually format if you are adding a new disk to an existing system.

Safety and Precautions

Formatting a disk erases all data on it. Before you begin:

  • Back up any important data to another disk or remote location.
  • Verify that you have selected the correct disk by checking its size and model.
  • Ensure the disk is not part of a mounted file system or ZFS pool.
  • Use the format command’s analyze option to check for bad blocks before formatting, especially on older drives.

If you are unsure about any step, consult the Solaris documentation or a qualified system administrator. Incorrect formatting can lead to data loss.

Frequently Asked Questions

What is the difference between formatting and partitioning in Solaris?

Partitioning divides the disk into logical sections (slices) and writes a partition table (VTOC or EFI). Formatting writes sector headers and checks the disk surface for defects. You must partition first, then format, then create a file system.

Can I format a disk that is currently in use?

No. The format command will refuse to format a disk that is mounted or part of a ZFS pool. You must unmount file systems and export ZFS pools before formatting.

How long does a full format take?

It depends on the disk size and speed. A rough estimate is 1.2 minutes per GB, so a 100 GB disk takes about 2 hours. Quick formats (format -q) take only a few seconds.

Do I need to format a new disk before using it with ZFS?

No. ZFS manages the entire disk, including partitioning and formatting. You can simply run zpool create pool disk and ZFS will take care of the rest.

What is the maximum disk size supported by VTOC?

VTOC supports disks up to 2 TB. For larger disks, you must use the EFI (GPT) label format, which supports disks up to 8 ZB (theoretically).

How do I check the format of a disk without changing it?

Run format and select the disk, then use the partition menu and print to view the current partition table. You can also use prtvtoc /dev/rdsk/cXtYdZ to print the VTOC directly.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →