Today, I've configured the iSCSI target service on Ubuntu 12.04 on the web-based tutorial, making a simple record here. The operating system is a newly installed Ubuntu 12.04, configured with a one-gigabyte SATA laptop hard drive. When the operating system is installed, the hard disk is divided into two partitions, one of which is mounted as the root partition of the operating system, and the other is a gigabyte (/dev/) partition (/DEV/SDA1).sda2) is temporarily not mounted as a space to provide storage services. After installing the operating system, install the necessary software: $ sudo apt-get Install chkconfig lvm2 iscsitarget iscsitarget-dkms Creating a physical volume/dev/sda2:$ sudo pvcreate/dev/sda2 in physical volumes/dev/Create a volume group:$ sudo vgcreate on sda2-S 32M vg_target00/dev/sda2 Look at the volume group:$ sudo you just created Vgdisplay---Volume Group---VG Name vg_target00system idformat lvm2metadata areas1Metadata Sequence No1VG Access Read/WRITEVG Status resizablemax LV 0Cur LV 0Open LV 0Max PV 0Cur PV1Act PV1VG Size419.19GIBPE Size32.00mibtotal PE13414Alloc PE/Size 0/0Free PE/Size 13414/419.19GIBVG UUID vzplqx-drje-kd4k-tr4e-rv6m-nir2-K7SEVT Create a logical volume in the volume group above lv_target00:$ sudo lvcreate-L 50G-N lv_target00 vg_target00 Look at the logical volume you just created: $ sudo lvdisplay---Logical volume---LV Name/dev/vg_target00/lv_target00vg Name vg_target00lv UUID Gd9ro2-xaqr-3u5c-mm1h-o3l8-e3ra-XRT9QTLV Write Access Read/Writelv Status Available#Open 0LV Size 50.00gibcurrent LE1600Segments1Allocation inheritread ahead sectors Auto-Currently set to 256Block Device252: 0 Modifying files/etc/default/Iscsitarget, enable the iSCSI target service: iscsitarget_enable=true to modify the file/etc/iet/ietd.conf, configure the parameters of the iSCSI target service (this assumes that the machine IP using the iSCSI target service is 192.168.100.104): Target iqn.2013-03. World.server:target0Lun 0 Path=/dev/mapper/vg_target00-lv_target00,type=Blockioinitiator-address 192.168.100.104incominguser test_user test_pass Restart the Iscsitarget service: sudo service iscsitarget restart set Iscsitarget services to start automatically after boot: $ sudo chkconfig iscsitarget on look at the Iscsitarget service that just started: $ sudo ietadm--op Show--tid=1wthreads=8Type=0QueuedCommands=32Nopinterval=0NOPTimeout=0 The ISCSI target service has been configured so far. Next we do some configuration on the machines that need to mount iSCSI Target (also known as iSCSI Initiator): $ sudo apt-get Install open-iSCSI Modify configuration file/etc/iscsi/iscsid.conf:#Line 39:uncommentNode.session.auth.authmethod =CHAP#Line 43,44:uncomment and set username and password which set on ISCSI TargetNode.session.auth.username =Test_usernode.session.auth.password=Test_pass uses this command to discover the iSCSI target service (this assumes that the machine IP that provides the iSCSI target service is 192.168.100.5): $ sudo iscsiadm-M discovery-t sendtargets-p 192.168.100.5 192.168.100.5:3260,1 iqn.2013-03. World.server:target0 use the following command to confirm the specific information for the iSCSI target service: $ sudo iscsiadm-M node-o Show use the following command to log in to the iSCSI target service: $ sudo iscsiadm-M node--Login uses the following command to confirm the logon session: $ sudo iscsiadm-M session-o Show this time you should be able to pass/proc/partitions See more out of a partition (SDB): $ more/proc/Partitionsmajor Minor#Blocks name11 0 1048575sr08 0 8388608SDA8 1 248832sda18 2 1sda28 5 8136704Sda5252 0 7581696 dm-0252 1 520192 dm-1 8 16 52428800SDB can also use the FDISK command to view partitions, and you should see/dev/information about SDB: $ sudo fdisk-Ldisk/dev/sdb:53.7 GB, 53687091200bytesHeads, Sectors/track, 51200 cylinders, Total 104857600sectorsunits= Sectors of 1 * 512 = 512bytessector size (logical/physical): bytes/512Bytesi/o Size (minimum/optimal): bytes/512bytesdisk Identifier:0x00000000Disk/dev/sdb doesn't contain a valid partition tableYou can format, mount, and use/dev/normally at this timeSDB. If you do not intend to continue using this partition, you can exit the service from iSCSI target: $ sudo iscsiadm-M node--logout
Configuring the iSCSI Target service on Ubuntu 12.04