1

I have a compiled arch kernel. As there are some files in the /root, the user has enabled usb mounting. as dmesg shows it identifies two usbs. one is plugged to keyboard.

I tried these commands, but they mounted folder is not my usb:

mount -t auto /dev/sdb2 /mnt/media
mount -t auto /dev/sda2 /mnt/media

in /dev I cannot see anything except

sda
sda1 
sda2
sdb
sdb1
sdb2

what should I do to get my usb mounted?

update: I am trying to mount the device on sdb1 and sdaxx, but it only mounts /root filesystem into /mnt/media. I also changed the format type of usb to ext4 as this is the only filesystem module loaded into the kernel.

still not result.

7
  • if you re-plugin your USB drive, can you tail /var/log/message to identify exactly where is it mounting (ie sda,sdb)
    – Raza
    Commented Jun 1, 2013 at 6:46
  • negative, in arch linux there is not messages inside /var/log. what I see is btmp faillog journal lastlog old pacman.log wtmp
    – Sam
    Commented Jun 1, 2013 at 6:50
  • you have already tried "mount -t vfat /dev/sdb2 /mnt/usbdisk" or "mount -t vfat /dev/sdb1 /mnt/usbdisk" ?
    – Raza
    Commented Jun 1, 2013 at 7:07
  • yes, I also changed usb filesystem format to ext4, but still cannot loads it. it instead load /root filesystem with sdb1 and sda1/2.
    – Sam
    Commented Jun 1, 2013 at 7:10
  • can you try to boot without your drive run dmesg to see which disk are pick-up and then plug in your drive and run dmesg again to identify exactly which one is your usb disk.
    – Raza
    Commented Jun 1, 2013 at 7:20

1 Answer 1

2

There are two ways to mount a USB or external device like a hard drive on Unix/Linux based systems. I will explain the manual mounting so you can understand better.

Plug in the flash drive into one of the USB ports on your computer.

Open a terminal window and become the "root" user.

To become the root user, type in the following commands:

jason@linux:~> su
Password:
linux:/home/jason #

After you've become root, enter the following command into the same terminal window to see if your computer has recognized the flash drive you plugged in.

linux:/home/jason # lsusb
Bus 002 Device 003: ID 08ec:0010 M-Systems Flash Disk Pioneers DiskOnKey
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
linux:/home/jason #

This information tells me that the system recognized one USB device named "M-Systems Flash Disk Pioneers DiskOnKey" That is good. Yours will most likely have a different name, so look for the name of your flash disk's manufacturer in the output.

NOTE: My system only has one USB device plugged in. If you have multiple devices plugged in, it will recognize them as well as your flash device, so your output will most likely look very differently than mine.

After successful recognition of your USB drive, you'll want to create a directory where your USB drive will be mounted. I entered the following commands into the same terminal window to do this.

linux:/home/jason # cd Desktop/
linux:/home/jason/Desktop # mkdir flash
linux:/home/jason/Desktop #
  • The cd Desktop command tells the computer to go into the Desktop directory (this is where I want to make the directory, so I can access the flash drive directly from my Desktop).
  • The mkdir flash command makes a directory named "flash" which we're going to use to mount the flash drive.

We need to get the appropriate device which is attached to your flash drive. To do this, simply issue the following command in the same terminal window.

dmesg | grep -i "SCSI device"

linux:/home/jason/Desktop # dmesg | grep -i "SCSI device"
SCSI device sda: 31520 512-byte hdwr sectors (16 MB)
SCSI device sda: 31520 512-byte hdwr sectors (16 MB)
SCSI device sda: 31520 512-byte hdwr sectors (16 MB)
linux:/home/jason/Desktop #

As you can see, there are three lines of output, but they are all the same. The information we're interested in is the output immediately after "SCSI device". On my machine it's sda.

This is the device we're looking for. On most machines this will be the case. If you've got a newer machine with a SATA drive or a SCSI drive in it, the output will most likely be quite different. The words you'll be looking for will probably be sdb or sdc. To make sure you select the correct device, simply look for some information that describes your flash drive. For example, my flash drive has 16 megabytes of storage on it. On the output, the words (16 MB) would be a good indicator of that being my flash drive.

When you've found the correct device (sda, sdb, sdc, etc.) enter the following command into the same terminal window:

linux:/home/jason/Desktop # pwd
/home/jason/Desktop
linux:/home/jason/Desktop # mount -t vfat -o uid=jason,gid=users /dev/sda /home/jason/Desktop/flash
linux:/home/jason/Desktop #
  • pwd is used to see where the path is to your Desktop, so we can accurately mount the flash drive. You'll use the line after it later.
  • The next command is the command to mount your flash drive to the flash directory. Let's break that down so we can understand it.
    • mount is the command used.
    • -t vfat tells the command to mount the "vfat" filesystem (which most flash drives are).
    • -o uid=jason,gid=users makes the mount accessible by the "jason" user. You'll want to change this to the user with which you use to log in. Example: if you use the username "jhamilton" to log in, you'd use -o uid=jhamilton,gid=users instead.
    • /dev/sda points to the correct device. Make sure you use the same device you found earlier. Example: If you found your correct device to be "sdc" earlier, you'd use /dev/sdc instead.
    • /home/jason/Desktop/flash is the directory to which you want the device to be mounted. You'll want to use the results of the pwd command here. Example: If the line after the pwd command was /home/jhamilton/Desktop you'd use /home/jhamilton/Desktop/flash instead.

Your flash drive is now mounted and ready to use. If you followed the instructions exactly, there is a new folder on your desktop named "flash" which can be used to put files, images, music, or anything else you want!

3
  • Nice explanation about the process - one thing missing though: if the drive is partitioned (this is quite common), then it's not the device itself but one of the partitions that needs to be mounted. Looks like the OP is having difficulties that could simply be related to that.
    – Mat
    Commented Jun 1, 2013 at 14:44
  • @Mat yes considering the fact that unix systems don't consider partitons the way as windows system do.this maybe the case the OP is having difficulties.If this is the condition than the OP should try to format the drive in one partition and see if the system detects it correct.also try to use different ports.
    – ChangMing
    Commented Jun 1, 2013 at 15:29
  • btw i just mounted a Sony 500Gb external drive which has three partitions but my system is showing it as a whole without any partitions and the files are accessible from any partition.this maybe due to unix/linux directory structure.
    – ChangMing
    Commented Jun 1, 2013 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .