Skip to content

Instantly share code, notes, and snippets.

@mnadjit
Last active May 3, 2022 07:55
Show Gist options
  • Save mnadjit/a32cc2a8e960ec9c3d08a4c6ef5be1b4 to your computer and use it in GitHub Desktop.
Save mnadjit/a32cc2a8e960ec9c3d08a4c6ef5be1b4 to your computer and use it in GitHub Desktop.
macOS Common commands to get info about a machine, its hardware, status, monitoring, administration and some useful tools.

diskutil list

  • Get a list of all block devices

sudo diskutil mount disk0f1

  • Mount a disk; Name is found in the list obtained using diskutil tool e.g. disk0f1

sudo diskutil unmount disk0f1

  • Unmount a disk

Resize Virtual Disk

Once virtual disk has been resized, the following commands should be run to allow the apfs partitions to expand into the free space. For example if the virtual disk is a Linux qemu disk format i.e. qcow2, after running qemu-img resize MyDisk.qcow2 +20G to expand the file MyDisk.qcow2 by 20 gigabytes, the following commands should be run in Mac terminal. Explained here.

diskutil repairdisk <disk#> e.g. diskutil repairdisk disk0 diskutil apfs resizeContainer <partition_id> 0 e.g. diskutil apfs resizeContainer disk0s3 0

  • disk# and partition_id are both found using diskutil list
  • partition_id is the id of the partition you'd want to expand into the free space of the disk containing it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment