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 [2001][scott@desk:~]$
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 [2020][scott@desk:~]$
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:
- cat /proc/partitions – find the partition of your USB stick
- make a mount point (perhaps in /media) to which you will mount the USB stick
- for user accessibility, edit your /etc/fstab file
- 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.
Source: http://www.suseblog.com by Scott Morris