LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-13-2022, 05:56 AM   #1
Greyham
LQ Newbie
 
Registered: May 2022
Posts: 1

Rep: Reputation: 0
USB mounting and unmounting


I unplugged my USB memory-stick from my laptop computer and now cannot get the computer to recognise and read any peripherals such as a USB printer or a USB data files. As an ignoramus in Linux, what commands do I have to enter to mount a USB device and how should I unmount it before unolugging it?
 
Old 05-13-2022, 07:02 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Greyham View Post
I unplugged my USB memory-stick from my laptop computer and now cannot get the computer to recognise and read any peripherals such as a USB printer or a USB data files. As an ignoramus in Linux, what commands do I have to enter to mount a USB device and how should I unmount it before unolugging it?
You don't tell us what version/distro of Linux you're using, but many Linux desktop environments have an applet where you can mount/unmount with a mouse click.

To mount a device (assuming it's /dev/sdb1 for example), would be "sudo mount /dev/sdb1 /some/folder"
To unmount, "sudo umount /some/folder"
 
Old 05-13-2022, 07:18 AM   #3
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
Hey Greyham,

Welcome to LinuxQuestions.

If you're coming to Linux from Windows, mounting and unmounting file systems can be one of the little surprises ... Windows does it for you, Linux *sometimes* does it the same way (it depends on how you've installed and configured your system).

To keep this short, however, and to address your actual question, the proper command to mount a "USB drive" depends on the file system you have on the drive. That's because you actually mount a file system, not a device. This may seem non-intuitive, but once you learn a little more about Linux, it makes sense.

So first of all, you need to know the block devices / UUIDs and file systems on your USB drive. The easiest way I know is to use the following command :

Code:
lsblk -f
This will give you a list of the various block devices / UUIDs on your system, the file systems on them and, if they are mounted, their mount points.

The concept of the mount point is sometimes difficult for new Linux users. It is simply an empty directory that, after mounting, will let you access the file system on a block device. Think of it as a "window" to your USB drive, in your case.

So, you will need an empty directory to mount your file system. I typically create some of these under the "mnt" directory in my own home directory. So, for example, if I were to create an empty mount point directory called "USB1", it would be at /home/rick/mnt/USB1 (you can create more of these as needed). I prefer a mount point in my home directory because I find it simplifies permissions (a whole other area of learning ;-) ...).

So now that you know the block device names / UUIDs and file systems on your USB drive and you have a mount point created, I'll give you an example of a mount command.

Code:
sudo mount -o <options> UUID=<uuid of block device containing the file system you wish to mount> <full path of directory to which you wish to mount the file system>
Note: you can also mount by specifying the block device name (usually something like "/dev/sd__") - I prefer UUIDs because they change less often.

Depending on the file system on your USB drive and what is installed or not on your system, you may need to provide file system options in your mount command (this is why we wanted to know the file system type on your drive). Also, you may need to provide permission options. I won't go into these here - you can find them with the manual command :

Code:
man mount
Hope this helps - let us know if you need further assistance.

Cheers.

Rick

*EDIT* : just noticed that I posted this at the same time as TB0ne provided an answer. Just consider this a more long-winded version of TB0ne's answer ... ;-) ...

Last edited by Rickkkk; 05-13-2022 at 07:21 AM.
 
1 members found this post helpful.
Old 05-13-2022, 07:54 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,637

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Rickkkk View Post
If you're coming to Linux from Windows, mounting and unmounting file systems can be one of the little surprises ... Windows does it for you, Linux *sometimes* does it the same way (it depends on how you've installed and configured your system).
I (slightly) disagree. Windows may 'mount' the stick automatically, but won't unmount it without a manual step.
Quote:
So first of all, you need to know the block devices / UUIDs and file systems on your USB drive. The easiest way I know is to use the following command :
Code:
lsblk -f
This will give you a list of the various block devices / UUIDs on your system, the file systems on them and, if they are mounted, their mount points.

The concept of the mount point is sometimes difficult for new Linux users. It is simply an empty directory that, after mounting, will let you access the file system on a block device. Think of it as a "window" to your USB drive, in your case.
The two methods I prefer (which I think are less confusing, especially for a new user), would be either:
  • Run "sudo dmesg -c", plug in the USB stick, and run "dmesg" again. Should show up as /dev/sdxxxx
  • Run "ls /dev/sd*", plug in the USB stick, and run it again...should see the new device(s) show up pretty clearly.
And Greyham, Rickkkk is correct in that a mount-point is nothing but a directory/folder. But as a warning, that directory CAN have something in it...and if you mount a device to it, you won't see the original data while the device is mounted.

If you have a home directory of "/home/user1", and it has a bunch of files in it you'll see them if you do an "ls /home/user1". But if you run "sudo mount /dev/sdb1 /home/user1" and run that same ls command...you will see the files from the USB stick. You will NOT be able to access the original data in /home/user1 while the USB stick is mounted, so use caution.

I use KDE, and have a removable-drive applet in my system tray. Pops up a message when I plug in a mountable device, and I can mount/dismount from there. And on openSUSE Tumbleweed, it will mount devices under /run/media/ to make things simple and safer.
 
1 members found this post helpful.
Old 05-13-2022, 01:40 PM   #5
Debian6to11
Member
 
Registered: Jan 2022
Location: Limassol, Cyprus
Distribution: Debian
Posts: 382
Blog Entries: 1

Rep: Reputation: 71
The easiest way to mount external drives, including USB sticks, is to label the file system with a tool like GParted, where the drives can be mounted at /media/user/label by a file manager.

It is good practice to learn the mount, umount and lsblk commands, in case you do not want to set a label for any reasons.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unmounting all nfs filesystems without unmounting local ones kaplan71 Linux - General 1 03-05-2009 11:00 AM
mounting and unmounting USB drives Ian D Linux - Software 3 10-15-2005 02:45 PM
How to use a USB Flash Key with out mounting and unmounting it! zparihar Linux - General 5 08-20-2005 11:56 AM
Need help identifying and mounting/unmounting USB drive. calathar Linux - Newbie 2 05-01-2005 03:50 AM
External USB drive mounting/unmounting nsk078 Linux - Hardware 1 09-22-2004 05:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration