Ubuntu – In terminal, what is the path of the HDDs

command linehard drive

I have 2 * 500-GB HDDs.
What is the path for each of the disks?
On OSX I can just do:

$ cd /Volumes/DiskName/FooDirectory

How can I do that on Ubuntu? How can I navigate to files in a HDD using a terminal? /dev and /dev/disk are not making sense to me.

Best Answer

On OS X those would be the mount points. Under Ubuntu you would want to look at /media/USERNAME/ for those. Though if the volume has not been mounted you could look at /dev/disk/by-label.

If the drives are paritioned and formatted, then you can navigate to them by doing something like cd /media/USERNAME/LABEL where USERNAME is your user name and LABEL is the label for the partition.

If your drives haven't been formatted, then you wouldn't see them in either location and you would instead want to look for /dev/sd[a-z]. That is, you'd have an entry like /dev/sda and /dev/sdb. If they are partitioned, then you should also see /dev/sda[0-9] and /dev/sdb[0-9] (for example, /dev/sda1.) But you'd have to at least format them before you can mount them and navigate to them...

If you haven't mounted the volumes, you can do it through nautilus by just clicking on the volume name. Or from the terminal you can use udisksctl. For example, I have a drive that is partitioned with just one file system. The label of the drive is "d_extra". I can view it in /dev/disk/by-label:

$ ls -l /dev/disk/by-label
lrwxrwxrwx 1 root root 10 Jul 17 15:34 d_extra -> ../../sdb1

Then, once I know the name, I can mount it via udisksctl like so:

$ udisksctl mount -o noatime -b /dev/disk/by-label/d_extra

Then I can cd to it and view files:

$ cd /media/stephen/d_extra
$ ls
Related Question