Macos Terminal Commands To Check Apfs Disk For Errors

Disk Utility has long been the workhorse of choice for dealing with hard drives, SSDs, and disk images. With the advent of APFS (Apple File System) with macOS High Sierra, Disk Utility acquired some additional capabilities that allow it to work with APFS and its support for containers.

macOS Mojave Failing to Install on an External USB Drive? Here’s the Fix The first thing to know is that, when you format the external SSD as APFS, you’ll be creating an APFS container. Jul 12, 2019  This command will format your main disk to 'Mac OS extended journaled' and name the drive Untitled. If you want it to be APFS just change to 'diskutil erasedisk APFS Untitled /dev/disk0' This is a format though = everything will be erased from the main disk.

We’re going to look at how to use Disk Utility to partition drives into multiple containers, and how to add volumes to containers. If you need to partition and manage standard HFS+ volumes, you’ll find detailed instructions in the Rocket Yard guide: How to Use macOS Sierra Disk Utility to Partition, Erase Drives.

What Are Containers?
Containers are a new abstract used in the APFS system to define a storage system that can share available free space among one or more volumes. Apple calls this Space Sharing. It allows volumes that are within a common container to grow or shrink as needed, without any type of repartitioning.

Related article: How to Revert a drive from APFS back to HFS+

Containers, then, define a block of space on a physical drive that will be assigned to and used by volumes you create in the container. Volumes you create in a container can have a minimum size and a maximum size, but the actual amount of space they use is dynamically assigned from the container’s free space, as each volume within the container needs the space.

(The selected drive shows that it contains two containers of different sizes. The smaller container houses a single volume, and the larger container holds two volumes.)

Use Disk Utility to Create an APFS Container
Containers are only supported on drives formatted with APFS. You can format a drive or convert an HFS+ drive to APFS using the version of Disk Utility found in macOS High Sierra or later.

APFS was designed primarily for use with SSDs, though it should also work with standard hard drives. But before you decide to format a hard drive to use APFS, you may want to read: Using APFS On HDDs …And Why You Might Not Want To. At the moment, Apple doesn’t support APFS being used on Fusion drives.

Before you begin this process, take a moment to make sure you have a current backup of the information on your Mac, and that the drive used for backups isn’t one of the drives that will be involved in any of the processes we will be performing. The best way to do that is to eject the backup drive and, if possible, disconnect it from your Mac.

With your backups current, you’re ready to explore the APFS file system, including working with containers and volumes.

Launch Disk Utility, located at /Applications/Utilities.

In the Disk Utility toolbar, click on the View button and select Show All Devices. You can also use the View menu to perform the same task.

To convert an HFS+ volume to an APFS volume, select the HFS+ volume on the Disk Utility sidebar. (HFS+ volumes appear just below the physical drives in the sidebar.) Once selected, choose Convert to APFS from Disk Utility’s Edit menu. A sheet will drop down asking if you would like to convert the drive to APFS. Converting to APFS shouldn’t cause data loss on the selected drive, but it’s a good idea to make sure the data on the drive has been backed up first. When you’re ready, click the Convert button.

(Disk Utility being used to convert the existing Video volume to APFS.)

To format a drive in APFS, select the drive in Disk Utility’s sidebar. Select Erase from the toolbar or from the Edit menu. Provide a name, and then select one of the APFS formats from the Format dropdown menu. Formatting a drive will erase all of the data it contains, so make sure you have a backup of the data, if needed, before proceeding. When you’re ready, click the Erase button.

Disk Utility will create an APFS container, along with a single volume within the container.

Adding Containers
A drive formatted to use APFS can have multiple containers. Each container can have multiple volumes, and the volumes within a container share the space within their container. You can add additional containers in order to isolate one group of volumes from another and prevent volumes from sharing space. This is done by partitioning the APFS drive.

(A drive can house multiple containers. The container’s name is used for the first volume that is created as part of the container.)

Select the APFS drive from the Disk Utility sidebar, then click the Partition button in the toolbar or select Partition from the Edit menu.

A sheet will appear asking if you wish to add a Volume or Partition the drive. Click the Partition button.

The Partition sheet will drop down. Use the plus (+) button to add a partition.

Enter a name for the partition.

Tip: Disk Utility uses the term partition, but since this is an APFS formatted drive, you’re actually creating containers.

You can add multiple partitions/containers by clicking the plus button.

You can resize the partitions/containers by dragging the anchor point on the pie chart to increase or decrease the size of a container. You can also modify a container’s size by selecting a container in the pie chart and entering a new value in the Size field. When you’re done, click Apply.

Adding Volumes to a Container
With the older HFS+ system, volumes were added to reserve space on the physical drive. With APFS, volumes are added to containers and every volume within a container shares the container’s available space.

(You can add multiple volumes to a container, with each volume dynamically sharing the available container space.)

To add a volume, select the container you wish to use in the sidebar, then select Add APFS Volume from the Edit menu.

A sheet will drop down, allowing you to give the volume a name. You can add size limitations by clicking the Size Options button.

Although a volume can grow and shrink as needed within the confines of a container, you can apply reserve size and quota size restrictions for each volume you create. The reserve size defines a size the volume is guaranteed to never go below; consider this the minimum volume size. The quota size defines the largest size the volume is allowed to grow to. You can use these size restrictions to ensure a volume doesn’t expand to completely fill the available space, or that another volume in the same container doesn’t take space away from a volume that needs a minimum amount of free space.

It’s not advisable to make use of the Size Options unless the volume you’re creating has a real need for them. Size options can’t be easily changed once a volume is created.

Enter the Reserve Size and Quota Size, if you wish to use these features, and click OK.

Apfs

Resizing APFS Volumes
APFS volume sizes are dynamically adjusted; as a result, you don’t need to manually adjust the size of a volume. A volume will grow in size as long as there’s free space in the container and the quota size, if assigned, hasn’t been reached.

Resizing Containers
Containers on a physical drive can be reduced in size to make room for additional containers. You can’t, however, enlarge a container without first deleting the adjacent container to make room. You can also add containers or delete containers you no longer need.

The rules for resizing containers follow the same ones used for resizing partitions. You can find more information about resizing rules in the Rocket Yard Guide: Partition 101: Rules to Resizing Volumes & How to Without Losing Data.

To resize containers, you make use of Disk Utility’s Partition function.

Disk

Select the physical drive in Disk Utility’s sidebar whose containers you wish to modify.

Click the Partition button in the toolbar.

A dropdown sheet will ask if you wish to Add a Volume or Partition. Click the Partition button.

The Partition map will be displayed, showing all of the containers in the selected drive. To reduce the size of a container, click within the container on the map, and then enter a new lower size for the container. You can’t reduce a container to a size smaller than the amount of data taken up by any volumes the container has. If you need to squeeze a container down to a smaller value, you’ll have to delete one or more volumes within the container (see Deleting Containers and Volumes, below).

Disk Utility will show the new smaller size of the container, as well as display a new container made up of the unassigned space. You’ll also see a resize anchor point appear on the pie chart. You can use this to fine-tune the container size.

Once you have the container sized as you wish, click the Apply button to make the changes permanent.

Deleting Containers and Volumes
Volumes can be removed from a container by selecting the volume you wish to delete from the Disk Utility sidebar. Once selected, choose Delete APFS Volume from the Edit menu, or right-click on the volume and select Delete APFS Volume from the popup menu.

Containers can also be removed, though there is a restriction that any APFS formatted drive must have at least one container. As a result, the first container that was created can’t be removed.

Any other containers a drive may have can be removed using the Partition tool. In the Disk Utility Sidebar, select the container you wish to remove, and then click the Partition button in the toolbar. In the sheet that appears, click the Partition button.

The partition window will open with the selected container highlighted in the partition map. You can delete the selected container by clicking the minus (-) button. If the minus button is dimmed, you may have selected the first container, which can’t be deleted.

Working with APFS disks, containers, and volumes may seem a bit cumbersome with Disk Utility, but given a bit of time, Disk Utility should see a few enhancements to make working in APFS storage systems as easy as the older HFS+ system.

Be Sociable, Share This!

Prices, terms, and availability subject to change without notice. Not responsible for typographical, technical, or descriptive errors of products herein.
OWC is on-site wind turbine powered at 8 Galaxy Way, Woodstock, IL 60098 | 1-800-275-4576 | +1-815-338-8685 (International)
All Rights Reserved, Copyright 2018, OWC – Since 1988

Disk Utility User Guide

Apple File System (APFS) allocates disk space on demand. When a single APFS container (partition) has multiple volumes, the container’s free space is shared and can be allocated to any of the individual volumes as needed. Each volume uses only part of the overall container, so the available space is the total size of the container, minus the size of all volumes in the container.

Macos Terminal Commands To Check Apfs Disk For Errors Free

Add an APFS volume

Each volume you add to an APFS container can have a different file system format, if needed.

  1. In the Disk Utility app on your Mac, select an existing APFS volume in the sidebar, then click the Add Volume button in the toolbar.

  2. Enter a name for the new APFS volume.

  3. Click the Format pop-up menu, then choose an APFS format.

    If you want to encrypt the volume, choose APFS (Encrypted) or APFS (Case-sensitive, Encrypted).

  4. If you want to manually manage APFS volume allocation, click Size Options, enter values in the fields, then click OK.

    • Reserve Size: The optional reserve size ensures that the amount of storage remains available for this volume.

    • Quota Size: The optional quota size limits how much storage the volume can allocate.

  5. Click Add, then click Done.

Delete an APFS volume

When you delete a volume, all the data on the volume is permanently erased, and the volume is removed from the container.

Macos terminal commands to check apfs disk for errors free
  1. In the Disk Utility app on your Mac, select the APFS volume you want to delete in the sidebar.

  2. Click the Delete Volume button in the toolbar.

  3. Click Delete, then click Done.

Macos Terminal Commands To Check Apfs Disk For Errors Iphone

Erase an APFS volume

When you erase a volume, all the data on the volume is permanently erased, and the empty volume remains in the container.

Macos Terminal Commands To Check Apfs Disk For Errors Free

  1. In the Disk Utility app on your Mac, select the APFS volume you want to erase in the sidebar.

  2. Click the Erase button in the toolbar.

  3. (Optional) Enter a new name for the volume.

  4. (Optional) Click the Format pop-up menu, then choose an APFS format.

    If you want to encrypt the volume, choose APFS (Encrypted) or APFS (Case-sensitive, Encrypted).

  5. Click Erase, then click Done.

You can’t delete or erase your startup volume. See Erase and reformat a storage device.

Macos Terminal Commands To Check Apfs Disk For Errors Windows 10

See alsoAbout Disk Utility on MacFile system formats available in Disk Utility on Mac