ubuntu20.04配置lio_sam
时间: 2023-05-24 18:07:16 浏览: 364
To configure lio_sam on Ubuntu 20.04, you can follow the steps below:
1. Install the necessary packages:
```
sudo apt-get update
sudo apt-get install targetcli-fb python3-rtslib-fb
```
2. Create a new target:
```
sudo targetcli
/iscsi create iqn.2020-01.com.example:target01
```
3. Create a new LUN (Logical Unit Number) and map it to the target:
```
cd /iscsi/iqn.2020-01.com.example:target01/tpg1/luns
create /backstores/fileio/example.img
cd /iscsi/iqn.2020-01.com.example:target01/tpg1/acls
create iqn.2020-01.com.example:initiator01
cd /iscsi/iqn.2020-01.com.example:target01/tpg1/luns
create /backstores/fileio/example.img lun0
cd /iscsi/iqn.2020-01.com.example:target01/tpg1/luns/lun0
set index=0
bind iqn.2020-01.com.example:initiator01
```
Note: Replace "example.img" with the name of your desired image file.
4. Exit targetcli.
```
exit
```
5. Restart the iSCSI service.
```
sudo systemctl restart iscsitarget
```
6. Make sure the iSCSI service is enabled upon startup.
```
sudo systemctl enable iscsitarget
```
7. Use the "iscsiadm" command to discover the new target and connect to it.
```
sudo iscsiadm -m discovery -t st -p 127.0.0.1
sudo iscsiadm -m node -T iqn.2020-01.com.example:target01 -p 127.0.0.1 -l
```
Note: Replace "127.0.0.1" with the IP address of your target server.
You should now be able to use the LUN as a SCSI disk.
阅读全文