1

I have a USB drive containing 2 FAT partitions which are automatically mounted when the drive is plugged in. If I run diskutil unmounDisk <device> and then diskutil mountDisk <device> I'd expect to be back on the initial state.

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:          Apple_CoreStorage Macintosh HD            250.1 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1 (internal, virtual):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                  Apple_HFS Macintosh HD           +249.8 GB   disk1
                                 Logical Volume on disk0s2
                                 DCD23031-6322-4269-A142-CD36C8FD95D7
                                 Unlocked Encrypted
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.8 GB     disk2
   1:             Windows_FAT_32 flash-boot              1.7 GB     disk2s1
   2:                      Linux                         197.1 MB   disk2s2
   3:                      Linux                         197.1 MB   disk2s3
   4:             Windows_FAT_32 flash-conf              21.0 MB    disk2s5
   5:                      Linux                         4.2 MB     disk2s6

See /dev/disk2. The two FAT partitions are currently mounted:

$ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk2s5 on /Volumes/flash-conf (msdos, local, nodev, nosuid, noowners)
/dev/disk2s1 on /Volumes/flash-boot (msdos, local, nodev, nosuid, noowners)

Now lets unmount:

$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk2 was successful

The partitions were indeed unmounted:

$ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, no browse)

Now lets try mounting back:

$ diskutil mountDisk /dev/disk2
Volume(s) mounted successfully

The operation succeeds, according to diskutil, but the partitions are still not mounted:

$ mount
/dev/disk1 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)

Is this the expected behaviour? If so, what's the correct way of mounting a disk back again?


I'm on OS X 10.11.3.


EDIT 1: fdisk output:

$ sudo fdisk /dev/disk2
Password:
Disk: /dev/disk2        geometry: 951/255/63 [15280192 sectors]
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
*1: 0C   64   0   1 - 1023   3  32 [      8192 -    3276800] Win95 FAT32L
 2: 83 1023   3  32 - 1023   3  32 [   3284992 -     385024] Linux files*
 3: 83 1023   3  32 - 1023   3  32 [   3670016 -     385024] Linux files*
 4: 0F 1023   3  32 - 1023   3  32 [   4055040 -      65536] Extended LBA
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 0C 1023   3  32 - 1023   3  32 [   4063232 -      40960] Win95 FAT32L
 2: 05 1023   3  32 - 1023   3  32 [   4112256 -       8320] Extended DOS
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused
Signature: 0xAA55
         Starting       Ending
 #: id  cyl  hd sec -  cyl  hd sec [     start -       size]
------------------------------------------------------------------------
 1: 83 1023   3  32 - 1023   3  32 [   4112384 -       8192] Linux files*
 2: 00    0   0   0 -    0   0   0 [         0 -          0] unused
 3: 00    0   0   0 -    0   0   0 [         0 -          0] unused
 4: 00    0   0   0 -    0   0   0 [         0 -          0] unused
  • My first thought was to try to recreate your external drive. Immediately, I realized this can not be done, since your MBR partitioned external disk has 6 partitions. Since the MBR partitioning scheme table can only contain 4 entries, some these partitions must be defined in extended boot records (EBRs). To view the EBRs, you would need to update your question with the output from the command sudo fdisk /dev/disk2. – David Anderson Mar 23 '16 at 19:04
  • @DavidAnderson I've edited the question with the output. – jviotti Mar 23 '16 at 19:11
  • @klanomath The image is a Resin.io (resin.io) Intel NUC image. You can register, create a NUC application and download the image from there. – jviotti Mar 24 '16 at 1:31
1

Though I can't verify this, I think the problem is related to the nodev flag of the partitions. In theory the nodev flag doesn't allow a non-root user to create a device node like /dev/disk2s5. So you have to prepend sudo to remount the mountable partitions of the disk.

The following should work:

  • Create mount points: mkdir mnt1 and mkdir mnt2
  • Mount the partitions

    sudo mount -t msdos /dev/disk2s1 ~/mnt1 
    #and respectively for the 2nd partition
    sudo mount -t msdos /dev/disk2s5 ~/mnt2
    

Rechecked with a real thumb drive:

Simply use:

sudo diskutil mountDisk /dev/disk2

instead of diskutil mountDisk /dev/disk2

  • Manually mounting the partitions work, however this is being used in an application where I'm interested in auto-mounting whatever is mountable (according to OS X) automatically. I might be able to scan the drive for FAT partitions and trigger a mount on those, but I have to specify the mount directory (the suggestions from the end doesn't work), and it doesn't cover other partition types that I might have to handle. – jviotti Mar 24 '16 at 1:37
  • @jviotti Updated answer – klanomath Mar 24 '16 at 2:42
  • Adding sudo also works on my machine. @jviotti: Do you have to use a MBR partitioning scheme? A scheme using a GUID Partition Table (GPT) would probably eliminate this problem. – David Anderson Mar 24 '16 at 5:16
  • Sadly I don't have control over the scheme. Turns out sudo diskutil mountDisk /dev/disk2 works fine! – jviotti Mar 24 '16 at 15:22
1

Basically, the diskutil command does not like partitions with the id of 0C and, therefore, will not mount them.

Here is the test I preformed.

  1. Using Yosemite OS X 10.10.5, I partitioned a 4 GB flash drive using a MBR scheme to have 5 equal sized FAT formatted partitions. This function is no longer permitted under El Capitan.
  2. Removed flash drive, inserted flash drive, unmounted disk using diskutil, and mounted disk using diskutil. Everything works fine. No problems.
  3. Boot to El Capitan OS X 10.11.4.
  4. Removed flash drive, inserted flash drive, unmounted disk using diskutil, and mounted disk using diskutil. Everything works fine. No problems.

One difference I did note. Your fdisk output shows the id for the FAT formatted partitions as 0C. Yosemite created these partitions, on my Mac, using the id of 0B. I used the fdisk command to change the id of the first partition to 0C. Now when I unmount and mount the flash drive using the diskutil command, the first partition does not mount. The remaining 4 do.

Ironically, if I use the command

diskutil mount /dev/disk1s1

the first partition, on the flash drive, mounts. (On my computer, I am not using core storage, therefore, the flash drive is disk1.)

  • Great discovery. According to win.tue.nl/~aeb/partitions/partition_types-1.html, 0C represents "WIN95 OSR2 FAT32, LBA-mapped" and 0B represents WIN95 OSR2 FAT32. Doing diskutil mount on the specific partitions works. I'm looking forward to integrate this into an application to auto-mount whatever is mountable. A good enough solution, albeit hacky, would be to iterate through available partitions and call diskutil mount <partition> ignoring the exit code. – jviotti Mar 24 '16 at 1:41
  • My experience with Windows is that it will often ignore the partition id. Instead, Windows will look directly into a partition and try to identify the file system. If windows recognizes a FAT or NTFS volume, it will mount the partition. I realize you are using OS X here, but I thought I would mention this anyway. – David Anderson Mar 24 '16 at 5:33

You must log in to answer this question.

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