sd(4)
πΎ sd(4) β the SCSI disk driver, bestie edition π
okay so this is a page from the Kernel Interfaces Manual, and it's literally all about sd, the driver for SCSI disk drives. she's iconic, she's been here forever, let's get into it π«Ά
β¨ SYNOPSIS β¨
#include <linux/hdreg.h> /* for HDIO_GETGEO */
#include <linux/fs.h> /* for BLKGETSIZE and BLKRRPART */
yes bestie you gotta include both headers, they're not optional, each one is pulling its own weight π
π CONFIGURATION π
so the block device name is shaped like sdlp β where l is a letter (the physical drive) and p is a number (the partition on that drive). and like, super often people just leave the partition number p off entirely when they mean the whole drive, no cap.
SCSI disks have a major device number of 8, and the minor device number goes like this:
(16 * drive_number) + partition_number
where drive_number is just the physical drive's number in the order it got detected, and partition_number is:
- partition
0is the whole drive π - partitions
1β4are the DOS "primary" partitions - partitions
5β8are the DOS "extended" (or "logical") partitions
for example, /dev/sda has major 8 and minor 0, and it refers to, like, all of the first SCSI drive in the system. and /dev/sdb3 has major 8 and minor 19 and refers to the third DOS "primary" partition on the second SCSI drive. the math is mathing β¨
at this time, only block devices are provided. raw devices have not yet been implemented β like, at all. sad but true π
π DESCRIPTION π
the following ioctls are provided, and they are serving:
HDIO_GETGEOβ returns the BIOS disk parameters in this structure:
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
unsigned short cylinders;
unsigned long start;
};
a pointer to this structure is passed as the ioctl(2) parameter.
the info you get back in that parameter is the disk geometry of the drive as understood by DOS! and this is not the physical geometry of the drive, okay, don't get it twisted. it is used when constructing the drive's partition table though, and you need it for convenient operation of fdisk(1), efdisk(1), and lilo(1). and if the geometry info isn't available, you get zero for all the parameters. zero, bestie. all of them. π
BLKGETSIZEβ returns the device size in sectors. theioctl(2)parameter should be a pointer to along.BLKRRPARTβ forces a reread of the SCSI disk partition tables. no parameter needed, she's low maintenance π¦
the SCSI ioctl(2) operations are also supported. and here's the catch: if the ioctl(2) parameter is required and it's NULL, then ioctl(2) fails with the error EINVAL. so don't do that π
πΈ FILES πΈ
/dev/sd[a-h]β the whole device/dev/sd[a-h][0-8]β individual block partitions
and that's the whole page, you ate that π this lil gem comes to you from Linux man-pages 6.20, dated 2026-02-08 β periodt, mwah πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1992, Rickard E. Faith <faith@cs.unc.edu>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms