Benutzer-Werkzeuge

Webseiten-Werkzeuge


targetcli

Dies ist eine alte Version des Dokuments!


targetcli ist ein Tool zum verwalten von iSCSI Targets.

manuel@vm-jzif4y4u:~$ sudo apt install targetcli-fb
[...]
manuel@vm-jzif4y4u:~$ sudo dd if=/dev/zero of=/iscsi-disk.img bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB, 100 MiB) copied, 0.516038 s, 203 MB/s

manuel@vm-jzif4y4u:~$ sudo losetup -fP /iscsi-disk.img
manuel@vm-jzif4y4u:~$ losetup -a
/dev/loop1: []: (/var/lib/snapd/snaps/lxd_29351.snap)
/dev/loop6: []: (/var/lib/snapd/snaps/snapd_23771.snap)
/dev/loop4: []: (/var/lib/snapd/snaps/core20_2496.snap)
/dev/loop2: []: (/var/lib/snapd/snaps/core20_2318.snap)
/dev/loop0: []: (/iscsi-disk.img)
/dev/loop5: []: (/var/lib/snapd/snaps/lxd_31333.snap)
/dev/loop3: []: (/var/lib/snapd/snaps/snapd_23545.snap)

manuel@vm-jzif4y4u:~$ sudo mkfs.ext4 /dev/loop0
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 25600 4k blocks and 25600 inodes

Allocating group tables: done
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

manuel@vm-jzif4y4u:~$ sudo mkdir /mnt/scsi

manuel@vm-jzif4y4u:~$ sudo mount /dev/loop0 /mnt/scsi

manuel@vm-jzif4y4u:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           197M  1.3M  196M   1% /run
/dev/vda1        25G   13G   12G  53% /
tmpfs           982M     0  982M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/vda15      105M  6.1M   99M   6% /boot/efi
tmpfs           197M  4.0K  197M   1% /run/user/1001
/dev/loop0       90M   24K   83M   1% /mnt/scsi

manuel@vm-jzif4y4u:~$ sudo targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.

/> /backstores/fileio create name=mydisk file_or_dev=/iscsi-disk.img size=1G
/iscsi-disk.img exists, using its size (104857600 bytes) instead
Created fileio mydisk with size 104857600
/> /iscsi create iqn.2025-03.com.example:storage1
Created target iqn.2025-03.com.example:storage1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/> /iscsi/iqn.2025-03.com.example:storage1/tpg1/luns create /backstores/fileio/mydisk
Created LUN 0.

/> saveconfig
Last 10 configs saved in /etc/rtslib-fb-target/backup/.
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/rtslib-fb-target/backup/.
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
manuel@vm-jzif4y4u:~$ sudo systemctl enable --now target
Created symlink /etc/systemd/system/multi-user.target.wants/target.service → /lib/systemd/system/target.service.
manuel@vm-jzif4y4u:~$
targetcli.1742758475.txt.gz · Zuletzt geändert: 2025/03/23 20:34 von jango