Mount external flash drive read-only on Mac OS X
- April
- 22
This post came about because of the hard time I had hunting down information on the topic. So I'm sharing what I've learned in the hope that others may be helped by it.
I own several Garmin GPS devices and notoriously I will have one dangling from my laptop and it will become unplugged accidentally without properly closing the filesystem and ejecting. I've had a few issues with file corruption on these devices and I decided to eliminate the possibility that these unintentional unplugging events had something to do with it.
I looked around on the net and there were a few utilities which claimed to be able to force read-only mounting of certain drives but I would rather not depend on a software program that has to watch for events like USB insertion in the kernel. It's just one more driver that needs to be upgraded when a new kernel comes out. So I settled on doing it the old-fashioned way.
The first step is to name your drive so you can identify it properly when it's inserted. If every drive you have comes up as "Untitled" it's not going to be easy to detect when a particular drive is on the system. My Garmin Edge 800 comes up as two drives, one named "GARMIN" and one named "NO NAME" which is the micro flash card. I always store my data on the main device leaving the micro flash card for maps only. I also have an Edge 500 which comes up with a single drive named "GARMIN." Recently I purchased the Garmin Virb Elite camera and put a 64 GB micro flash drive in it. It came up as "Untitled" initially but I simply renamed it to VIRB through the GUI and it is still detected properly by the Garmin software so all is well.
Next, you want to modify /etc/fstab as root. Be careful or you can mess up your boot drive and possible render your machine unbootable if you're not careful. But this is simply a text file that tells OS X what to do when a particular volume is mounted. My /etc/fstab was empty so I just added what I needed. One of the parameters you can specify for a mounted drive is whether it is read/write or read-only. That makes it easy to get the system to mount the drives the way we want.
Here is a copy of my fstab with the entries I had to add in. Note that there are tab characters between fields.
# Identifier, mount point, fs type, options
LABEL=GARMIN none msdos ro
LABEL=NO\040NAME none msdos ro
LABEL=VIRB none exfat ro
One thing to note is that the last entry's fs type is exfat. That's not documented anywhere I could find. I had to guess to find the right entry to put there. My Garmin VIRB Elite camera uses a flash card that is formatted EXFAT (64 bit FAT) so that there are no large file problems. The other two devices use normal 16 bit FAT so you use the 'msdos' file type.
Now when you plug in the device you should be able to see it mounting read-only via tha mount command. You'll see your other disk partitions in the output as well.
$ 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)
localhost:/9A5XAFt6LFmeQe3kcbu0RD on /Volumes/MobileBackups (mtmfs, nosuid, read-only, nobrowse)
/dev/disk2s1 on /Volumes/VIRB (exfat, local, nodev, nosuid, read-only, noowners)
Notice the last line fir the Virb camera includes the read-only parameter.
Now this is all neat but what if you want to erase something on the camera or write a file? I normally purge the old activities and videos off and I upload courses to the Garmin Edge 800. That can be accomplished with a script. I wrote one script to set the devices read-write and one to set them back to read-only. That way I can run the script, write a file or erase something and then run the read-only script. There is one caveat though. The Mac GUI doesn't seem to get informed when you unmount and remount the filesystem read-write. So you can't use it to copy files. I just do it from the command line instead, no big deal.
Here is the garmin-rw script:
#!/bin/sh
# garmin-rw.sh
#
if [ -d /Volumes/GARMIN ]; then
DISK=`mount | grep GARMIN | awk '{ print $1 }'`
sudo mount -uw -o nodev,nosuid $DISK /Volumes/GARMIN
fi
DISK=""
if [ -d /Volumes/NO\ NAME ]; then
DISK=`mount | grep "NO NAME" | awk '{ print $1 }'`
sudo mount -uw -o nodev,nosuid $DISK /Volumes/NO\ NAME
fi
DISK=""
if [ -d /Volumes/VIRB ]; then
DISK=`mount | grep "VIRB" | awk '{ print $1 }'`
sudo mount -uw -o nodev,nosuid $DISK /Volumes/VIRB
fi
Here is the garmin-ro script:
#!/bin/sh
# garmin-ro.sh
#
if [ -d /Volumes/GARMIN ]; then
DISK=`mount | grep GARMIN | awk '{ print $1 }'`
sudo mount -ur -o nodev,nosuid $DISK /Volumes/GARMIN
fi
DISK=""
if [ -d /Volumes/NO\ NAME ]; then
DISK=`mount | grep "NO NAME" | awk '{ print $1 }'`
sudo mount -ur -o nodev,nosuid $DISK /Volumes/NO\ NAME
fi
DISK=""
if [ -d /Volumes/VIRB ]; then
DISK=`mount | grep "VIRB" | awk '{ print $1 }'`
sudo mount -ur -o nodev,nosuid $DISK /Volumes/VIRB
fi
For quicker ejecting I also wrote a shell script to eject the drives. Works much better than right clicking on the icon.
#!/bin/sh
# garmin-eject.sh
#
if [ -d /Volumes/GARMIN ]; then
DISK=`mount | grep GARMIN | awk '{ print $1 }'`
sudo umount $DISK
fi
DISK=""
if [ -d /Volumes/NO\ NAME ]; then
DISK=`mount | grep "NO NAME" | awk '{ print $1 }'`
sudo umount $DISK
fi
DISK=""
if [ -d /Volumes/VIRB ]; then
DISK=`mount | grep "VIRB" | awk '{ print $1 }'`
sudo umount $DISK
fi
For the record I am using Mac OS X 10.9.2. I am not sure of the existence of the exfat file system type in other versions.
Chicken Vindaloo - Slow Cooker
- March
- 3
This is a great recipe for spicy chicken dish. There are a bunch of steps but it's really not that bad. Once you've made it once it goes faster the next time. I like it because you can get it going in the morning and you have a finished dish for supper.
Vindaloo is a spicy dish. You can dial back the chili pepper if you can't take the heat but be aware that there are lots of strong spices in the recipe. I like it hot of course!
4 lbs fresh boneless skinless chicken breast cut into 1" pieces
4 Tablespoons safflower oil
3 cups chopped yellow onions
6 Tablespoons white wine vinegar
1/2 cup shredded fresh ginger
20 cloves of fresh garlic
16 dried red chili peppers
1 Tablespoon haldi (turmeric) powder
1 Tablespoon bhania (coriander) powder
1 Tablespoon garam masala
1 teaspoon cinnamon powder
2 teaspoons red chili powder
1 Tablespoon black peppercorns
1 Tablespoon coarse sea salt
1 Tablespoon black mustard seed
Saute the onions in a large fry pan in two tablespoons of the oil until browned. Remove from heat and let them cool a bit. Put them in the food processor and puree into a runny paste. Put the onion paste in the slow cooker. No need to clean out the processor, okay if there are still some onions in there. Next, add the garlic, ginger, chilies, haldi, bhania, garam masala, chili powder and cinnamon to the food processor and process into a paste along with remaining 2 tablespoons of oil. Add this paste to the slow cooker and mix it in with the onion paste.
Use a mortar and pestle or grinder to grind the other whole spices (peppercorns, mustard seed, salt) into a coarse powder. Add to the slow cooker. Add the vinegar in. Add the 1" chicken pieces to the slow cooker and mix so everything is coated. Cook for about 6 hours, chicken will be tender.
Gobi Palak Matar
- March
- 3
The challenge today was to cook some dishes that can be eaten while in the induction phase of the Atkins Diet. I know that spices are generally counted very low in carbohydrates so why not spice it up?
I picked out a few vegetables that are on the list for the induction phase including califlower (gobi), spinach (palak) and peas (matar). The spinach is very low in carbohydrate per serving (0.2), the cauliflower is also low (1.0) and the peas area lot higher (9.9). Anyway, I think the choices balance out for a nutritional dish that has a variety of tastes.
I decided that I like the flavor of ajwain with vegetables. It gives them a very savory flavor especially when combined with bhania (coriander). So I adapted another vegetables recipe that used these ingredients.
2 cups califlower cut into 1" pieces
2 cups fresh spinach leaves
1 cup frozen peas
2 tablespoons safflower oil
4 dried red chili peppers
1 Tablespoon bhania (coriander) powder
1 teaspoon ajwain (carom) seeds
1/2 teaspoon haldi (turmeric)
1 teaspoon salt
1 teaspoon lemon juice
Heat the oil on medium heat in a large fry pan, not too hot. Add the ajwain seeds and let them cook for a few seconds, don't burn them, they are very tiny so keep the heat medium. Add the dried chilies and the haldi and stir for a few more seconds. Add in the peas, cover for a minute and let them defrost. Add the coriander and salt and stir in. Now add the califlower pieces and then put the spinach on top. You can add a tablespoon of water if needed to get some steam going. Cover and let it simmer for a few minutes and the spinach will reduce down as the vegetables begin to cook. Stir every few minutes and cook until vegetables are tender. Add the lemon juice and stir and it's ready to serve.
I calculated 51 grams of carbohydrate in this dish total.
Hari Podina Chutney
- March
- 1
This is a chutney made with cilantro and mint leaves. It has a bright green color. It's great with fried foods like pakoras and samosas. I made a big batch and put some portions in the freezer for later.
4 cups mint leaves (no stems)
4 cups cilantro leaves and small stems
10 thai chilies chopped.
1/2 cup lemon juice
3 Tablespoons minced ginger
1 Tablespoon salt
1 Tablespoon cumin seeds
1 Tablespoon safflower oil
1 Tablespoon sugar
1/8 teaspoon asafetida
Place the cumin seeds in a fry pan or wok on medium high heat and dry roast them for a minute or so. As soon as they turn a darker color remove from heat. Use a mortar and pestle to grind the seeds into a powder. Add the other powdered ingredients to the mortar, salt, sugar and asafetida. Grind some more until thoroughly mixed and powdered.
In a food processor place the lemon juice, oil, ginger and chilies. Process on high until everything is liquified. Add the powdered spices/sugar and blend some more. Liquid will be very thin. Add cilantro and mint leaves a bunch at a time and process on high to reduce volume. Continue adding until all leaves are added. Process until chutney is smooth. A little water may be added if chutney is too thick.
You can freeze this chutney and simply defrost later when you need it. I put some into Ziploc bags and let them freeze. It will also keep in the fridge for several days.
Aloo Gobi with Methi
- February
- 28
This is a tasty dish as a side. It is a dry saute and is very flavorful.
2 heads cauliflower cut into bite size pieces
4 medium potatoes peeled and cut into 1/2" pieces
2 medium onions
4 Tablespoons oil
1 large bunch fresh methi
1-1/2 Tablespoons grated garlic
1-1/2 Tablespoons garlic, chopped very small
2 teaspoons cumin seeds
1 teaspoon garam masala
1 teaspoon red chili powder
1 teaspoon coriander powder
2 Tablespoons sugar
4 thai chilies, chopped
Few sprigs of cilantro leaves for garnish
Pick the methi leaves and small stems and discard the large stems. Place the methi leaves in a collander and rinse well. Then soak the methi leaves in cold water with a the sugar while you get everything else ready.
To cook, heat a large skillet with oil until hot. Add the cumin seeds and cook until they crack (a few seconds). Add the chopped chilies. Then add the garlic and ginger and stir for a few seconds. Next, add the onions. Cook the mixture until onions are soft, about 5-6 minutes. Add the spice powders and stir them in.
Add the cauliflower and potatoes and mix everything together. I use a wide spatula so I can get underneath the veggies and turn them in the skillet without breaking them. You can add a little water to help get the cooking process started if needed. As the vegetables cook they will give off some water. Cover and reduce heat. Cook until vegetables are starting to soften. Drain the methi leaves and add them in. Continue to cook for about 10 to 15 minutes, turning and mixing carefully every few minutes.
When veggies are tender it is ready to serve. Garnish with fresh cilantro leaves.