Passa ai contenuti principali

Linux CentOS 7 - iSCSI configuration

Linux CentOS 7 - iSCSI configuration

Configure the following target on system1: iqn.2019-06.com.example.system1 with 3 GB partition

Configure on system2 an initiator iqn.2019-06.com.example.system2 and automatically mount the iSCSI partion.

On system1

View the partitions
fdisk -l

If there is no space on the present disk, add a new disk.

Configure the new disk.

# fdisk /dev/sdb
n for new
p for primary
1 as the number
first sector: accept default value;
last sector: +4GB
t for type
code 8e for LVM
p to show the configured partition
w to write the configuration and make it permanent

Tell the kernel about the new parttion
# partprobe /dev/sdb

Create a new physical volume
# pvcreate /dev/sdb1

Create a new volume group
# vgcreate vg1 /dev/sdb1

Create a new logical volume
#lvcreate -n lvm1 -l 100%VG vg1

Install packages for target configuration
# yum install -y targetcli

Enable and strart the target service
# systemctl enable target && systemctl start target

Configure the iSCSI target
# targetcli

Configure the block
cd /backstores/block> create block1 /dev/vg1/lvm1

Configure the iscsi target
cd iscsi> create iqn.2019-06.com.example:system1

Configure the ACL
cd iqn.2019-06.com.example:system1/tpg1/acls> create qn.2019-06.com.example:system2

Configure the LUN
cd luns> create /backstores/block/block1

Configure the portal
cd portals> delete 0.0.0.0 3260
create 192.168.189.140:3260

Go to root directory and see the result:
ls

/> ls
o- / ......................................................................................................................... [...]
  o- backstores ....................................................................................................... [...]
  | o- block .................................................................................... [Storage Objects: 1]
  | | o- block1 .......................................... [/dev/vg1/lv1 (2.8GiB) write-thru activated]
  | |   o- alua ..................................................................................... [ALUA Groups: 1]
  | |     o- default_tg_pt_gp .......................................... [ALUA state: Active/optimized]
  | o- fileio ....................................................................................... [Storage Objects: 0]
  | o- pscsi ........................................................................................ [Storage Objects: 0]
  | o- ramdisk ................................................................................... [Storage Objects: 0]
  o- iscsi ......................................................................................................... [Targets: 1]
  | o- iqn.2019-06.com.example:system1 ......................................................... [TPGs: 1]
  |   o- tpg1 .................................................................................... [no-gen-acls, no-auth]
  |     o- acls ....................................................................................................... [ACLs: 1]
  |     | o- iqn.2019-06.com.example:system2 ...................................... [Mapped LUNs: 1]
  |     |   o- mapped_lun0 .............................................................. [lun0 block/block1 (rw)]
  |     o- luns ........................................................................................................ [LUNs: 1]
  |     | o- lun0 .........................................[block/block1 (/dev/vg1/lv1) (default_tg_pt_gp)]
  |     o- portals .................................................................................................. [Portals: 1]
  |       o- 192.168.189.140:3260 ................................................................................. [OK]
  o- loopback ..................................................................................................... [Targets: 0]
/>


Save the configuration
saveconfig
exit

Adjust the firewall
# firewall-cmd --permanent -add-port=3260/tcp

# firewall-cmd --reload



On system2

Install packages for iSCSI initiator
# yum install -y iscsi-initiator-utils

Configure the initiator name
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2019-06.com.example:system2

See the manual pages to copy and adjust sample commands
# man isciadm

Discover the target on the network
# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.189.140 --discover

Login into the target as user root
# iscsiadm --mode node --targetname iqn.2019-06.com.example:system1 --portal 192.168.189.140:3260 --login root

Enable and start the iscsi daemon
# systemctl enable  iscsid && systemctl start  iscsid

Install utility to check iscsi 
# yum install -y lsscsi

Check iscsi targets
# lsscsi
[0:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda
[2:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0
[4:0:0:0]    disk    LIO-ORG  block1           4.0   /dev/sdb
# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   16G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   15G  0 part
  ├─centos-root 253:0    0 13.4G  0 lvm  /
  └─centos-swap 253:1    0  1.6G  0 lvm  [SWAP]
sdb               8:16   0  2.8G  0 disk

# fdisk -l

Configure the iscsi partition

# fdisk /dev/sdb

n for new
p for primary
1 as the number
first sector: accept default value;
last sector: accept default value;
t for type
code 83 for Linux
p to show configured partition
w to save the partion

Format the new partition
# mkfs -t ext4 /dev/sdb1
or shorter
# mkfs.ext4 /dev/sdb1 

View the memory blocks for mounting the iscsi partition
# lsblk

Get the UUID of the blocks
# blkid /dev/sdb1

Copy the UUID into the fstab file
# blkid /dev/sdb1 >> /etc/fstab

Create the mount point for the iscsi partition
# mkdir /iscsi

Edit the /etc/fstab file
UUID="b6ed8784-5417-457e-afe4-b117be65e71d"      /iscsi     ext4      defaults,_netdev 0 0

Mount the whole fstab 
# mount -a

Check the configuration can withstand a reboot
# reboot

# mount | grep iscsi 
it must show no errors and boot OK.



Commenti

Post popolari in questo blog

Using Wallys Communications DR4018H access point Introduction WiFi Analyzer is an open-source app for Android, available for download from Google Play. It allows the user to optimize their WiFi network by examining surrounding WiFi networks, measuring their signal strength as well as identifying crowded channels. This application does not require access to internet, therefore it does not send any personal/device information to any other source and it does not receive any information from other sources. I installed it on my Samsung Galaxy smartphone and I tested the connection to the Wallys Communications DR4018H access point (see picture below) . The findings are described below. Procedure I linked the AP to my home router in the entrance hall of my apartment. The SSID is called “WIFIA” and the smartphone is connected. It receives a local IP address from the router directly connected to the AP.     The received power at abo...

Linux CentOS 7 - Mounting the iso file as a CD-ROM

Linux CentOS 7 - Mounting the iso file as a CD-ROM in a repo Mount the iso file as a CD-ROM in a repository. Provided your iso file contains the complete operative system, this allows you to disable the default repositories and mirrors and install all required packages without downloading them from the internet. In other words you can work off-line. On system1 and/or system2 Edit the repo file vim /etc/yum.repos.d/CentOS-CD.repo [CentOS-CD] name =  CD ROM baseurl = file:///media/CentOS gpgcheck = 0 enabled = 1 Mount the iso file as a CD-ROM in a repository. Make a mount point mkdir /media/CentOS Edit the fstab file /dev/cdrom     /media/CentOS   iso9660   loop 0 0 mont -a Verify df -Th it must return the /dev/loop0 disk yum repolist it must show the repositories contained in the iso file.

Linux CentOS 7 - Configuring a cache-only DNS

Linux CentOS 7 - Configuring a cache-only DNS Configure a cache only DNS server which forwards requests to the well known Google DNS server. On system1 Install the unbound package # yum install -y unbound Enable and start the service # systemctl enable unbound && systemctl start unbound Adjust the configuration file # vim /etc/unbound/unbound.conf interface: 0.0.0.0                       ## all interfaces access-control: 0.0.0.0/0 allow ## from all networks forward-zone      name: "."                              ## from any domain      forward-addr: 8.8.8.8           ## DNS server towards which all requests will be forwarded Check configuration  # unbound-checkconf Modify the DNS server on the interface configuration # vim /etc/sysconfig/network-scripts/ifc...