Commands

Some commands used during daily maintenance of Linux servers

fdisk

 Command  Explanation  Example
fdisk -l
List the partition tables for the specified devices  
fdisk <device>
Edit the partition table of specified device
fdisk /dev/sdd

Logical Volumes

 Command  Explanation  Example
lvcreate -L<size> <PhysicalVolumePath...>
Create a logical volume lvcreate -L20G datavg
     
     

iSCSI

 Command  Explanation  Example
targetcli
Administration shell for iSCSI storage targets  
          
help
 
help ls
 
ls
Display either the nodes tree relative to path or to the current node  
 
cd
Change current path to path
cd /
 
/backstores/block> create <name> <device>
Creates an Block Storage object
/backstores/block/> create block1 /dev/datavg/lvol1
 
/iscsi> create iqn.<yyyy-mm>.<reversed target domain>:<id>
Creates a new target
/iscsi> create iqn.2017-05.com.mydomain:t1
 
/iscsi/iqn.20...:t1/tpg1/luns> create <storage object>
Creates a new LUN in the Target Portal Group, attached to a storage
object
/iscsi/iqn.20...:t1/tpg1/luns> create /backstores/block/block1
 
/iscsi/iqn.20...:t1/tpg1/acls> create iqn.<yyyy-mm>.<reversed initiator domain>:<id>
Creates a Node ACL for the initiator node with the specified wwn. Also edit /etc/iscsi/initiatorname.iscsi and set InitiatorName to the same wwn.
/iscsi/iqn.20...:t1/tpg1/acls> create iqn.2017-05.com.mydomain:data
iscsiadmin
Open-iscsi administration utility  
 
iscsiadm --mode discovery --type sendtargets --portal <target>
Discover exposed services on target
iscsiadm --mode discovery --type sendtargets --portal 10.0.23.1
 
iscsiadm --mode node --targetname <service> --portal <target> --login
Login to the service and create a local device for the lun
iscsiadm --mode node --targetname iqn.2017-05.com.mydomain:t1 --portal 10.0.23.1 --login
 
iscsiadm --mode node --targetname <service> --portal <target> --logout
Logout from the service
iscsiadm --mode node --targetname iqn.2017-05.com.mydomain:t1 --portal 10.0.23.1 --logout
 
iscsiadm -m session --print=3
Show mapping between lun and device  

mkfs

 Command  Explanation  Example
mkfs.ext4 -L <label> <device>
Create ext4 filesystem on specified device
mkfs.ext4 -L data /dev/sdd1
     

systemctl

 Command  Explanation  Example
systemctl stop|start|restart <service>
Stop, start or restart a service
systemctl restart target.service
systemctl restart iscsid.servic