SetupHPAOnSSD
HPA Size Table
| SSD vendor size (GB) | Desired capacity (GB) | Overprovisioned % | HPA Sectors |
| 256/240 | 220 | 14/8 | 429687500 |
| 512/480 | 460 | 10/4 | 898437500 |
| 1024/960 | 920 | 10/4 | 1796875000 |
| 2048/? | 1900 | 7/? | 3710937500 |
In theory, the number of sectors to set up can be calculated as
x = s*10^9/512
where s is the desired size in GB (base 1000).
Automatically Resize SSD with Script
There is a script on exampleclu which automatically erases and resizes an SSD. This script works for Kingston and Samsung SSDs only, at the moment. For Intel SSDs, use the manual method.
bash /usr/local/scripts/setup_new_ssd.sh --device /dev/sdX --size auto --yes
The size parameter sets the new size in GBs. If you use auto, the SSD will be resized according to the table above (recommended). The device must be physically removed and inserted (power-cycled) to the PC afterwards.
Steps to Set up HPA Manually
Kingston and Samsung SSDs
We will assume that the device to modify is available at /dev/sde.
- make sure the device does not contain any data!
- secure erase the drive
hdparm --user-master u --security-set-pass foo /dev/sde hdparm --user-master u --security-erase foo /dev/sde
- set up HPA according to the table above, HPA size is set up in sectors
hdparm -Np<sectors> --yes-i-know-what-i-am-doing /dev/sde
- check the result
hdparm -N /dev/sde
- delete and re-scan the device
echo 1 > /sys/block/sde/device/delete # use lsscsi or dmesg to find proper scsi host number echo "- - -" > /sys/class/scsi_host/host<X>/scan
- check out the resized disk
fdisk - l /dev/sde
Intel SSDs
Intel SSDs are different in that you cannot use hdparm to set up HPA. Instead, Intel has a special management tool called isdct which is only available on exampleclu right now. To set up HPA, follow these steps:
- First, you must identify the proper Intel SSD, the tool uses different identifiers than /dev/sdX. Call
isdct show -intelssd
and look for Index: <number> under the disk with the right S/N. - Call
isdct set -intelssd <index> MaximumLBA=$(( <HPA sectors from table above> - 1 ))
- Call
echo 1 > /sys/block/sdX/device/delete
- Power-cycle the device.