How to Install & Uninstall Drivers from the Command Line on Mac OS Guide

This guide is about Mount & Unmount Drives from the Command Line in Mac OS X. I will do my best so that you understand this guide very well. Hope you all like this guide Mount & Unmount Drives from Command Line in Mac OS X.

You can mount and unmount drives, drives and disks from the MacOS and Mac OS X command line.

For many users, the easiest way to remove a drive on a Mac is to drag the volume to the Trash, use the Delete keys, remove the drive, or use some forced removal method. Along the same lines, if you want to reinstall the drive, you can usually physically remove the drive and plug it back in. But what if you want to be able to install, uninstall and mount drives from the command line? This is exactly what we are covering here.

This trick works with external USB drives, hard drives, Firewire, Thunderbolt, DVDs, CDs, network drives, even USB flash drives, with literally any volume that can be mounted and used with the extremely useful diskutil command. When you reinstall a drive from the command line, the entire process can be done remotely via SSH if needed, and you never have to disconnect the drive from your Mac. This is extremely useful for troubleshooting, scripting, and automation scenarios, and is a great trick for those of us who just want to play in Terminal.

Removing a drive from the command line on a Mac

Let’s first look at removing the drive. To do this, you need another volume that is connected or plugged into your Mac in one format or another, and then start the Terminal to start (sit / Applications / Utilities /).

1: List all stations

The first thing you need to do is list the connected drives. This will list all the drives attached to your Mac that have been installed and removed, as well as all the corresponding Partitions. We do this so we can get a drive ID, something like disk1s2 or disk2s2, etc.

disk list

The result looks like this:

list $ diskutil / dev / disk0 #: TYPE NAME SIZE DISK0: GUID_partition_scheme * 121.3 GB disk01: EFI 209.7 MB disk0s12: Apple_HFS Macintosh HD 120.5 GB disk0s23: Apple_Boot Recovery disks HDvv 6013:01: EFI / IZPE: Recovery disk GB 6053 #1 : EFI 209.7 MB disk1s12: Apple_HFS OSX daily 15.7 GB disk1s2

For this example, we’ll focus on a connected drive called bollyinside, which happens to be an external USB flash drive that appears last on the list. Note that the drive ID for that drive is “disk1s2”, and we will move it to the next script to remove and reinstall it.

It’s probably worth mentioning that drives are always located in /dev/ so /dev/ is always appended to the prefix tag.

2: Remove the specified drive

We continue to use the diskutil command, assigning it to that drive to remove.

diskutil uninstall / dev / disk1s2

This indicates that the named quantity and location have been removed, as follows:

$ diskutil unmount / dev / disk1s2Volume OSXDis of day1s2 removed

That’s all there is to it. You’ll notice that the drive is no longer available in Finder, but it will still be visible through your disk account from the command line or the more familiar Disk Utility application in the Mac OS X interface.

Installing a driver from the command line on a Mac

Of course, if you can remove the drive, you can also mount or reinstall it. The script is very similar; find the volume and install the drive.

1: Get Drive to Mount

If you already know the location of the volume, you can ignore Part 1 and jump directly to Part 2, but in any case, the recovery of the volume tag will be covered. This time, we shorten it a bit because we assume that we know the name of the drive to be installed, so we just need to find the identifier. We do this by using a grep file to shorten the output of the diskutil command as follows:

list $ diskutil | grep bollyinside2: Apple_HFS bollyinside 15.7 GB disk1s2

This output is, of course, much shorter than the full diskutil listing output above.

In this example, the “bollyinside” drive is still located in /dev/disk1s2 and we will mount it.

2: Install (or install) the drive

To install (or reinstall) a drive, we use the same diskutil command with a new flag and inputs, for example:

diskutil mount / dev / disk1s2

Using the same examples elsewhere, the command and output look like this:

/dev/disk1s2 is mounted by $ diskutil mount /dev/disk1s2Volume bollyinside

This appears to reinstall the drive, and the installed volume will reappear in the Mac OS X Finder and GUI-based applications in various Open or Save dialog boxes.

Install and remove drives from the command line in Mac OS X.

Remove and install a drive / drive with a single command

Terminal Do you want to quickly unplug and install the same thing, mainly on a power wheel, that is connectivity with a Mac? You can do this with a single command by concatenating the two like this:

diskutil unmount /dev/disk1s2; diskutil mount /dev/disk1s2; echo “Volume reinstalled”

It looks like this when run:

$ diskutil unmount / dev / disk1s2; diskutil mount /dev/disk1s2; echo “Volume Remounted” Volume bollyinside Disk1s2 removable volume bollyinside on /dev/disk1s2 Mounted Volume Remounted

If you happen to look at the volume in the Finder during this process, you will notice that it disappears for a moment and then appears almost immediately. The last echo part is optional, but it makes the whole command function even more precise.

Thanks to Nilesh for the tip inspiration

Benefits: Mount & Unmount Drives from the Command Line in Mac OS X

  • Mount & Unmount Drives from the Command Line in Mac OS X is free to read.
  • We help many internet users to follow up interest in a convenient way.
  • Mount & Unmount Drives from the Command Line in Mac OS X is free.

FAQ: Mount & Unmount Drives from the Command Line in Mac OS X

In this guide, I told you about Mount & Unmount Drives from Command Line in Mac OS X.

In this guide, I discuss about Mount & Unmount Drives from Command Line in Mac OS X, which is very helpful.

Apple devices only.

mac OS or iOS

Final note: Install & Uninstall Drivers from the Command Line in Mac OS X

If you have any question regarding the Mount & Unmount Drives from Command Line in Mac OS X, then ask us via the comment section below or contact us directly.
Education: This guide or tutorial is for educational purposes only.
Misrepresentation: If you want to correct any incorrect information about the “Mount & Unmount Drives from the Command Line in Mac OS X” guide, kindly contact us.
Trying to add an alternate method: If anyone wants to add more methods to Mount & Unmount Drives from Command Line in Mac OS X guide, kindly contact us.
Our Contact: Kindly use our contact page for any help.

Leave a Comment