ISCSI. AlmaLinux 8. ISCSI-Initiator

Материал из Wiki
Версия от 15:18, 2 февраля 2023; Cless (обсуждение | вклад) (Новая страница: «= Links = https://computingforgeeks.com/how-to-configure-iscsi-initiator-on-centos-rhel/ = Configuring = == Connect to target and mount a device == Install <co...»)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к навигации Перейти к поиску

Links

https://computingforgeeks.com/how-to-configure-iscsi-initiator-on-centos-rhel/

Configuring

Connect to target and mount a device

Install

dnf -y install iscsi-initiator-utils

Target path

nano /etc/iscsi/initiatorname.iscsi

    InitiatorName=iqn.2023-01.alef:vmail

Login and password for target (CHAP only)    

nano /etc/iscsi/iscsid.conf

...
node.session.auth.username = vmail
node.session.auth.password = PassWord
...

Discovery target (target discovery auth disabled)

iscsiadm -m discovery -t sendtargets -p 192.168.199.250

    ...
    192.168.199.250:3260,1 iqn.2023-01.alef:vmail
    ...

Target info

iscsiadm -m node -o show

Login to ALL targets

iscsiadm -m node --login

    ...
    Logging in to [iface: default, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260]
    Login to [iface: default, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260] successful.
    ...

Login to specific targets

iscsiadm -m node --login --targetname iqn.2023-01.alef:vmail.zfs -p 192.168.199.250,3260    

Show connected session info

iscsiadm -m session -o show

    ...
    tcp: [6] 192.168.199.250:3260,1 iqn.2023-01.alef:vmail (non-flash)
    ...

Show connected block device

lsblk

    ...
    sdb                       8:16   0  100G  0 disk
    ...

Create partition

fdisk /dev/sdb

    n - Next - Next...

Create FS

mkfs.ext4 /dev/sdb1

Getting partition UUID

blkid

    ...
    /dev/sdb1: UUID="d13097d0-1b54-47b0-b504-ffc56d9bceff" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="797c5bc8-01"
    ...

Auto mount after OS boot

mkdir /var/vmail

nano /etc/fstab

...
# iscsi vmail
UUID="d13097d0-1b54-47b0-b504-ffc56d9bceff" /var/vmail ext4 _netdev 0 0
...

reboot

df -h

    ...
    /dev/sdb1                         98G  4.1G   89G   5% /var/vmail
    ...

Unmount and disconnect a target

Unmount device

umount /var/vmail

Logout target

iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -u

   ...
   Logging out of session [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260]
   Logout of [sid: 1, target: iqn.2023-01.alef:vmail, portal: 192.168.199.250,3260] successful.
   ...

Delete connection

iscsiadm --mode node --targetname iqn.2023-01.alef:vmail --portal 192.168.199.250 -o delete

Increase a size of the an extent (block device)

Server ISCSI-target

Increase size of the extent

For example, on Nas4free you just have to type bigger size of the file-extent instead of old size of the file-extent in the web-interface and restart ISCSI-target service

Client ISCSI-initiator

Unmount device (don't logout from target, otherwise you wil not be able to work with sdb - it will disappear)

umount /dev/sdb1

Run parted util

parted

Select device

> select /dev/sdb

Get device full size (it will be bigger than actual size)

> print

    ...
    Disk /dev/sdb: 129GB
    ...

Increaze size to full disk size

> resizepart 1 129GB

Exit

> quit

Increase FS size

resize2fs /dev/sdb1

Mount device

mount /dev/sdb1

Check new size

df -h

    ...
    /dev/sdb1                        118G  4.1G  108G   4% /var/vmail
    ...

Success!