204.2. Adjusting Storage Device Access
204.2 Adjusting Storage Device Access
Weight: 2
Description: Candidates should be able to configure kernel options to support various drives. This objective includes software tools to view & modify hard disk settings including iSCSI devices.
Key Knowledge Areas:
Tools and utilities to configure DMA for IDE devices including ATAPI and SATA
Tools and utilities to configure Solid State Drives including AHCI and NVMe
Tools and utilities to manipulate or analyse system resources (e.g. interrupts)
Awareness of sdparm command and its uses
Tools and utilities for iSCSI
Awareness of SAN, including relevant protocols (AoE, FCoE)
Terms and Utilities:
hdparm, sdparm
nvme
tune2fs
fstrim
sysctl
/dev/hd*, /dev/sd*, /dev/nvme*
iscsiadm, scsi_id, iscsid and iscsid.conf
WWID, WWN, LUN numbers
In this course many standards and storage concepts are discussed. Before begging lets classified some topics and then we realize where each tools for.
Storage Types
Description
HDD
Hard Disk Drive, traditional mechanical hard disks stores data on magnetic platter.
SSD
Solid state drives (SSDs) are storage devices that contain non-volatile flash memory. they are superior to mechanical hard disk drives in terms of performance, power use, and availability.
NVMe
non-volatile memory expres (NVMe) devices are flash memory chips connected to a system via the PCI-E bus.
and from another aspect :
Storage Connectivity Protocols
Description
IDE/ATA
Popular Interface, used to connect hard disks and optical drives. speed: 133 MB/s
Serial ATA
Serial Version of IDE/ATA typically used for internal connectivity.speed up to 16 Gb/s
SCSI
Popular standard for compute-to-storage connectivity.speed up to 640 MB/s
SAS
Serial attached SCSI, is a point-to-point serial protocol that provides alternative to SCSI.speed up to 12 Gb/s
FC
Fibre Channel a widely-used-protocol for high-spedd communication to the storage device. Latest version speed up to 32 Gb/s
IP
IP is a network protocol that has been traditionally used for compute-to-compute traffic.ISCSI and FCIP protocols are common examples of using IP for compute-to-storage communications.
Now lets get familiar with some linux tools for specific Hard Drives:
hdparm
hdparm is a command line program to set and view ATA hard disk drive hardware parameters. First (in 2005) hdparm utility developed by Mrk Lord to test Linux drivers for IDE hard drives. Since then, the program has developed into a valuable tool for diagnosis and tuning of hard drives It can set parameters such as drive caches, sleep mode, power management and DMA settings.As hdparm interacts directly with hardware it can cause data lost and other file system damages.
hdparm has to be run with root privileges, otherwise it will either not be found or the requested actions will not be executed properly.
hdparm -I /dev/sda to get information about Hard Disk :
lets check how fast is my ssd drive with -t switch:
Wow 509.06 MB/ sec.Not bad :). Some other amazing parameters and features that can be manipulated with hdparm:
hdparam command switch
Description
hdparm -B 125 /dev/sda
Set the Advanced Power Management, valus <1-255>. While 1-127 permit spin-down, 128-254 no not allow spin-down and 255 disable feature completly
hdparm -S 240 /dev/sda
Set standby time.specifies how long to wait in idle (with no disk activity) before turning off the motor to save power. 0 can disbale feature,the values from 1 to 240 specify multiples of 5 seconds and values from 241 to 251 specify multiples of 30 minutes.
hdparm -d 1 /dev/sda
set DMA (Direct Memory Access)on or off,values 0 or 1
and many many other options.
sdparm
scsi version of hdparm. sdparm manupulate scsi specific attributes of hard drive.
NVMEe
Linux has NVMe driver which is natively included in the kernel since version 3.3. NVMe devices should show up under /dev/nvme*
tune2fs
tune2fs command is used by the system administrator to change/modify tunable parameters on ext2, ext3 and ext4 type filesystems. Incomparison to hdparm it manipulates disk drive from File System layer.
We have already seen tune2fs -l /dev/sda command and we have used -i and -c flags to change fsck check interval. Lets do something more interesting. By default every File System in Linux has some space reserved for root, so no regular user can fill file system up to 100%. As a standard, each File System reserve 5% of total space.Lets change it:
When we have very huge partition, ext file system sparse lots of super blocks bakcups in different places of hard disk which consume noticeable space, we can Limit the number of backup superblocks to save space on large filesystems using tune2fs -s 0 /dev/sda10 command.
note that after any manipulation fsck should be run in order to changes take effect.
sysctl
We have previously seen sysctl as a tool to view and change kernel parameters at the run time. sysctl deals with /proc directory .
We used sysctl -a to list all parameters ,and as an example we know sysctl -w net.ipv4.ipforward=1 is the same as echo "1" > /proc/sys/net/ipv4/ip_forward. Then for marking changes persistent we learned that sysctl has a configuration file which is /etc/sysctl.conf and kernel parameters are defined there.
What is LUN?
a logical unit number, or LUN, is a number used to identify a logical unit, which is a device addressed by the SCSI protocol or Storage Area Network protocols which encapsulate SCSI, such as Fibre Channel or iSCSI.
iscsi "EYE-skuzzy"
Befor talking about iscsi, lets talk about scsi to understand it better, Whats scsi? SCSI "skuzzy" ( Small Computer System Interface), is a set of American National Standards Institute (ANSI) standard electronic interfaces that allow personal computers (PCs) to communicate with peripheral hardware such as disk drives, tape drives, CD-ROM drives, printers and scanners faster and more flexibly than previous parallel data transfer interfaces . But what if we could do it remotely?
iSCSI (Internet Small Computer System Interface), works on top of the TCP (Transport Control Protocol) and allows the SCSI command to be sent end-to-end over LANs and WANs or the Internet.
How dose it work? iSCSI works by transporting block-level data between an iSCSI initiator on a computer(as client) and an iSCSI target on a storage device(as server). The iSCSI protocol encapsulates SCSI commands and assembles the data in packets for the TCP/IP layer. Packets are sent over the network using a point-to-point connection. When packets arrived, the iSCSI protocol disassembles the packets, take out SCSI commands so the operating system will see the storage as a local SCSI device that can be formatted as usual.

iqn,EUI
Each iscsi target or iscsi initirator is called iscsi node.All iSCSI nodes are identified by an iSCSI name. An iSCSI name is not IP address or DNS name of that host. Names enable iSCSI storage resources to be managed regardless of other kind of addresses, Also it is used in authentication of targets to initiators and initiators to targets.
iSCSI addresses can be one of two types:
iSCSI Qualified Name (iQN)
IEEE Naming convention (EUI)
iQN format ‐ iqn.yyyy‐mm.com.xyz.aabbccddeeffgghh :
iqn ‐ Naming convention identifier
yyyy‐nn ‐ Point in time when the .com domain was registered
com.xyz ‐ Domain of the node backwards
aabbccddeeffgghh ‐ Device identifier (can be a WWN, the system name, or any other vendorimplemented
standard)
EUI format ‐ eui.64‐bit WWN:
eui ‐ Naming prefix
64‐bit WWN ‐ FC WWN of the host
Okey enough introduction lets start.To keep it simple we use CentOS 7 server (target) with additional 10 gig Disk Drive and then get Our Ubuntu client (initiator) connected to it. First We need to add EPEL repository:
and now lets install iscsi target:
Now lets configure target vi /etc/tgt/target.conf:
lets restrat service:
use tgtadmin to scan what is result:
Do not forget to sysemctl enable tgt.service to keep iscsi target service Active even after reboot. Before testing we have to make tcp port 3260 open, CentOS 7 use firewalld on top of iptables so we use firewall-cmd to manipulate ip table:
okey its time to configure our client as iscsi initiator , we use ubuntu 16 here:
lets configure iscsi initiator vi /etc/iscsi/iscsid.conf :
and lets start the service:
and check with iscsiadm tool:
see current hard disk of our client and lets add new hard disk using iscsiadm:
okey /dev/sdb is added, if you have noticed. to confirm:
and if we reboot the system BoOoMM! every thing is gone! to make it persistent change node.startup = manual
to automatic inside /etc/iscsi/iscsi.conf file. and copy iscsiadm script to /etc/rc.local and enable it if required:
and we are done. Now we can format mount the partition or we can add it to fstab using _netdev option.
Last updated