Flash Drive not mounted on macOS Mojave I have a flash drive which was formatted on Mac using the Disk Utility. But when I'm trying to replug the drive it shows up in disk utility but says Not Mounted. 
I'm unable to erase as it says

Unmounting disk
Erasing
Couldn't open device.
Operation failed...


It is not visible in the finder.

I also have tried formatting it from terminal using 

diskutil eraseDisk free EMPTY /dev/disk2


but this stops with following error:

Started erase on disk2
Unmounting disk
Creating the partition map
Error: -69877: Couldn't open device


Also have tried this link but it also failed with error:

Started partitioning on disk2
Unmounting disk
Creating the partition map
Error: -69877: Couldn't open device
(Is a disk in use by a storage system such as AppleRAID, CoreStorage, or APFS?)


After an exhausted online search and trials I'm posting here.

Thanks in Advance
I was able to fix this by changing the Micro SD adapter into another one and then unlocking the security switch in the sd adapter. That error occurs whenthere is a physical write protect switch on the drive, and it's locked in that position.