So you went on eBay and purchased some used SAS disks that were previously in an EMC device (or some other scenario where you ended up with disks that have non-standard block sizes) and when you use them on your system, you see something similar to the following on the console or in
[163994.026960] sd 1:0:14:0: [sdm] 520-byte physical blocks
[163994.028868] sd 1:0:14:0: [sdm] Unsupported sector size 520.
There are a number of various articles online that will purportedly resolve this issue, however, none seem to be current or applicable to large (2TB+) disks. The process outlined here should work on modern Ubuntu systems to alter the block size on large SAS or SCSI disks so they can be used on any normal system including Windows, Linux, FreeBSD, and others.
First, you’ll need to make sure you have a copy of GCC installed on the system:
sudo apt install gcc
Next, you’ll want to download and compile a copy of ahouston’s fork of setblocksize from https://github.com/ahouston/setblocksize – this fork has a couple of changes; most important being a longer maximum command timeout to allow us to work with large disks.
Now, we need to find the generic SCSI device that corresponds to the drive. First, we will install
sudo apt install sg3-utils
Next, we will run
sudo sg_map which will return the list of block devices and their corresponding SCSI generic devices:
sudo sg_map | grep sdm
Now we know that
/dev/sg14 is what corresponds to our disk
sdm. Now, all that’s left to do is to reformat it with the correct block size by running
sudo ./setblocksize -t1800 /dev/sg14
-t1800 parameter here tells the drive to wait a maximum of 1800 minutes before canceling the job. This should be plenty of time for even large disks to reformat themselves. After the task completes, this disk should work in nearly any system.
It’s important to note that this job will take quite some time. It runs on the disk itself, so if
setblocksize is closed, the drive will continue to happily churn away. However, if the disk is disconnected from power, the job will need to be restarted.
A concise version of the commands we would run for disk
sdX is below:
sudo apt install gcc sg3-utils
sudo sg_map | grep sdX
sudo ./setblocksize -t1800 /dev/sgXX