Linux Tutorials - Herong's Tutorial Examples - v1.32, by Dr. Herong Yang
"hdparm" - Hard Disk Parameters
Provides a tutorial example on how to use the 'hdparm' command to gather hard disk identification information and get/set individual parameters. 'hdparm' command does not work on normal USB drives.
If you want to see and change hard disk parameters, you can use the "hdparm" command as shown in this tutorial.
1. Get hard disk identification information in a compact format with the "hdparm -i" command.
herong$ sudo hdparm -i /dev/sda /dev/sda: Model=WDC WD10EZEX-******, FwRev=01.01A01, SerialNo=WD-****** Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=16 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=1953525168 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5 AdvancedPM=no WriteCache=enabled Drive conforms to: Reserved: ATA/ATAPI-1,2,3,4,5,6,7
2. Get hard disk identification information in a detailed format with the "hdparm -I" command. I see lot of useful information.
herong$ sudo hdparm -I /dev/sda /dev/sda: ATA device, with non-removable media Model Number: WDC WD10EZEX-****** Serial Number: WD-****** Firmware Revision: 01.01A01 Transport: Serial, SATA 1.0a, SATA II Extensions, ... Standards: Used: unknown (minor revision code 0x001f) Supported: 9 8 7 6 5 Likely used: 9 Configuration: Logical max current cylinders 16383 16383 heads 16 16 sectors/track 63 63 -- CHS current addressable sectors: 16514064 LBA user addressable sectors: 268435455 LBA48 user addressable sectors: 1953525168 Logical Sector size: 512 bytes Physical Sector size: 4096 bytes device size with M = 1024*1024: 953869 MBytes device size with M = 1000*1000: 1000204 MBytes (1000 GB) cache/buffer size = unknown Nominal Media Rotation Rate: 7200 Capabilities: LBA, IORDY(can be disabled) Queue depth: 32 Standby timer values: spec'd by Standard, with device specific minimum R/W multiple sector transfer: Max = 16 Current = 16 DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 *udma5 Cycle time: min=120ns recommended=120ns PIO: pio0 pio1 pio2 pio3 pio4 Cycle time: no flow control=120ns IORDY flow control=120ns Commands/features: Enabled Supported: * SMART feature set Security Mode feature set * Power Management feature set * Write cache * Look-ahead * Host Protected Area feature set * WRITE_BUFFER command * READ_BUFFER command ... Security: Master password revision code = 65534 supported not enabled not locked frozen not expired: security count supported: enhanced erase 122min for SECURITY ERASE UNIT. 122min for ENHANCED SECURITY ERASE UNIT. Logical Unit WWN Device Identifier: 5001****** NAA : 5 IEEE OUI : 0014ee Unique ID : ****** Checksum: correct
3. Get detailed identification information of a USB drive. I don't see any useful information. So "hdparm" command is not design for all types of storage devices.
herong$ sudo hdparm -I /dev/sdb /dev/sdb: SG_IO: bad/missing sense data, sb[]: f0 00 05 00 00 00 00 14 ... ATA device, with non-removable media Standards: Likely used: 1 Configuration: Logical max current cylinders 0 0 heads 0 0 sectors/track 0 0 -- Logical/Physical Sector size: 512 bytes device size with M = 1024*1024: 0 MBytes device size with M = 1000*1000: 0 MBytes cache/buffer size = unknown Capabilities: IORDY not likely Cannot perform double-word IO R/W multiple sector transfer: not supported DMA: not supported PIO: pio0
3. Get the read-only flag of a USB drive using the "hdparm -r" command.
herong$ sudo hdparm -r /dev/sdb /dev/sdb: readonly = 0 (off)
4. Set the read-only flag of a USB drive using the "hdparm -r 1" command.
herong$ sudo hdparm -r 1 /dev/sdb /dev/sdb: setting readonly to 1 (on) readonly = 1 (on)
5. Verify the read-only flag of a USB drive. I see that the read-only flag on the USB drive is not working.
(mount the only partition of the USB drive) herong$ sudo mount /dev/sdb1 /media herong$ cd /media (create a new file on USB driver) herong$ sudo touch test.txt herong$ ls -l test.txt -rwxr-xr-x. 1 root root 0 Apr 1 05:38 test.txt herong$ sudo hdparm -r /dev/sdb /dev/sdb: readonly = 1 (on)
Table of Contents
Cockpit - Web Portal for Administrator
"df" - Display Free Space of File System
Mount USB Drive as File System
"fdisk" - Format Disk Partitions
"dd" - Copy Data from/to Storage Devices
Use "dd" Command to Test I/O Speed
►"hdparm" - Hard Disk Parameters
"du" - Display Disk Usage of Directories
Mount Windows NTFS File System
Access Persmissions on "ntfs-3g" File System
File System Types, IDs and Formats
"parted" - Partition Manipulation Program
Reformat NTFS Partition into EXT4 Partition
Unreachable Remote File Systems
SELinux - Security-Enhanced Linux
Software Package Manager on CentOS - DNF and YUM
Running Apache Web Server (httpd) on Linux Systems
Running PHP Scripts on Linux Systems
Running MySQL Database Server on Linux Systems
Running Python Scripts on Linux Systems
vsftpd - Very Secure FTP Daemon
Postfix - Mail Transport Agent (MTA)
Dovecot - IMAP and POP3 Server
Email Client Tools - Mail User Agents (MUA)