|
| 1 | +# Hide partitions in windows disk management |
| 2 | +> In Windows, you may want to *hide* some partitions |
| 3 | +> in Windows Disk Manager to prevent damage from Windows, |
| 4 | +> this guide will tell you how to change gpt partition's |
| 5 | +> attribute to mark a partition as **system** partition. |
| 6 | +
|
| 7 | +:::warning |
| 8 | +Please **carefully** read each step and comments. |
| 9 | +**Wrong actions may damage your GPT table and brick your device**. |
| 10 | +::: |
| 11 | + |
| 12 | +## Requirement |
| 13 | +- A phone in Windows or Android/Linux |
| 14 | +- Diskpart in Windows, gdisk in Linux, termux+gdisk+root in android. |
| 15 | + |
| 16 | +## Steps in Windows |
| 17 | +- Open a terminal with administrator permission. |
| 18 | +- Type `diskpart` and enter . |
| 19 | +- List all disks |
| 20 | +```powershell |
| 21 | +lis dis |
| 22 | +``` |
| 23 | +- Choose the disk contains your target partition, use `1` for example here. |
| 24 | +```powershell |
| 25 | +sel dis 1 |
| 26 | +``` |
| 27 | +- List all partitions in this disk |
| 28 | +```powershell |
| 29 | +lis par |
| 30 | +``` |
| 31 | +- Select your target partition, use `1` for example here. |
| 32 | +```powershell |
| 33 | +sel par 1 |
| 34 | +``` |
| 35 | +- Get partition current gpt attribute |
| 36 | +```powershell |
| 37 | +det par |
| 38 | +# Partition 1 |
| 39 | +# Type : d32b7c28-e321-21cc-1122-12acc91ec92b |
| 40 | +# Hide : No |
| 41 | +# Necessary: No |
| 42 | +# Attribute : 0X1C00000000000000 |
| 43 | +# Bytes Offset: 1234 |
| 44 | +``` |
| 45 | +- Set *system bit* in partition gpt attribute. |
| 46 | + + system bit is the lowest bit. |
| 47 | +:::warning |
| 48 | +Please *ONLY* set the last bit to 1. |
| 49 | +::: |
| 50 | +```powershell |
| 51 | +GPT ATTRIBUTES=0x1C00000000000001 |
| 52 | +``` |
| 53 | +- Set system bit for all partitions in a lun can make the lun invisible in Windows device manager. |
| 54 | + |
| 55 | +## Steps in Android/Linux |
| 56 | +- Install [Termux](https://github.com/termux/termux-app/releases) |
| 57 | +- General setup, and setup gptfdisk |
| 58 | +```bash |
| 59 | +# Replace mirror |
| 60 | +# *Use space to select and enter to confirm* |
| 61 | +termux-change-repo |
| 62 | +# Update |
| 63 | +apt update |
| 64 | +# Install root repo |
| 65 | +apt install root-repo |
| 66 | +# Install gdisk |
| 67 | +apt install tsu gptfdisk |
| 68 | +``` |
| 69 | +- Open gdisk |
| 70 | +```bash |
| 71 | +tsu # when termux request root permission, please agree. |
| 72 | +gdisk /dev/block/sdx # x can be a, b, or other letters |
| 73 | +``` |
| 74 | +- Enter expert mode |
| 75 | +```bash |
| 76 | +x |
| 77 | +# Expert command (? for help): |
| 78 | +``` |
| 79 | +- Change partition's attribute |
| 80 | +```bash |
| 81 | +# Expert command (? for help): |
| 82 | +a # Change partition attribute |
| 83 | +# Partition number: |
| 84 | +1 # Enter partition number |
| 85 | +# Known attributes are: |
| 86 | +# 0: system partition |
| 87 | +# 1: hide from EFI |
| 88 | +# 2: legacy BIOS bootable |
| 89 | +# 60: read-only |
| 90 | +# 62: hidden |
| 91 | +# 63: do not automount |
| 92 | + |
| 93 | +# Attribute value is 10C0000000000000. Set fields are: |
| 94 | +# 54 (Undefined bit #54) |
| 95 | +# 55 (Undefined bit #55) |
| 96 | +# 60 (read-only) |
| 97 | + |
| 98 | +# Toggle which attribute field (0-63, 64 or <Enter> to exit): |
| 99 | +0 # System bit |
| 100 | +# Have enabled the 'system partition' attribute. |
| 101 | +# Attribute value is 10C0000000000001. Set fields are: |
| 102 | +# 0 (system partition) |
| 103 | +# 54 (Undefined bit #54) |
| 104 | +# 55 (Undefined bit #55) |
| 105 | +# 60 (read-only) |
| 106 | +``` |
| 107 | +- Set system bit for all partitions in a lun can make the lun invisible in Windows device manager. |
| 108 | + |
| 109 | +## In the last |
| 110 | +This guide only help you interact with tools in CLI. |
| 111 | +The tool may support run in script, why not have a try with running these commands in script? |
0 commit comments