Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    In the case of don't know the device can write, how to mount device

    In my programe, I need mount hotplug device,for example,U Disk, SD card.
    In the case of don't know the device can write, I use like "mount -w" command to mount the device, the mount will be failed,
    error message:block device /dev/sda1 is write-protected but explicit `-w' flag given.

    I don't know how to know whether the device is readalbe or writable before I mount the device.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Usually, mounting the device without options will figure out if it is readable/writable or whatever and do the right thing. Example, assuming that an sd card is registered as /dev/sdn and it has a partition as /dev/sdn1, and the sd card has its write-protect switch enabled, then then command "mount /dev/sdn1 mountpoint" should 1) detect what file system it uses (probably fat or fat32), 2) determine that it is read-only, and 3) mount it on the mountpoint as a read-only file system that you can read from, but not write to.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts