1

I'm running Ubuntu 14.10 Server (headless).

I have a group of USB flashdrives that I need to reformat for use across several devices. I've successfully mounted, formatted, copied files to, and unmounted three devices. Upon mounting the forth the system believes that the first partition of this drive has already been mounted; it has never been inserted into the server before. I cannot mount or unmount the partition at all. At this point I'm assuming that this is my fault somewhere along the way but I can't get things back to normal.


The Devices

The USB drives are to be formatted with two partitions and an empty 8MB header. The table is required as they will be used for specialized equipment. Each device is roughly 2GB in size

USB Partition table (to-be): [-EMPTY 8MB-|-- >1.1GB FAT 16--|--751MB FAT16--]

The USB devices will have, at the very least, one pre-formatted partition of either Ext4 or Fat16.

The Situation

I've inserted a new USB device. Attempting to mount the device fails:

$ sudo mount sdb1
  mount: can't find sdb1 in /etc/fstab
$ ls /media                   # Mounting a partition defaults to here
  <empty>
$ pmount sdb1
  Error: device /dev/sdb1 is already mounted to /media/sdb1
$ ls /media
  <empty>

df does not display /dev/sdb1 at all

Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/sda2      944392620 35959148 860437980   5% /
none                   4        0         4   0% /sys/fs/cgroup
udev             8183068        4   8183064   1% /dev
tmpfs            1638852     5640   1633212   1% /run
none                5120        0      5120   0% /run/lock
none             8194244        0   8194244   0% /run/shm
none              102400        4    102396   1% /run/user
/dev/sda1         523248     3436    519812   1% /boot/efi

fdisk displays the device correctly

Disk /dev/sdb: 1.9 GiB, 1993342976 bytes, 3893248 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5651d77f

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1          2048 2353151 2351104  1.1G 83 Linux
/dev/sdb2       2353152 3893247 1540096  752M  6 FAT16

GParted will display the device correctly (size, partition(s), table, etc.) but shows that sdb1 is mounted. I can delete the partition, format to ext4, however I cannot format it to Fat16.

I can, however, mount sdb2 via pmount and view any files that exist. Unmounting, partitioning, and erasing it is always successful. If I insert additional devices (e.g. sdc) I can make any changes without issue. If I swap this device so that it is sdc instead of sdb I can still access it without any problems.

I'm assuming that I've goofed up and did not unmount properly sdb1 on a previous device which is causing this problem. I'm also assuming that mkfs.vfat is also experiencing issues because mkfs.ext3,mkfs.ext4 will run without errors.

Is there a way to recover from this problem? Would my (only) solution be to reboot the system? I'm hoping to avoid this because we have multiple data-fetching and data-hosting services up and running.


Solution

Many thanks to steve for his simple solution. Of all my searches I did not happen to come across this.

If df, fdisk -l, umount -l, pumount do not work then you should check /etc/mtab next. This file had the following contents:

/dev/sda2 / ext4 rw,errors=remount-ro 0 0
proc /proc proc rw,nodev,noexec,nosuid 0 0
sysfs /sys sysfs rw,nodev,noexec,nosuid 0 0
none /sys/fs/cgroup tmpfs rw,uid=0,gid=0,mode=0755,size=1024 0 0
. . .
systemd /sys/fs/cgroup/systemd cgroup rw,nosuid,noexec,nodev,none,name=systemd 0 0
/dev/sdb1 /media/sdb1 ext4 rw,nodev,nosuid,noexec,errors=remount-ro,user 0 0

That very last line was the source of the issue. Simply removing it fixed everything.

Please try using other guides/solutions before attempting this. I am not aware of any impact this could have on your system or device if other services are actively attempting to read/write/lock this partition.

1

Try umount -f /media/sdb1 or umount -l /media/sdb1.

If all else fails you can manually edit /etc/mtab to remove the offending mount entry.

  • Thank you for the prompt response. Both commands print an error: umount: /media/sdb1: mountpoint not found. Should I create this directory and try again? (EDIT: creating the directory and attempting to unmount claims that sdb1 is not mounted) – Kamikaze Rusher Jul 28 '15 at 20:53
  • Take a look at /etc/mtab, might need to manually edit it. – steve Jul 28 '15 at 20:56
  • This is at the very end: /dev/sdb1 /media/sdb1 ext4 rw,nodev,nosuid,noexec,errors=remount-ro,user 0 0. Do I need to remove it? – Kamikaze Rusher Jul 28 '15 at 20:59
  • 1
    Ok, commenting that out/removing that line fixed it. I'm assuming that this is an easy fix that I overlooked at some point. If you can change your answer to this I'll check it as my solution – Kamikaze Rusher Jul 28 '15 at 21:07

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.