2

I am completely unfamiliar with how *nix handles partitions, but I needed to get a file off of my USB drive so I followed an online post that said you could mount a USB stick with:

sudo mount -t auto /dev/sdb1 /mnt

So I did, but now ls /mnt returns the contents of my computer's /home/ directory, and I am afraid to unmount it.

How can I get out of this situation without compromising any data?

Where can I find an accessible explanation of how to mount a usb drive?

4

Evidently you have two hard drives in the machine, and you have a dedicated /home partition on the second one.

What's happened is /dev/sdb1 (which is not your USB drive) is now mounted twice, once on /home and once on /mnt. The only real risk in that is you now also have double the opportunities to, e.g., delete something accidentally. If you are not in the habit of doing such things, then no worries.

How can I get out of this situation without compromising any data?

Just umount /mnt. If you get a "device busy" message, it's because a shell or file browser is open to that location -- change directory in those.

Where can I find an accessible explanation of how to mount a usb drive?

Contemporary linux distributions (and I presume other *nix's) come out of the box with desktop environments that will do automounting, so most newbies don't have to worry much about this stuff.

If for some reason you aren't using an automounter, man mount is a good starting place. Device nodes get assigned in order -- this is why /dev/sdb1 turned out not to be the USB. One way to get a clue about the proper device node would be to look at the various sd files in /dev without the stick in, then add it and look again. If you already have two hard drives, plugging in another (including USB sticks) will probably yield sdc, and sdc1 would be the first partition.

  • Also, mount (without anything else) list all mount points, fdisk -l list all the devices and partitions. – Braiam Aug 9 '13 at 21:19
  • Ah, thanks for the added explanation. It turns out I do have an auto-mounting system, though now it is upset. In nautilus, my USB drive shows up in gray, and says 'failed to mount,' though if I try to unmount it (in nautilus) it says 'writing data to device \n there is data that needs to be written to the device. Please do not remove the device.' Do you have any idea what it would be doing, and if I could remove the drive? – user2669183 Aug 9 '13 at 21:21
  • Actually, it was Thunar (Nautilus doesn't show the drive), but I can't seem to edit my last comment. I tried cosing all open windows. – user2669183 Aug 9 '13 at 21:42
1

Because you've mounted it via a different location than that of /home, you should be able to unmount it without loss of data: umount /mnt. I assume you've not started any processes from /mnt. You can check for open files from that mount point with something like lsof.

Attempting to umount whilst files ARE open from /mnt will give you an error anyway:

umount: unmount of /mnt failed: Device busy

As to finding the correct device for the USB disk:

sudo lshw -class disk

should allow you to find the /dev/sdX device you require.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.