OpenSUSE Linux Rants

OpenSUSE Linux Tips, tricks, how-tos, opinions, and news

My Resume  -  My LinkedIn Profile

April 25, 2007

Mounting USB Partition in openSUSE Linux

by @ 6:46 am. Filed under General Linux, General SUSE, How-To, SUSE Tips & Tricks

Once upon a time, I wrote a short tip on how to quickly and easily mount a USB stick, pen drive, jump drive, card reader or whatever from a command prompt in openSUSE Linux. There was just a slight problem (or two) with the way I suggested doing this. One such issue is that when you go to access the drive as a regular user, it is read-only.

In most cases, when you put a USB stick into your USB port on a machine running openSUSE, a window will appear asking what you’d like to do. This is done by the Hardware Abstraction Layer service running in the background.

However, what about cases where you need to manually mount a USB stick? For example, if you have a custom-compiled kernel module that you need to load off a USB stick during installation, what do you do? HAL ain’t gonna save your bacon. You’ll want to know how to get the USB stuff up and cracking very quickly with minimal fooling around.

This is a quick re-write of my last tip, except that it is easier for users with regular accounts to work with the USB stick.

In your /proc directory, there is a file called partitions. To see which partitions are available to the system at any given time, you can do cat /proc/partition at a terminal. With no USB sticks plugged in, mine looks like this:

[2001][scott@desk:~]$ cat /proc/partitions
major minor  #blocks  name

   3     0  195360984 hda
   3     1      40131 hda1
   3     2    1959930 hda2
   3     3   29302560 hda3
   3     4  164055780 hda4

Now, when I plug in a USB stick (or card reader with a card inserted), this is what I get:

[2001][scott@desk:~]$ cat /proc/partitions
major minor  #blocks  name

   3     0  195360984 hda
   3     1      40131 hda1
   3     2    1959930 hda2
   3     3   29302560 hda3
   3     4  164055780 hda4
   8     0     124048 sda
   8     1     123888 sda1

You can see that sda and sda1 were added. sda refers to the drive. It’s the sda1 that we care about. Just add /dev/ to the front of that to get the partition we want to mount. Our partition is /dev/sda1.

Next, we just pick a place to mount it to. As su I just create a directory called /media/usbstick or something similar. Then, you run your mount command as su with this syntax:

mount -t [filesystem type] [usb stick partition] [target mount point] -o rw,nosuid,nodev,noatime,uid=1000,utf8,shortname=lower

If I were mounting the USB stick as /dev/sda1 onto the mount point /media/usbstick, this command would look like this:

mount -t vfat /dev/sda1 /media/usbstick -o rw,nosuid,nodev,noatime,uid=1000,utf8,shortname=lower

In most cases, vfat for the filesystem type for a USB stick should work just fine (unless you know it to be something else).

After you run this command, you should be in business. You can open a terminal as your regular user and change and modify the USB partition with minimal trouble.

If you wish to have this USB partition mounted automatically, you can edit your /etc/fstab file to do this.

As su, open your /etc/fstab file in your favorite text editor. Add a line, with this syntax:

[usb stick partition]            [target mount point]      auto       auto,user

If using /dev/sda1 as my usb stick partition and /media/usbstick as my target mount point, I would put this into my fstab:

/dev/sda1            /media/usbstick      auto       auto,user

The only thing you really need to know about this is that it makes it so that regular users can mount the USB stick. Of course, the user who mounts it is considered as the owner of the partition and its files (at least in the case of the USB stick).

Save your file and exit. Then, to mount it, just run the following command (as a normal user, even):

mount /media/usbstick

You will then notice that your user has full access to the USB stick.

To Review:

  1. cat /proc/partitions – find the partition of your USB stick
  2. make a mount point (perhaps in /media) to which you will mount the USB stick
  3. for user accessibility, edit your /etc/fstab file
  4. mount the usb stick

Most of the time, when you plug in a USB stick or card reader (with a card in it), SUSE will just pop open a window asking you if you want to see the contents of the device. However, in cases where that does not happen, or you are using a distribution that doesn’t do that, this is one way to mount a USB partition.

5 Responses to “Mounting USB Partition in openSUSE Linux”

  1. EqualTime Says:

    Or, you could just plug your USB device into a windows machine, which would automatically mount it and give it a drive letter without all the command line voodoo.

    I’m a linux admin myself, and I love linux in general. However, I see the value in “easy to use” solutions. Many of your rants dive deeply into the realm of things that, while possible, are far more trouble than they should be. Sure, windows isn’t perfect. It does things that make me want to poke the eyes out of both myself and any innocent bystanders in the area. However, so does Linux. This article is a prime example of something that should be transparent and automatic.

  2. Scott Morris Says:

    I dig what you are saying. openSUSE does provide the same functionality you attribute to Windows. You plug it in and it comes right up and just works. Had you read the details of the article, you’d see that this is a tip/trick for times when you may not have that functionality available. I had to mount a USB stick during installation once, and used this type of method. Can you even mount a USB stick during a Windows install?

  3. EqualTime Says:

    Ah, I see your point. I admit I only had time to skim the article before now. That does sound handy.

    You know, I’ve never even *tried* to mount one during a Windows install. I would imagine that’s one of those eye-poking situations. 🙂

    I really do like your articles and your Intro guides. You obviously know your stuff ! Keep at it – maybe eventually we can have a MS-free world (or at least encourage them to be less stupid about things.)

  4. Scott Morris Says:

    Yeah, little things like that can be quite useful when those oddball situations pop up.

    Heh, eye-poking indeed. Seriously, it’s not that you need to do it all the time, often, or even sometimes. It’s just that one time that will save your job that counts.

    Thanks for stopping by and posting your thoughts.

  5. Duncan Says:

    Give a look to (mounting from scripts)

OpenSUSE Linux Rants
Official OpenSUSE Linux Site

internal links:


SUSE Resources

search blog:


February 2018
« Mar    

55 queries. 1.064 seconds