Write protection (also known as read-only) can be used to ensure that data is not accidentally overwritten or deleted. It prevents files and folders from being changed. This article provides very simple ways to enable write protection for USB | Pen drive, as well as SD cards and other storage devices.
Some USB flash drives and SD cards come with a write-protect switch that protects the drive from being written andfrom malware and viruses. Let's see how to check if there is a lock switch on the USB flash drive and turn it on.
In the USB flash drive, move the switch to the locked position.
In the SD card adapter, lock the switch down to turn on write protection.
A read-only file can be opened and viewed as any other file, but it cannot be written to. Here's how to set a read-only for a USB or Pen drive.
Step 1: Press Win + R to open the Run dialog, then type in diskpart and hit Enter key.
If you receive a UAC prompt asking you to continue, click Yes.
Step 2: In the new command window, type list disk and press Enter.
From the size of the disk, it's easy to find out which one is your removable disk. In this example, I know that Disk 1 is my removable USB flash drive because its size is listed as 14 GB.
Step 3: Run the select disk 1 command to select the disk you want to use and press Enter.
Step 4: Type the attributes disk set readonly and press Enter.
If necessary, you can use the following command to remove write protection.
attributes disk clear readonly