Steps to configure ISCSI Initiator:
Step 1: Install iscsi
[root@localhost ~]# yum install iscsi* -y
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Package iscsi-initiator-utils-6.2.0.872-41.el6.x86_64 already installed and latest version
Nothing to do
Step 2: Discover the IQN.
[root@localhost ~]#
[root@localhost ~]# iscsiadm -m discovery -t st -p instructor.example.com
Starting iscsid: [ OK ]
iscsiadm: Cannot resolve host instructor.example.com. getaddrinfo error: [Name or service not known]
iscsiadm: cannot resolve host name instructor.example.com
iscsiadm: cannot resolve host name instructor.example.com
iscsiadm: Could not perform SendTargets discovery: encountered connection failure
if you get an error cannot resolve host name then
add server ip address in this file
[root@localhost ~]# vim /etc/resolv.conf
[root@localhost ~]# iscsiadm -m discovery -t st -p instructor.example.com
192.168.0.254:3260,1 iqn.2010-09.com.example:rdisks.server5
Step 3: Add iqn number in initiator file of iscsi
[root@localhost ~]# vim /etc/iscsi/initiatorname.iscsi
[root@localhost ~]#
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2010-09.com.example:rdisks.server5
[root@localhost ~]#
Step 4: Login to the target.
[root@localhost ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server5 -p 192.168.0.254 -l
Logging in to [iface: default, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260] (multiple)
Login to [iface: default, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260] successful.
Step 5: check the remote partition and create a partition of required size.
[root@localhost ~]# fdisk -cul
Disk /dev/vda: 6442 MB, 6442450944 bytes
16 heads, 63 sectors/track, 12483 cylinders, total 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003aa93
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 526335 262144 83 Linux
/dev/vda2 526336 9914367 4694016 8e Linux LVM
Disk /dev/mapper/vgsrv-swap: 570 MB, 570425344 bytes
255 heads, 63 sectors/track, 69 cylinders, total 1114112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-root: 3556 MB, 3556769792 bytes
255 heads, 63 sectors/track, 432 cylinders, total 6946816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-home: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
[root@localhost ~]#
[root@localhost ~]# fdisk -cul
Disk /dev/vda: 6442 MB, 6442450944 bytes
16 heads, 63 sectors/track, 12483 cylinders, total 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003aa93
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 526335 262144 83 Linux
/dev/vda2 526336 9914367 4694016 8e Linux LVM
Disk /dev/mapper/vgsrv-swap: 570 MB, 570425344 bytes
255 heads, 63 sectors/track, 69 cylinders, total 1114112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-root: 3556 MB, 3556769792 bytes
255 heads, 63 sectors/track, 432 cylinders, total 6946816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-home: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
login to iscsi
[root@localhost ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server5 -p 192.168.0.254 -l
[root@localhost ~]# fdisk -cul /dev/sda
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
[root@localhost ~]# fdisk -cu /dev/sda
Command (m for help): p
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-65535, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-65535, default 65535): +25M
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
Step 6: Apply file system to the partition created.
[root@localhost ~]# mkfs.ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
6400 inodes, 25600 blocks
1280 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=26214400
4 block groups
8192 blocks per group, 8192 fragments per group
1600 inodes per group
Superblock backups stored on blocks:
8193, 24577
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Step 7: create a directory and mount the partition on it.
[root@localhost ~]# mkdir /mnt/storage
[root@localhost ~]#
[root@localhost ~]# mount /dev/sda1 /mnt/storage/
[root@localhost ~]#
Step 8: To mount permanently add the partition to /etc/fstab
To check partition id
[root@localhost ~]# blkid /dev/sda1
/dev/sda1: UUID="123ab4de-06e6-46cf-92c8-a8af69de8efa" TYPE="ext4"
[root@localhost ~]# vim /etc/fstab
add the line at the end of the file
#
# /etc/fstab
# Created by anaconda on Tue Feb 11 18:17:43 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vgsrv-root / ext4 defaults 1 1
UUID=34a6d081-83ad-4c22-968c-3abd831784b2 /boot ext4 defaults 1 2
/dev/mapper/vgsrv-home /home ext4 defaults 1 2
/dev/mapper/vgsrv-swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
UUID="123ab4de-06e6-46cf-92c8-a8af69de8efa" /mnt/storage ext4 _netdev0 0
save and exit
verify if there are any errors in the file
[root@localhost ~]# mount -a
check the partition is created successfully
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vgsrv-root
ext4 3.3G 2.4G 793M 75% /
tmpfs tmpfs 499M 100K 499M 1% /dev/shm
/dev/vda1 ext4 248M 33M 203M 14% /boot
/dev/mapper/vgsrv-home
ext4 248M 11M 226M 5% /home
/dev/sda1 ext4 25M 1.4M 22M 6% /mnt/storage
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgsrv-root
3.3G 2.4G 793M 75% /
tmpfs 499M 100K 499M 1% /dev/shm
/dev/vda1 248M 33M 203M 14% /boot
/dev/mapper/vgsrv-home
248M 11M 226M 5% /home
/dev/sda1 25M 1.4M 22M 6% /mnt/storage
Step 9: To logout from the device.
[root@localhost ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server5 -p 192.168.0.254 -u
Logging out of session [sid: 1, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260]
Logout of [sid: 1, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260] successful.
Step 1: Install iscsi
[root@localhost ~]# yum install iscsi* -y
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Package iscsi-initiator-utils-6.2.0.872-41.el6.x86_64 already installed and latest version
Nothing to do
Step 2: Discover the IQN.
[root@localhost ~]#
[root@localhost ~]# iscsiadm -m discovery -t st -p instructor.example.com
Starting iscsid: [ OK ]
iscsiadm: Cannot resolve host instructor.example.com. getaddrinfo error: [Name or service not known]
iscsiadm: cannot resolve host name instructor.example.com
iscsiadm: cannot resolve host name instructor.example.com
iscsiadm: Could not perform SendTargets discovery: encountered connection failure
if you get an error cannot resolve host name then
add server ip address in this file
[root@localhost ~]# vim /etc/resolv.conf
[root@localhost ~]# iscsiadm -m discovery -t st -p instructor.example.com
192.168.0.254:3260,1 iqn.2010-09.com.example:rdisks.server5
Step 3: Add iqn number in initiator file of iscsi
[root@localhost ~]# vim /etc/iscsi/initiatorname.iscsi
[root@localhost ~]#
[root@localhost ~]# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2010-09.com.example:rdisks.server5
[root@localhost ~]#
Step 4: Login to the target.
[root@localhost ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server5 -p 192.168.0.254 -l
Logging in to [iface: default, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260] (multiple)
Login to [iface: default, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260] successful.
Step 5: check the remote partition and create a partition of required size.
[root@localhost ~]# fdisk -cul
Disk /dev/vda: 6442 MB, 6442450944 bytes
16 heads, 63 sectors/track, 12483 cylinders, total 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003aa93
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 526335 262144 83 Linux
/dev/vda2 526336 9914367 4694016 8e Linux LVM
Disk /dev/mapper/vgsrv-swap: 570 MB, 570425344 bytes
255 heads, 63 sectors/track, 69 cylinders, total 1114112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-root: 3556 MB, 3556769792 bytes
255 heads, 63 sectors/track, 432 cylinders, total 6946816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-home: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
[root@localhost ~]#
[root@localhost ~]# fdisk -cul
Disk /dev/vda: 6442 MB, 6442450944 bytes
16 heads, 63 sectors/track, 12483 cylinders, total 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003aa93
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 526335 262144 83 Linux
/dev/vda2 526336 9914367 4694016 8e Linux LVM
Disk /dev/mapper/vgsrv-swap: 570 MB, 570425344 bytes
255 heads, 63 sectors/track, 69 cylinders, total 1114112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-root: 3556 MB, 3556769792 bytes
255 heads, 63 sectors/track, 432 cylinders, total 6946816 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vgsrv-home: 268 MB, 268435456 bytes
255 heads, 63 sectors/track, 32 cylinders, total 524288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
login to iscsi
[root@localhost ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server5 -p 192.168.0.254 -l
[root@localhost ~]# fdisk -cul /dev/sda
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
[root@localhost ~]# fdisk -cu /dev/sda
Command (m for help): p
Disk /dev/sda: 33 MB, 33554432 bytes
2 heads, 32 sectors/track, 1024 cylinders, total 65536 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x939be537
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-65535, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-65535, default 65535): +25M
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
Step 6: Apply file system to the partition created.
[root@localhost ~]# mkfs.ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
6400 inodes, 25600 blocks
1280 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=26214400
4 block groups
8192 blocks per group, 8192 fragments per group
1600 inodes per group
Superblock backups stored on blocks:
8193, 24577
Writing inode tables: done
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Step 7: create a directory and mount the partition on it.
[root@localhost ~]# mkdir /mnt/storage
[root@localhost ~]#
[root@localhost ~]# mount /dev/sda1 /mnt/storage/
[root@localhost ~]#
Step 8: To mount permanently add the partition to /etc/fstab
To check partition id
[root@localhost ~]# blkid /dev/sda1
/dev/sda1: UUID="123ab4de-06e6-46cf-92c8-a8af69de8efa" TYPE="ext4"
[root@localhost ~]# vim /etc/fstab
add the line at the end of the file
#
# /etc/fstab
# Created by anaconda on Tue Feb 11 18:17:43 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vgsrv-root / ext4 defaults 1 1
UUID=34a6d081-83ad-4c22-968c-3abd831784b2 /boot ext4 defaults 1 2
/dev/mapper/vgsrv-home /home ext4 defaults 1 2
/dev/mapper/vgsrv-swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
UUID="123ab4de-06e6-46cf-92c8-a8af69de8efa" /mnt/storage ext4 _netdev0 0
save and exit
verify if there are any errors in the file
[root@localhost ~]# mount -a
check the partition is created successfully
[root@localhost ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vgsrv-root
ext4 3.3G 2.4G 793M 75% /
tmpfs tmpfs 499M 100K 499M 1% /dev/shm
/dev/vda1 ext4 248M 33M 203M 14% /boot
/dev/mapper/vgsrv-home
ext4 248M 11M 226M 5% /home
/dev/sda1 ext4 25M 1.4M 22M 6% /mnt/storage
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vgsrv-root
3.3G 2.4G 793M 75% /
tmpfs 499M 100K 499M 1% /dev/shm
/dev/vda1 248M 33M 203M 14% /boot
/dev/mapper/vgsrv-home
248M 11M 226M 5% /home
/dev/sda1 25M 1.4M 22M 6% /mnt/storage
Step 9: To logout from the device.
[root@localhost ~]# iscsiadm -m node -T iqn.2010-09.com.example:rdisks.server5 -p 192.168.0.254 -u
Logging out of session [sid: 1, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260]
Logout of [sid: 1, target: iqn.2010-09.com.example:rdisks.server5, portal: 192.168.0.254,3260] successful.
No comments:
Post a Comment