How Can I list Directories in a Disk using Terminal Command

I've got a number of disks mounted on my Mac. I'd like to run ls in Terminal in on disk7.


I know how to navigate to /Volumes, cd to the right volume and ls, but I don't want to do that. I can get to

/dev and there is a disk7 in it, but when I do cd disk7 I get a message "not a directory"


I'm about to erase/format disk7 and I want to be really really really really sure that it's the right volume before I do so.


Anyone know how to use Terminal to check the contents of disk7 so I'm sure that when I erase it I'm not erasing something important?


Thanks in advance for any help.

MacBook Pro 14″, macOS 14.4

Posted on May 10, 2024 5:45 AM

Reply
9 replies

May 10, 2024 8:18 AM in response to etresoft

Here's my problem

I've got a disc called Malcolm and I need to erase and format it.

I can find Malcolm in Terminal by CDing to /Volumes/Malcolm

When I run Disk Utility there's no disc called Malcom in the LH panel. There are three discs called Apple Disk Image Media". I can use Disc Utility to get info on these discs and it tells me they are diskx (x= 6, 7, 9). I want to erase and format "Malcolm" but I don't know which diskx is Malcolm in Disc Utility. So, I need to find out whether Malcolm is disk6, disk7 or disk9 before I can erase and format. diskutil lists and diskutil info don't help - when I run them there's no diskx listed for the name of the disk ("Malcolm") or for any of the other disks labelled "Apple Disk Image Media" in Disk Utility.


So I need to know which diskx Malcolm is because that's the only useful reference to the disk that I can find in Disk Utility and formatting the wrong disk would be a very bad thing.

May 10, 2024 8:31 AM in response to Zurarczurx

mount


The mount command with no arguments will list the mounted file systems. For example

/dev/disk5s1 on /Volumes/Samsung_SSD_1TB (apfs, local, nodev, nosuid, journaled)

With the device shown first, then the mount point followed by various mount options.


It is also possible to mount disk images, such as .dmg files, such as open Karabiner-Elements-14.12.0.dmg

/dev/disk10s1 on /Volumes/Karabiner-Elements-14.12.0 (hfs, local, nodev, nosuid, read-only, noowners, quarantine, mounted by raharris)

May 10, 2024 8:34 AM in response to Zurarczurx

It's hard to say. Maybe a screen shot would be helpful?


Normally Disk Utility will list all devices, including disk images in the sidebar. File systems can be complicated, so you may have to use the little disclosure arrows to see which disk image contains the "Malcom" volume.


And for all know, this could be a network volume. In that case, it won't appear in Disk Utility.


You can also use the command line tool "mount" to see which devices are associated with which mount points. This command will show all mount points, regardless of physical media.

How Can I list Directories in a Disk using Terminal Command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.