How to understand what this sfdisk command is doing
Solution 1:
sfdisk has a manual page that you even find online. It tells you this:
start size type bootable
Also, when a field is empty, the default value is assumed. So, echo , | sfdisk /dev/sdx
creates a single, non-bootable Linux filesystem type (0x83) partition that spans the entire disk.
In your case, the partition starts at sector 2048, i.e. 1Mb, and ends at the end of the disk. The partition is of type 0xC, which means FAT filesystem.
Solution 2:
ExplainShell.com:
-u, --unit letter
Interpret the input and show the output in the units specified by letter. This letter can be one of S, C, B or M, meaning Sectors, Cylinders, Blocks and Megabytes, respectively. The default is cylinders, at least when the geometry is known.
-L, --Linux
Do not complain about things irrelevant for Linux.
-q, --quiet
Suppress warning messages.
Essentially "use sectors as a unit and don't complain".
As for the input format, man sfdisk
:
sfdisk has four (main) uses: list the size of a partition, list the partitions on a device, check the partitions on a device, and - very dangerous - repartition a device. [...]
List sizes
sfdisk -s partition
gives the size of partition in blocks.
Your command doesn't use -s
. Mode 2:
List partitions
The second type of invocation:sfdisk -l device
will list the partitions on the specified device.
Your command doesn't use -l
. Mode 3:
Check partitions
The third type of invocation:sfdisk -V device
will apply various consistency checks to the partition tables on device.
Your command doesn't use -V
, so we're left with the 4th mode:
Create partitions
The fourth type of invocation:sfdisk device
will cause sfdisk to read the specification or the desired partitioning of device from standard input, and then to change the partition tables on that disk. [...]BE EXTREMELY CAREFUL - ONE TYPING MISTAKE AND ALL YOUR DATA IS LOST
[...]
INPUT FORMAT
sfdisk reads lines of the form
<start> <size> <id> <bootable> <c,h,s> <c,h,s>
where each line fills one partition descriptor.
Fields are separated by whitespace, or comma or semicolon possibly followed by whitespace; [...] When a field is absent or empty, a default value is used. [...]
Bootable is specified as [
*
|-
], with as default not-bootable. [...]The default value of size is as much as possible (until next partition or end-of-disk).
So your input:
2048,,0x0C,-
Will create a partition offset 2048 sectors, as large as possible, with ID 0C
hexadecimal (FAT32) and with the bootable flag not set.
Exact offset will depend on sector size of the target drive. With the more common 512-byte sectors it will be 1 MiB.
The partition will not be automatically formatted as FAT32. It will only be marked as intended to be FAT32-formatted.
TL;DR: It's all in the manual.