Accessing second disk drive from command line

Asked by Rosencrantz Cardwell

I have two disk drives, one, which I boot from, /dev/sda1 and another /dev/sdb1. The /dev/sdb1 name is "Original Drive", which is what I named it when I mounted it.

I can read and write to the drive from the Graphical User Interface, i.e. cut, past, drag and drop. But, when I open up a terminal session, I can't seem to get to it via cd, or the like. What I would like to do is work from the second disk is to say, compile simple c programs via the command line, i.e. gcc simple.c, and so fourth. Is there a way to work from the second drive, in other words change my working directory to the /dev/sdb1 or "Original Drive"?

Sincerely,

Rosencrantz

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu bash Edit question
Assignee:
No assignee Edit question
Solved by:
Eliah Kagan
Solved:
Last query:
Last reply:
Revision history for this message
Best Eliah Kagan (degeneracypressure) said :
#1

If the drive is mounted (accessing it in Nautilus, the file browser, will automatically mount it if it's not mounted already), you should be able to access it from the command line as '/media/Original Drive'. You could cd do it with:

cd '/media/Original Drive'

Or with:

cd "/media/Original Drive"

Or with:

cd /media/Original\ Drive

You could not cd to it with

cd /media/Original Drive

because only the text "/media/Original" would be passed as the first argument of the cd command.

If it's not mounted, then to mount it on the command line in the same way that it gets automatically mounted from the graphical user interface, you can run the command:

udisks --mount /dev/sdb1

That will automatically create the mount point (/media/Original Drive). When it is unmounted, the mount point will be removed.

To unmount it after it has been mounted that way or from Nautilus (though you probably will not need to manually unmount it), you can run:

udisks --unmount /dev/sdb1

To look at all your drives and see what's mounted and how it can be accessed, run the one-word command:

mount

You can pipe the output of mount to grep, if you're only interested in one drive. For example, this command will display nothing if /dev/sdb1 is not mounted, and it will display just the line about /dev/sdb1 if it is mounted:

mount | grep /dev/sdb1

For more information, you can read the manual pages for these commands. For example, you could read the manual page for the udisks command by running the command:

man udisks

And you could read the manual page for the man command itself by running:

man man

If you're viewing a manual page and you want to stop viewing it, press q. If that doesn't work, press Escape a few times and then press q. Everything else about man can be figured out easily or learned from its own manual page.

Manual pages can also be viewed online, if you prefer:
http://manpages.ubuntu.com/

And they can be viewed in Yelp (Ubuntu's help viewer), though there have occasionally been some bugs relating to the way they are displayed.

Revision history for this message
Rosencrantz Cardwell (cardwell6718) said :
#2

Thanks Eliah Kagan, that solved my question.