How to avoid a disk or partition from being formatted accidentally? An available way is to make disk or partition read-only. You should also set disk or partition read-only before you share your PC, external hard drive, or USB flash drive with your friends or colleagues.
By doing so, you or someone else can’t only open and read the file available on the hard drive, USB drive, or partition. Then you and others won’t be able to delete or format the data saved on the storage device. Even viruses won’t affect the data. Simply put, you can protect your data by setting read-only attribute for disk partition.
Make Disk or Partition Read-Only
Here comes the question: how to set disk or partition read-only. Diskpart, a built-in utility on Windows PCs, allows you to set read-only attribute for disk partition by running some commands.
Step 1: Open the Run dialog window by holding the Windows and R keys.
Step 2: Type cmd in the Run window and press Ctrl + Shift + Enter keys to run Command Prompt as administrator.
Step 3: In the Command Prompt window, type the following commands and hit Enter after each.
- list disk
- select disk n (replace n with the specific number that stands for the disk/partition to set read-only)
- list partition
- select partition # (replace # with the exact drive letter that represents the partition to set read-only)
- attributes disk clear readonly
To remove read-only status, type “attributes disk clear readonly” and hit Enter. If the command runs smoothly, you will see the message “Disk attributes cleared successfully” soon.
You need to check/release locked file or folder if you want to rename/move/delete it. Here, you can get 3 methods from this post.
Check the Disk or Partition Attributes
If you want to see the attributes of a specific disk, please refer to the steps below.
Step 1: Run Command Prompt as administrator.
Step 2: Type the following commands and hit Enter after each to execute the command.
- list disk
- select disk 2 (replace 2 with the number that stands for the target disk)
- attributes disk
To view the attributes of a partition, you should run these commands in Command Prompt.
- list volume
- select volume # (replace # with the drive letter of the target partition)
- attributes volume
This post explains what Device Portal is and tells you how to enable or disable Device Portal in Windows 11.
How to set disk or partition read-only? This post offers you the detailed steps. You can refer to these steps to make disk or partition read-only. If necessary, check disk or partition attributes with the provided steps in the post.