Skip to main content

IT - iSCSI: installing target server Fedora 36 / 37 / 38 / 39

Fedora Installation and iSCSI Target Setup

1. Install Fedora from DVD DL

  • Download latest version from Fedora Server Download
  • Burn DVD DL using the Windows workstation
  • (Apple mac-mini) Plug external DVD DL reader. Mac-mini 015 has a faulty USB port.
  • Plug wired network cable
  • Load Fedora disc, boot
  • Enable root account and SSH for root
  • Add user afberendsen
  • Disk layout with fedora_fedora-root using all space available

2. Initial Setup

  • Set up hostname:
    • sudo hostnamectl set-hostname <host-name>
    • sudo reboot
    • Check prompt
  • Update ~/.bashrc:
export HISTCONTROL=ignoredups:erasedups   # no duplicate entries
export HISTSIZE=100000                    # big big history
export HISTFILESIZE=100000                # big big history
export HISTTIMEFORMAT="[%F %H:%M:%S %a] "
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
export QUOTING_STYLE=literal
shopt -s histappend
  • Update SSH: sudo vi ./ssh/sshd_config
    • Change Banner /etc/ssh/motd
    • Create /etc/ssh/motd
  • Update NetworkManager config:
[ipv4]
method=manual
address1=192.168.0.15/24,192.168.0.1
dns=1.1.1.1;1.0.0.1;8.8.8.8;8.8.4.4;
  • Update DNF config: sudo vi /etc/dnf/automatic.conf
[commands]
upgrade_type = default
random_sleep = 0
network_online_timeout = 60
download_updates = yes
apply_updates = yes
reboot = never
reboot_command = "shutdown -r +5 'Rebooting after applying package updates'"

[emitters]
emit_via = stdio

[email]
email_from = root@<this-server-ip-address>
email_to = afberendsen@gmail.com
email_host = localhost

[command]
[command_email]
email_from = root@<this-server-ip-address>
email_to = afberendsen@gmail.com

[base]
debuglevel = 1

3. Extensions

  • Install packages: targetcli wget cpufetch glances
  • systemctl enable target
  • sudo firewall-cmd --add-service=iscsi-target
  • sudo firewall-cmd --runtime-to-permanent
  • sudo shutdown -r now
  • systemctl | grep "target.service\|iscsi"

4. iSCSI Target CLI Script

#!/bin/bash

echo "===> Deleting"

for a1 in $(targetcli ls /iscsi | grep TPGs | awk '{print $2}'); do
    for a2 in $(targetcli ls "/iscsi/${a1}" | grep tpg | awk '{print $2}'); do
        for a3 in $(targetcli ls "/iscsi/${a1}/${a2}/acls/" | grep Mapped | awk '{print $2}'); do
            targetcli "/iscsi/${a1}/${a2}/acls/" delete "${a3}"
        done
        for a3 in $(targetcli ls "/iscsi/${a1}/${a2}/luns/" | grep default_tg_pt_gp | awk '{print $2}'); do
            targetcli "/iscsi/${a1}/${a2}/luns/" delete "${a3}"
        done
    done
    targetcli "/iscsi" delete "${a1}"
done

echo "===> Creating"

for a1 in $(targetcli ls /backstores/block | grep /dev | awk '{print $2}'); do
    targetcli /backstores/block/ delete ${a1}
done

sThis=iqn.1994-05.com.redhat:4aa4ea84d4aa
sClient=iqn.1994-05.com.redhat:ecdd17858d7

# Add backstores
targetcli /backstores/block create t16-A-disk0 /dev/disk/by-id/wwn-0x5000c500db7ea494
targetcli /backstores/block create t16-A-disk1 /dev/disk/by-id/wwn-0x5000c500c523375a
targetcli /backstores/block create t16-A-disk2 /dev/disk/by-id/wwn-0x5000039c08d83244
targetcli /backstores/block create t16-A-disk3 /dev/disk/by-id/wwn-0x5000039b48d84d70
targetcli /backstores/block create t16-A-disk4 /dev/disk/by-id/wwn-0x5000c500d5698091
targetcli /backstores/block create t16-B-disk0 /dev/disk/by-id/wwn-0x5000c500b5154088
targetcli /backstores/block create t16-B-disk1 /dev/disk/by-id/wwn-0x5000039968cb6ac5
targetcli /backstores/block create t16-B-disk2 /dev/disk/by-id/wwn-0x5000c500db76e926
targetcli /backstores/block create t16-B-disk3 /dev/disk/by-id/wwn-0x50000399b8cba421
targetcli /backstores/block create t16-B-disk4 /dev/disk/by-id/wwn-0x5000c500b27fe42e

# Add server node
targetcli /iscsi create ${sThis}

# Add LUNs
for disk in t16-A-disk{0..4} t16-B-disk{0..4}; do
    targetcli /iscsi/${sThis}/tpg1/luns create /backstores/block/${disk}
done

# Add client ACL
targetcli /iscsi/${sThis}/tpg1/acls create ${sClient}

# Save and verify
targetcli saveconfig
targetcli ls

Comments

Popular posts from this blog

TV Series - The Brokenwood Mysteries [NZ] (2014) - Season 10

 

Movie - Sin City: A Dame to Kill For (2014)

 

Movies - Deadpool & Wolverine (2024)