LUN iSCSI Config on Ubuntu
I setup a NAS at home, and I can attach a LUN iSCSI disk from NAS to the ubuntu laptop. After made some tryings, I got this work.
Install the iscsi package
$ sudo apt-get install open-iscsi
Edit the config
$ sudo vi /etc/iscsi/iscsid.conf
line 53: uncomment
node.session.auth.authmethod = CHAP
line 57, 58: uncomment and set username and password which set on iSCSI Target
node.session.auth.username = your.username
node.session.auth.password = your.password
sudo /etc/init.d/open-iscsi restart
discover the targets
$ sudo iscsiadm --mode discovery -t st -p 192.168.0.xx
$ sudo iscsiadm -m discovery -t sendtargets -p 192.168.0.xx
confirm status after discovery
$ sudo iscsiadm -m node -o show
BEGIN RECORD 2.0-873
node.name = iqn.2015-05.world.server:target00
node.tpgt = 1
node.startup = manual
node.leading_login = No
.....
.....
login/logout the node
$ sudo iscsiadm -m node -p 192.168.0.xx:326x -T iqn.2015-09.memodir.iscsi:virtualdisk-linux.02 --login[logout]
Logging in to [iface: default, target: iqn.2015-09.memodir.iscsi:virtualdisk-linux.02, portal: 192.168.0.xx,326x] (multiple)
Login to [iface: default, target: iqn.2015-09.memodir.iscsi:virtualdisk-linux.02, portal: 192.168.0.xx,326x] successful.
confirm established session
$ sudo iscsiadm -m session -o show
tcp: [1] 192.168.0.xx:326x,0 iqn.2015-09.memodir.iscsi:virtualdisk-linux.02
confirm partitions
cat /proc/partitions
first time to create the partition
$ sudo fdisk /dev/sdb
n
p
enter
w
format the file system with ext4
$ sudo mkfs.ext4 /dev/sdb1
mount the /iscsi (or some other folder)
$ sudo mount /dev/sdb1 /iscsi
add the fstab
/dev/sdb1 /srv ext4 defaults,auto,_netdev 0 0