Mounting with sync

Table of Contents

  1. OS X
  2. Linux

This page describes how to configure Linux or OS X to mount the mbed Microcontroller with the 'sync' option, this ensures files copied to the board are written immediately and without having to 'Eject' the drive.

Note: It is not necessary on all systems, but we haven't made up a list yet. Use this if you found you needed to "eject" before the file was properly transfered

OS X

Open a Terminal window and edit (or create) the file /etc/fstab with a text editor such as pico for example with the command:

sudo pico /etc/fstab

Add an entry to the end of the existing fstab file for the mbed device,

LABEL=MBED none msdos rw,sync

Do not change any other entries in /etc/fstab.

Save the updated /etc/fstab then reconnect the mbed board so that the drive is mounted with the new configuration.

Note that you must update the text following LABEL= in fstab if you change the volume label of your mbed board.

Linux

There are several possible ways to achieve this on Linux but the most reliable seems to be to simply add a static entry in fstab. For distributions that use tools like pmount or gnome-mount to automatically mount removable devices you may be able to configure these to get a similar result.

Open a Terminal window (shell) and run mount to get a list of the currently mounted file systems, you should see a entry for the mbed board like this:

/dev/sdb on /media/MBED type vfat (rw,nosuid,nodev,shortname=mixed,uid=1000,utf8,umask=077)

edit /etc/fstab with a text editor such as pico for example with the command:

sudo pico /etc/fstab

Add an entry to the end of the existing fstab file for the mbed device, changing /dev/sdb if necessary.

/dev/sdb /media/MBED vfat rw,user,sync 0 0

Do not change any other entries in /etc/fstab.

Save the updated /etc/fstab then create the mount point with:

sudo mkdir /media/MBED

Reconnect the mbed board so that the drive is mounted with the new configuration.

If you have several removable devices you may find that the mbed board is not always /dev/sdb. If so, you can replace /dev/sdb with a symbolic link from /dev/disk/by-id which uniquely identifies one mbed board using its serial number or create a udev rule to create a persistant name like /dev/mbed1.





8 comments:

08 Oct 2010

Dan

FYI, I had intermittent problems with my mbed but I believe the 'fstab' changes have solved the problem. Previously, the old code would execute after new code was transferred, and sometimes the mbed would hang up and only recover after many power cycles and reset assertions. However, debugging this problem, I noticed that the mbed drive does not have any valid partitions as seen in 'fdisk'. Is that to be expected?

Dave

08 Oct 2010

Dan

Sorry, I didn't mention on my previous comment that I'm running Linux (2.6.18 kernel..)

Dave

17 Oct 2010

Very useful for linux mbedders; before modifying my fstab for autosync I was having unexplainable strange program start errors.

18 Oct 2010

If you don't want to modify your /etc/fstab you can also use: "sudo mount -o remount,rw,user,sync /dev/sdx", worked for me on openSuse 11.3 x86-64 system with a 2.6.34 kernel (replace x with the letter where your mbed is mounted).

The disadvantage is that this is not persistant, you have to redo it each time you reconnect the device.

20 Oct 2010

You can also just run the 'sync' command after writing to the USB disk.

19 Mar 2011

or open a terminal window and execute:

while true;do sync;sleep 1;done

10 May 2012

How would one change the volume label on an mbed?

21 Jul 2012

In Ubuntu 12.04, using the above fstab entry caused by mbed to be mounted as 755 mode (i.e., I had to run sudo to write the mbed binary to the device, as only root could write to it). If Ubuntu tells you that the MBED folder is read-only after adding this entry to your fstab, then you should also add the option "umask=000" to the /etc/fstab options. This will make the fstab entry look like:

/dev/sdb /media/MBED vfat umask=000,rw,user,sync 0 0

Posting new comments for this page has been disabled