Table of Contents
Environment
Details
Master Server
192.168.144.136 imastiscsi.example.com mastiscsi
192.168.144.155
Client Server
192.168.144.153 iscsiclient.example.com iscsiclient
192.168.144.154
Installation
of ISCSI Target on Master server
1. Checking Disk Space
[root@mastiscsi ~]# fdisk
-l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2
33 5221 41680642+
8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
2. Mount RHEL 5.9 DVD for configuration of Yum Server
[root@mastiscsi ~]# mount /dev/cdrom /mnt/rhel5/
mount: block
device /dev/cdrom is write-protected, mounting read-only
[root@mastiscsi ~]# cat
/etc/yum.repos.d/rhel5-media.repo
[cd-media]
name=rhel5.9-media
baseurl=file:///mnt/rhel5/Server
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
3. Download below rmps and copy into root folder
[root@mastiscsi ~]# ls
perl-Config-General-2.52-31.1.x86_64.rpm
scsi-target-utils-1.0.14-2.el5.x86_64.rpm
4. Install below software & its dependencies
[root@mastiscsi ~]# rpm
-ivh perl-Config-General-2.52-31.1.x86_64.rpm
warning: perl-Config-General-2.52-31.1.x86_64.rpm: Header V3
DSA signature: NOKEY, key ID dcef338c
Preparing...
########################################### [100%]
1:perl-Config-General
########################################### [100%]
[root@mastiscsi ~]# yum
install libibverbs*
Installed:
libibverbs.i386
0:1.1.6-3.el5
libibverbs.x86_64 0:1.1.6-3.el5
libibverbs-devel.i386
0:1.1.6-3.el5
libibverbs-devel.x86_64 0:1.1.6-3.el5
libibverbs-static.x86_64 0:1.1.6-3.el5 libibverbs-utils.x86_64 0:1.1.6-3.el5
Dependency Installed:
libnes.x86_64
0:1.1.3-1.el5
openib.noarch 0:1.5.4.1-4.el5
[root@mastiscsi ~]# yum
install librdmacm*
Installed:
librdmacm.i386
0:1.0.15-2.el5
librdmacm.x86_64 0:1.0.15-2.el5
librdmacm-devel.i386
0:1.0.15-2.el5
librdmacm-devel.x86_64 0:1.0.15-2.el5
librdmacm-static.x86_64
0:1.0.15-2.el5
librdmacm-utils.x86_64 0:1.0.15-2.el5
[root@mastiscsi ~]# rpm
-ivh scsi-target-utils-1.0.14-2.el5.x86_64.rpm
warning: scsi-target-utils-1.0.14-2.el5.x86_64.rpm: Header V3
DSA signature: NOKEY, key ID e8562897
Preparing... ###########################################
[100%]
1:scsi-target-utils
########################################### [100%]
5. Check NetworkManager and off by chkconfig command
[root@mastiscsi ~]#
chkconfig --list | grep Netwo
NetworkManager 0:off
1:off 2:off 3:off
4:off 5:off 6:off
6. Check and start tgtd service
[root@mastiscsi ~]#
chkconfig --list | grep tgtd
tgtd
0:off 1:off 2:off
3:off 4:off 5:off
6:off
[root@mastiscsi ~]#
service tgtd start
Starting SCSI target daemon: Starting target framework daemon
[root@mastiscsi ~]#
chkconfig tgtd on
[root@mastiscsi ~]#
chkconfig --list | grep tgt
tgtd
0:off 1:off 2:on
3:on 4:on 5:on
6:off
7. Take backup of /etc/tgt/targets.conf file and start
service
[root@mastiscsi ~]# cp -p
/etc/tgt/targets.conf /etc/tgt/targets.conf.bkp
[root@mastiscsi ~]# vi
/etc/tgt/targets.conf
<target iqn.2015-08.com.example:mastiscsi.disk1>
backing-store
/dev/sdb
</target>
[root@mastiscsi ~]#
service tgtd restart
Stopping SCSI target daemon: Stopping target framework daemon
[ OK ]
Starting SCSI target daemon: Starting target framework daemon
8. Check lun & target details
[root@mastiscsi ~]# tgt-admin
-s
Target 1: iqn.2015-08.com.example:mastiscsi.disk1
System information:
Driver: iscsi
State: ready
I_T nexus
information:
LUN information:
LUN: 0
Type:
controller
SCSI ID:
IET 00010000
SCSI SN:
beaf10
Size: 0 MB,
Block size: 1
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: null
Backing
store path: None
Backing
store flags:
LUN: 1
Type: disk
SCSI ID:
IET 00010001
SCSI SN:
beaf11
Size: 4295
MB, Block size: 512
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: rdwr
Backing
store path: /dev/sdb
Backing
store flags:
Account
information:
ACL information:
ALL
9. Check & disable iptables & selinux
[root@mastiscsi ~]#
service iptables status
Firewall is stopped.
[root@mastiscsi ~]#
getenforce
Disabled
Installation
of ISCSI imitator on Client Server
1. Check installed iscsi-initiator rpm
[root@iscsiclient ~]# rpm
-qa | grep iscsi
iscsi-initiator-utils-6.2.0.872-16.el5
2. Check & modify initiator name
[root@iscsiclient ~]# cat
/etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2015-08.com.example:mastiscsi
Above mastiscsi is master server hostname
3. Start iscsi service and make it permanent
[root@iscsiclient ~]#
/etc/init.d/iscsid restart
Stopping iSCSI daemon: [ OK ]
Starting iSCSI daemon: [
OK ]
[root@iscsiclient ~]#
chkconfig --list | grep scsi
iscsi
0:off 1:off 2:off
3:on 4:on 5:on
6:off
iscsid
0:off 1:off 2:off
3:on 4:on 5:on
6:off
4. Discover iscsi server by two IPs of Master Server
[root@iscsiclient ~]#
iscsiadm -m discoverydb -t st --portal 192.168.144.136:3260 --discover
192.168.144.136:3260,1
iqn.2015-08.com.example:mastiscsi.disk1
[root@iscsiclient ~]#
iscsiadm -m discoverydb -t st --portal 192.168.144.155:3260 --discover
192.168.144.155:3260,1
iqn.2015-08.com.example:mastiscsi.disk1
5. Login Master server with both IPs
[root@iscsiclient ~]#
iscsiadm -m node --portal 192.168.144.136:3260 -T
iqn.2015-08.com.example:mastiscsi.disk1 -l
Logging in to [iface: default, target:
iqn.2015-08.com.example:mastiscsi.disk1, portal: 192.168.144.136,3260]
(multiple)
Login to [iface: default, target: iqn.2015-08.com.example:mastiscsi.disk1,
portal: 192.168.144.136,3260] successful.
[root@iscsiclient ~]#
iscsiadm -m node --portal 192.168.144.155:3260 -T
iqn.2015-08.com.example:mastiscsi.disk1 -l
Logging in to [iface: default, target: iqn.2015-08.com.example:mastiscsi.disk1,
portal: 192.168.144.155,3260] (multiple)
Login to [iface: default, target:
iqn.2015-08.com.example:mastiscsi.disk1, portal: 192.168.144.155,3260]
successful.
6. Check Disk Space
[root@iscsiclient ~]#
fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2 33
5221 41680642+ 8e
Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 8246 * 512 = 4221952 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 8246 * 512 = 4221952 bytes
Disk /dev/sdc doesn't contain a valid partition table
Configuration
of multipath on Client
Multipath configuration is
required to configure on Client Machine only. It is not require on Master
Server
1. Check below rpms:
[root@iscsiclient ~]# rpm
-qa | grep device-mapper
device-mapper-1.02.67-2.el5
device-mapper-multipath-0.4.7-54.el5
device-mapper-event-1.02.67-2.el5
device-mapper-1.02.67-2.el5
2. Check if kernel is loaded with multipath module
[root@iscsiclient ~]#
lsmod | grep multipath
dm_multipath 58969 0
scsi_dh 42561
1 dm_multipath
dm_mod
102417 15
dm_multipath,dm_raid45,dm_snapshot,dm_zero,dm_mirror,dm_log
3. Check current mapper device
[root@iscsiclient ~]# ls
-l /dev/mapper/
total 0
crw------- 1 root root
10, 60 Aug 27 17:30 control
brw-rw---- 1 root disk 253,
2 Aug 27 17:31 vg0-home
brw-rw---- 1 root disk 253,
0 Aug 27 17:31 vg0-root
brw-rw---- 1 root disk 253,
3 Aug 27 17:30 vg0-swap
brw-rw---- 1 root disk 253,
1 Aug 27 17:31 vg0-var
4. Comment default blacklist detail
[root@iscsiclient ~]# vi
/etc/multipath.conf
#blacklist {
# devnode
"*"
#}
5. Start multipathd service and make it permanent
[root@iscsiclient ~]#
service multipathd start
Starting multipathd daemon: [
OK ]
[root@iscsiclient ~]#
chkconfig multipathd on
6. Check current multipath details
[root@iscsiclient ~]#
multipath -ll
mpath0 (1IET_00010001) dm-4 IET,VIRTUAL-DISK
[size=4.0G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 31:0:0:1 sdb
8:16 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 32:0:0:1 sdc 8:32 [active][ready]
7. Now check Disk Details
[root@iscsiclient ~]#
fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End
Blocks Id
System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2
33 5221 41680642+
8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 8246 * 512 = 4221952 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 4294 MB, 4294967296 bytes
133 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 8246 * 512 = 4221952 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/dm-4: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-4 doesn't contain a valid partition table
8. Check new mapper device
[root@iscsiclient ~]# ls
-l /dev/mapper/
total 0
crw------- 1 root root
10, 60 Aug 27 17:30 control
brw-rw---- 1 root disk
253, 4 Aug 27 18:17 mpath0
brw-rw---- 1 root disk 253,
2 Aug 27 17:31 vg0-home
brw-rw---- 1 root disk 253,
0 Aug 27 17:31 vg0-root
brw-rw---- 1 root disk 253,
3 Aug 27 17:30 vg0-swap
brw-rw---- 1 root disk 253,
1 Aug 27 17:31 vg0-var
9. Format new Disk
[root@iscsiclient ~]#
fdisk /dev/mapper/mpath0
Command (m for help): p
Disk /dev/mapper/mpath0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
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 cylinder (1-522, default 1): <Enter>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default
522): <Enter>
Using default value 522
Command (m for help): p
Disk /dev/mapper/mpath0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath0p1 1 522
4192933+ 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/mapper/mpath0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath0p1 1 522
4192933+ 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22:
Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
10. Check & make new partition kernel readable
[root@iscsiclient ~]#
fdisk -l /dev/mapper/mpath0
Disk /dev/mapper/mpath0: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath0p1 1 522
4192933+ 8e Linux LVM
[root@iscsiclient ~]#
partprobe /dev/mapper/mpath0
[root@iscsiclient ~]#
fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2 33 5221
41680642+ 8e Linux LVM
Disk /dev/sdb: 4294 MB,
4294967296 bytes
133 heads, 62
sectors/track, 1017 cylinders
Units = cylinders of 8246
* 512 = 4221952 bytes
Disk /dev/sdb doesn't
contain a valid partition table
Disk /dev/sdc: 4294 MB,
4294967296 bytes
133 heads, 62
sectors/track, 1017 cylinders
Units = cylinders of 8246
* 512 = 4221952 bytes
Disk /dev/sdc doesn't
contain a valid partition table
Disk /dev/dm-4: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/dm-4p1
1 522 4192933+
8e Linux LVM
11. New partition is now visible on reaming disks as per above
output so it is require to reboot machine
[root@iscsiclient ~]#
reboot
Broadcast message from root (pts/0) (Thu Aug 27 19:01:54
2015):
The system is going down for reboot NOW!
[root@iscsiclient ~]#
12. After reboot the machine now new partition is visible on
remaining disk
[root@iscsiclient ~]#
fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2
33 5221 41680642+
8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1 1 522
4192933+ 8e Linux LVM
Disk /dev/sdc: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdc1 1 522
4192933+ 8e Linux LVM
Disk /dev/dm-4: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/dm-4p1 1 522
4192933+ 8e Linux LVM
Disk /dev/dm-5: 4293 MB, 4293563904 bytes
255 heads, 63 sectors/track, 521 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-5 doesn't contain a valid partition table
Note: After
reboot machine above /dev/dm-5 has additionally added. But it is useless.
Creating
pv, vg & lvm
1. We should not create physical volume with /dev/dm-4p1. It will show error like
below
[root@iscsiclient
~]# pvcreate /dev/dm-4p1 -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Device /dev/dm-4p1
not found (or ignored by filtering).
Note : Also not create Physical volume with /dev/sdb1 and /dev/sdc1
2. List current Device
[root@iscsiclient ~]# ls
-l /dev/mapper/
total 0
crw------- 1 root root
10, 60 Aug 27 19:03 control
brw-rw---- 1 root disk 253,
4 Aug 27 19:04 mpath0
brw-rw---- 1 root disk
253, 5 Aug 27 19:04 mpath0p1
brw-rw---- 1 root disk 253,
2 Aug 27 19:03 vg0-home
brw-rw---- 1 root disk 253,
0 Aug 27 19:03 vg0-root
brw-rw---- 1 root disk 253,
3 Aug 27 19:03 vg0-swap
brw-rw---- 1 root disk 253,
1 Aug 27 19:03 vg0-var
3. Now Create Physical Volume
[root@iscsiclient ~]#
pvcreate /dev/mapper/mpath0p1
Writing physical
volume data to disk "/dev/mapper/mpath0p1"
Physical volume
"/dev/mapper/mpath0p1" successfully created
[root@iscsiclient ~]#
pvdisplay /dev/mpath/mpath0p1
"/dev/mpath/mpath0p1" is a new physical volume of "4.00
GB"
--- NEW Physical
volume ---
PV Name /dev/mpath/mpath0p1
VG Name
PV Size 4.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID
TLgOgU-8PF6-8x95-3Yqv-vVc2-6soy-wSuEkc
4. Create Volume Group
[root@iscsiclient ~]#
vgcreate wasvg /dev/mpath/mpath0p1
Volume group
"wasvg" successfully created
[root@iscsiclient ~]#
vgdisplay wasvg
--- Volume group ---
VG Name wasvg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence
No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 4.00 GB
PE Size 4.00 MB
Total PE 1023
Alloc PE / Size 0 / 0
Free PE / Size 1023 / 4.00 GB
VG UUID
VigepC-As6r-9q1d-NLlv-gMiK-hJr9-kGNFFt
5. Create Logical Volume
[root@iscsiclient ~]#
lvcreate -L 4GB -n wasvg-datalv wasvg -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Volume group
"wasvg" has insufficient free space (1023 extents): 1024 required.
[root@iscsiclient ~]#
lvcreate -L 3GB -n wasvg-datalv wasvg
Logical volume
"wasvg-datalv" created
[root@iscsiclient ~]#
lvdisplay /dev/wasvg/wasvg-datalv
--- Logical volume
---
LV Name /dev/wasvg/wasvg-datalv
VG Name wasvg
LV UUID
aaT8Df-2U6T-Eh98-YLks-Q1YI-EWQN-oaF6lf
LV Write Access read/write
LV Status available
# open 0
LV Size 3.00 GB
Current LE 768
Segments 1
Allocation inherit
Read ahead
sectors auto
- currently set
to 256
Block device 253:6
Adding
5GB Disk Space on master & Configure as target server
1. Check disk space before scanning new disk without reboot
the machine
[root@mastiscsi ~]# fdisk
-l
Disk /dev/sda: 42.9 GB,
42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2
33 5221 41680642+
8e Linux LVM
Disk /dev/sdb: 4294 MB,
4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1
1 522 4192933+
8e Linux LVM
2. Scan new Disk on Master Server and new disk space
[root@mastiscsi ~]# echo "- - -" >
/sys/class/scsi_host/host0/scan
[root@mastiscsi ~]# fdisk
-l /dev/sdc
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
[root@mastiscsi ~]#
3. Create LVM to export disk as target
[root@mastiscsi ~]#
pvcreate /dev/sdc -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Writing physical
volume data to disk "/dev/sdc"
Physical volume
"/dev/sdc" successfully created
[root@mastiscsi ~]#
pvcreate /dev/sdc
Writing physical
volume data to disk "/dev/sdc"
Physical volume
"/dev/sdc" successfully created
[root@mastiscsi ~]#
vgcreate multivg /dev/sdc -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Volume group
"multivg" successfully created
[root@mastiscsi ~]#
vgcreate multivg /dev/sdc
Volume group
"multivg" successfully created
[root@mastiscsi ~]#
lvcreate -L 800MB -n multilv multivg -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Logical volume
"multilv" created
[root@mastiscsi ~]#
lvcreate -L 800MB -n multilv multivg
Logical volume
"multilv" created
4. Check newly created PV, VG ad LVM
[root@mastiscsi ~]#
pvdisplay /dev/sdc
--- Physical volume
---
PV Name /dev/sdc
VG Name multivg
PV Size 5.00 GB / not usable 4.00 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 1279
Free PE 1079
Allocated PE 200
PV UUID
Un9URB-fgvf-SBAP-AeAN-7J0I-sLWw-KIWBzI
[root@mastiscsi ~]#
vgdisplay multivg
--- Volume group ---
VG Name multivg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence
No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.00 GB
PE Size 4.00 MB
Total PE 1279
Alloc PE / Size 200 / 800.00 MB
Free PE / Size 1079 / 4.21 GB
VG UUID
pkBZxW-DM3m-a1dz-9MCM-gKd8-DXpr-i2cEMG
[root@mastiscsi ~]#
lvdisplay /dev/multivg/multilv
--- Logical volume
---
LV Name /dev/multivg/multilv
VG Name multivg
LV UUID
vlK9G8-E8lS-bEwX-2w6Z-fAFO-3Rsi-971joA
LV Write Access read/write
LV Status available
# open 0
LV Size 800.00 MB
Current LE 200
Segments 1
Allocation inherit
Read ahead
sectors auto
- currently set
to 256
Block device 253:4
[root@mastiscsi ~]#
5. Add disk into /etc/tgt/targets.conf file
[root@mastiscsi ~]# vi
/etc/tgt/targets.conf
<target iqn.2015-08.com.example:mastiscsi.disk1>
backing-store
/dev/sdb
</target>
<target iqn.2015-08.com.example:mastiscsi.disk2>
backing-store
/dev/multivg/multilv
</target>
6. Reload the tgtd service for exporting newly added disk
[root@mastiscsi ~]#
/etc/init.d/tgtd reload
Updating target framework daemon configuration
New Disk
add on client machine
1. Discovery disk on master server with both IPs
[root@iscsiclient ~]#
iscsiadm -m discoverydb -t st --portal 192.168.144.136:3260 --discover
192.168.144.136:3260,1
iqn.2015-08.com.example:mastiscsi.disk1
192.168.144.136:3260,1
iqn.2015-08.com.example:mastiscsi.disk2
[root@iscsiclient ~]#
iscsiadm -m discoverydb -t st --portal 192.168.144.155:3260 --discover
192.168.144.155:3260,1
iqn.2015-08.com.example:mastiscsi.disk1
192.168.144.155:3260,1
iqn.2015-08.com.example:mastiscsi.disk2
2. Login into newly added disk on master server with both
IPs
[root@iscsiclient ~]#
iscsiadm -m node --portal 192.168.144.136:3260 -T
iqn.2015-08.com.example:mastiscsi.disk2 -l
Logging in to [iface: default, target:
iqn.2015-08.com.example:mastiscsi.disk2, portal: 192.168.144.136,3260]
(multiple)
Login to [iface: default, target:
iqn.2015-08.com.example:mastiscsi.disk2, portal: 192.168.144.136,3260]
successful.
[root@iscsiclient ~]# iscsiadm
-m node --portal 192.168.144.155:3260 -T
iqn.2015-08.com.example:mastiscsi.disk2 -l
Logging in to [iface: default, target:
iqn.2015-08.com.example:mastiscsi.disk2, portal: 192.168.144.155,3260]
(multiple)
Login to [iface: default, target: iqn.2015-08.com.example:mastiscsi.disk2,
portal: 192.168.144.155,3260] successful.
[root@iscsiclient ~]#
3. Check newly disk add by multipath command
[root@iscsiclient ~]#
multipath -ll
mpath1 (1IET_00020001) dm-7 IET,VIRTUAL-DISK
[size=800M][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 33:0:0:1 sdd
8:48 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 34:0:0:1 sde
8:64 [active][ready]
mpath0 (1IET_00010001) dm-4 IET,VIRTUAL-DISK
[size=4.0G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 31:0:0:1 sdb
8:16 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 32:0:0:1 sdc
8:32 [active][ready]
[root@iscsiclient ~]#
4 Check disk space newly added and visible on multipath
output
[root@iscsiclient ~]#
fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sda1 * 1 32 257008+
83 Linux
/dev/sda2
33 5221 41680642+
8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdb1
1 522 4192933+
8e Linux LVM
Disk /dev/sdc: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/sdc1
1 522 4192933+
8e Linux LVM
Disk /dev/dm-4: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/dm-4p1
1 522 4192933+
8e Linux LVM
Disk /dev/dm-5: 4293 MB, 4293563904 bytes
255 heads, 63 sectors/track, 521 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-5 doesn't contain a valid partition table
Disk /dev/sdd: 838 MB,
838860800 bytes
26 heads, 62
sectors/track, 1016 cylinders
Units = cylinders of 1612
* 512 = 825344 bytes
Disk /dev/sdd doesn't
contain a valid partition table
Disk /dev/dm-7: 838 MB,
838860800 bytes
255 heads, 63
sectors/track, 101 cylinders
Units = cylinders of 16065
* 512 = 8225280 bytes
Disk /dev/dm-7 doesn't contain a valid partition table
Disk /dev/sde: 838 MB, 838860800 bytes
26 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 1612 * 512 = 825344 bytes
Disk /dev/sde doesn't contain a valid partition table
[root@iscsiclient ~]#
5. List current device mapper
[root@iscsiclient ~]# ls
-l /dev/mapper/
total 0
crw------- 1 root root
10, 60 Aug 27 19:03 control
brw-rw---- 1 root disk 253,
4 Aug 27 19:04 mpath0
brw-rw---- 1 root disk 253,
5 Aug 27 19:39 mpath0p1
brw-rw---- 1 root disk
253, 7 Aug 27 21:30 mpath1
brw-rw---- 1 root disk 253,
2 Aug 27 19:03 vg0-home
brw-rw---- 1 root disk 253,
0 Aug 27 19:03 vg0-root
brw-rw---- 1 root disk 253,
3 Aug 27 19:03 vg0-swap
brw-rw---- 1 root disk 253,
1 Aug 27 19:03 vg0-var
brw-rw---- 1 root disk 253,
6 Aug 27 19:44 wasvg-wasvg--datalv
6. Now partition the newly added disk
[root@iscsiclient ~]#
fdisk -l /dev/mapper/mpath1
Disk /dev/mapper/mpath1: 838 MB, 838860800 bytes
255 heads, 63 sectors/track, 101 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/mapper/mpath1 doesn't contain a valid partition
table
[root@iscsiclient ~]#
fdisk /dev/mapper/mpath1
Command (m for help): p
Disk /dev/mapper/mpath1: 838 MB, 838860800 bytes
255 heads, 63 sectors/track, 101 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
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 cylinder (1-101, default 1): <enter>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-101, default
101): <enter>
Using default value 101
Command (m for help): p
Disk /dev/mapper/mpath1: 838 MB, 838860800 bytes
255 heads, 63 sectors/track, 101 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
83 Linux
Command (m for help):
t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/mapper/mpath1: 838 MB, 838860800 bytes
255 heads, 63 sectors/track, 101 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22:
Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@iscsiclient ~]#
fdisk -l /dev/mapper/mpath1
Disk /dev/mapper/mpath1: 838 MB, 838860800 bytes
255 heads, 63 sectors/track, 101 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
8e Linux LVM
[root@iscsiclient ~]#
partprobe /dev/mapper/mpath1
[root@iscsiclient ~]#
partprobe /dev/mapper/mpath1p1
7. Create PV, VG and LVM on new partition
[root@iscsiclient ~]#
pvcreate /dev/mapper/mpath1p1 -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Writing physical
volume data to disk "/dev/mapper/mpath1p1"
Physical volume
"/dev/mapper/mpath1p1" successfully created
[root@iscsiclient ~]#
pvcreate /dev/mapper/mpath1p1
Writing physical
volume data to disk "/dev/mapper/mpath1p1"
Physical volume
"/dev/mapper/mpath1p1" successfully created
[root@iscsiclient ~]#
vgcreate mpath1vg /dev/mapper/mpath1p1 -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Volume group
"mpath1vg" successfully created
[root@iscsiclient ~]#
vgcreate mpath1vg /dev/mapper/mpath1p1
Volume group
"mpath1vg" successfully created
[root@iscsiclient ~]#
lvcreate -L 600M -n mpath1-lv mpath1vg
-t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Logical volume
"mpath1-lv" created
[root@iscsiclient ~]#
lvcreate -L 600M -n mpath1-lv mpath1vg
Logical volume
"mpath1-lv" created
8. Display PV, VG and LVM
[root@iscsiclient ~]#
pvdisplay /dev/mapper/mpath1p1
--- Physical volume
---
PV Name /dev/mapper/mpath1p1
VG Name mpath1vg
PV Size 792.24 MB / not usable 243.00 KB
Allocatable yes
PE Size (KByte) 4096
Total PE 198
Free PE 48
Allocated PE 150
PV UUID PvY0Jc-LWfy-Cz9F-93v4-8a8T-GRCc-72wkHd
[root@iscsiclient ~]#
vgdisplay mpath1vg
--- Volume group ---
VG Name mpath1vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence
No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 792.00 MB
PE Size 4.00 MB
Total PE 198
Alloc PE / Size 150 / 600.00 MB
Free PE / Size 48 / 192.00 MB
VG UUID
33jdf6-tP2I-pXm6-kioh-OWvm-fL69-mnswiQ
[root@iscsiclient ~]#
lvdisplay /dev/mpath1vg/mpath1-lv
--- Logical volume
---
LV Name /dev/mpath1vg/mpath1-lv
VG Name mpath1vg
LV UUID
L1ZDxM-WTwI-792x-qU1e-hFmi-8SP1-jGoqXe
LV Write Access read/write
LV Status available
# open 0
LV Size 600.00 MB
Current LE 150
Segments 1
Allocation inherit
Read ahead
sectors auto
- currently set
to 256
Block device 253:9
[root@iscsiclient ~]#
9. Create File System on newly added disk
[root@iscsiclient /]# mkfs
-t ext3 /dev/mpath1vg/mpath1-lv
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
76800 inodes, 153600 blocks
7680 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=159383552
5 block groups
32768 blocks per group, 32768 fragments per group
15360 inodes per group
Superblock backups stored on blocks:
32768, 98304
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 34 mounts
or
180 days, whichever comes first. Use tune2fs -c or -i to override.
10. Mount file system and check
[root@iscsiclient /]#
mount -t ext3 /dev/mpath1vg/mpath1-lv /mpath1-lv/
[root@iscsiclient /]# df
-h
Filesystem
Size Used Avail Use% Mounted on
/dev/mapper/vg0-root
20G 3.1G 16G
17% /
/dev/mapper/vg0-var
9.7G 222M 9.0G
3% /var
/dev/mapper/vg0-home
992M 34M 908M
4% /home
/dev/sda1
244M 14M 218M
6% /boot
tmpfs
500M 0 500M
0% /dev/shm
/dev/mapper/mpath0p1
4.0G 73M 3.7G
2% /datalv
/dev/mapper/mpath1vg-mpath1--lv
591M 17M
545M 3% /mpath1-lv
[root@iscsiclient /]#
11. Creating file in newly created file system
[root@iscsiclient /]# ls
-l > /mpath1-lv/ls-l.txt
[root@iscsiclient /]# ls
-l /mpath1-lv/
total 20
drwx------ 2 root root 16384 Aug 29 15:22 lost+found
-rw-r--r-- 1 root root
1245 Aug 29 15:23 ls-l.txt
[root@iscsiclient /]#
Extend
(resize) disk on master
1. View Current disk space on Master Server
[root@mastiscsi ~]# pvdisplay /dev/sdc
--- Physical volume
---
PV Name /dev/sdc
VG Name multivg
PV Size 5.00 GB / not usable 4.00 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 1279
Free PE 1079
Allocated PE 200
PV UUID
Un9URB-fgvf-SBAP-AeAN-7J0I-sLWw-KIWBzI
[root@mastiscsi ~]#
vgdisplay multivg
--- Volume group ---
VG Name multivg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 5.00 GB
PE Size 4.00 MB
Total PE 1279
Alloc PE / Size 200 / 800.00 MB
Free PE / Size 1079 / 4.21 GB
VG UUID
pkBZxW-DM3m-a1dz-9MCM-gKd8-DXpr-i2cEMG
[root@mastiscsi ~]#
lvdisplay /dev/multivg/multilv
--- Logical volume
---
LV Name /dev/multivg/multilv
VG Name multivg
LV UUID
vlK9G8-E8lS-bEwX-2w6Z-fAFO-3Rsi-971joA
LV Write Access read/write
LV Status available
# open 0
LV Size 800.00 MB
Current LE 200
Segments 1
Allocation inherit
Read ahead
sectors auto
- currently set
to 256
Block device 253:4
[root@mastiscsi ~]#
2. Extend LVM on Master server
--------------------------
[root@mastiscsi ~]#
lvextend -L +100MB /dev/multivg/multilv -t
[root@mastiscsi ~]#
lvextend -L +100MB /dev/multivg/multilv
Extending logical
volume multilv to 900.00 MB
Logical volume
multilv successfully resized
[root@mastiscsi ~]#
lvdisplay /dev/multivg/multilv
--- Logical volume
---
LV Name /dev/multivg/multilv
VG Name multivg
LV UUID
vlK9G8-E8lS-bEwX-2w6Z-fAFO-3Rsi-971joA
LV Write Access read/write
LV Status available
# open 1
LV Size 900.00 MB
Current LE 225
Segments 1
Allocation inherit
Read ahead
sectors auto
- currently set
to 256
Block device 253:4
[root@mastiscsi ~]#
2. Show target details
[root@mastiscsi ~]# tgtadm
--op show --mode target
Target 1: iqn.2015-08.com.example:mastiscsi.disk1
System information:
Driver: iscsi
State: ready
I_T nexus
information:
I_T nexus: 7
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
I_T nexus: 10
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
LUN information:
LUN: 0
Type:
controller
SCSI ID:
IET 00010000
SCSI SN:
beaf10
Size: 0 MB,
Block size: 1
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: null
Backing
store path: None
Backing
store flags:
LUN: 1
Type: disk
SCSI ID:
IET 00010001
SCSI SN:
beaf11
Size: 4295
MB, Block size: 512
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: rdwr
Backing
store path: /dev/sdb
Backing
store flags:
Account
information:
ACL information:
ALL
Target 2: iqn.2015-08.com.example:mastiscsi.disk2
System information:
Driver: iscsi
State: ready
I_T nexus
information:
I_T nexus: 8
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
I_T nexus: 9
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
LUN information:
LUN: 0
Type:
controller
SCSI ID:
IET 00020000
SCSI SN:
beaf20
Size: 0 MB,
Block size: 1
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: null
Backing
store path: None
Backing
store flags:
LUN: 1
Type: disk
SCSI ID:
IET 00020001
SCSI SN:
beaf21
Size: 839 MB, Block size: 512
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: rdwr
Backing
store path: /dev/multivg/multilv
Backing
store flags:
Account
information:
ACL information:
ALL
3. Delete logical unit 1 and target 2 temporarily, it will
not effect on client side
[root@mastiscsi ~]# tgtadm --op delete --mode logicalunit
--tid=2 --lun=1
4. View exported target backup-store path
[root@mastiscsi ~]# more
/etc/tgt/targets.conf
<target iqn.2015-08.com.example:mastiscsi.disk1>
backing-store
/dev/sdb
</target>
<target iqn.2015-08.com.example:mastiscsi.disk2>
backing-store
/dev/multivg/multilv
</target>
5. Again add new logical unit 1 and target 2
[root@mastiscsi ~]# tgtadm
--op new --mode logicalunit --tid=2 --lun=1 --backing-store
/dev/multivg/multilv
6. Check newly updated size
[root@mastiscsi ~]# tgtadm
--op show --mode target
:
:
:
Target 2: iqn.2015-08.com.example:mastiscsi.disk2
System information:
Driver: iscsi
State: ready
I_T nexus
information:
I_T nexus: 8
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
I_T nexus: 9
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
LUN information:
LUN: 0
Type:
controller
SCSI ID:
IET 00020000
SCSI SN:
beaf20
Size: 0 MB,
Block size: 1
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: null
Backing
store path: None
Backing
store flags:
LUN: 1
Type: disk
SCSI ID:
IET 00020001
SCSI SN:
beaf21
Size: 944 MB, Block size: 512
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: rdwr
Backing store path: /dev/multivg/multilv
Backing
store flags:
Account information
ACL information:
ALL
[root@mastiscsi ~]#
Same output can also be check by below command
[root@mastiscsi ~]#
tgt-admin -s
:
:
:
Target 2: iqn.2015-08.com.example:mastiscsi.disk2
System information:
Driver: iscsi
State: ready
I_T nexus
information:
I_T nexus: 8
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
I_T nexus: 9
Initiator:
iqn.2015-08.com.example:mastiscsi
Connection:
0
IP
Address: 192.168.144.153
LUN information:
LUN: 0
Type:
controller
SCSI ID:
IET 00020000
SCSI SN:
beaf20
Size: 0 MB,
Block size: 1
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: null
Backing
store path: None
Backing
store flags:
LUN: 1
Type: disk
SCSI ID:
IET 00020001
SCSI SN:
beaf21
Size: 944 MB, Block size: 512
Online: Yes
Removable
media: No
Readonly:
No
Backing
store type: rdwr
Backing
store path: /dev/multivg/multilv
Backing
store flags:
Account
information:
ACL information:
ALL
[root@mastiscsi ~]#
Scan
newly updated size on client machine
1. Check current disk size
[root@iscsiclient ~]#
multipath -ll
mpath1 (1IET_00020001) dm-5 IET,VIRTUAL-DISK
[size=800M][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 34:0:0:1 sdc 8:32 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 33:0:0:1 sdd 8:48 [active][ready]
mpath0 (1IET_00010001) dm-4 IET,VIRTUAL-DISK
[size=4.0G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 31:0:0:1 sdb
8:16 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 32:0:0:1 sde 8:64 [active][ready]
2. Scan block device
[root@iscsiclient ~]# echo
1 > /sys/block/sdc/device/rescan
[root@iscsiclient ~]# echo
1 > /sys/block/sdd/device/rescan
3. Check disk but not update
[root@iscsiclient ~]#
multipath -ll
mpath1 (1IET_00020001) dm-5 IET,VIRTUAL-DISK
[size=800M][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 34:0:0:1 sdc
8:32 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 33:0:0:1 sdd
8:48 [active][ready]
mpath0 (1IET_00010001) dm-4 IET,VIRTUAL-DISK
[size=4.0G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 31:0:0:1 sdb
8:16 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 32:0:0:1 sde
8:64 [active][ready]
4. Resize map by multipathd command
[root@iscsiclient ~]#
multipathd -k'resize map mpath1'
ok
Note: above space between –k and 'resize map mpath1' NOT allow
5. Check disk, now size updated
[root@iscsiclient ~]#
multipath –ll
mpath1 (1IET_00020001) dm-5 IET,VIRTUAL-DISK
[size=900M][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 34:0:0:1 sdc
8:32 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 33:0:0:1 sdd
8:48 [active][ready]
mpath0 (1IET_00010001) dm-4 IET,VIRTUAL-DISK
[size=4.0G][features=0][hwhandler=0][rw]
\_ round-robin 0 [prio=1][active]
\_ 31:0:0:1 sdb
8:16 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 32:0:0:1 sde
8:64 [active][ready]
[root@iscsiclient ~]#
6. Check disk space
[root@iscsiclient /]#
fdisk -l /dev/mapper/mpath1
Disk /dev/mapper/mpath1: 943
MB, 943718400 bytes
255 heads, 63 sectors/track, 114 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
8e Linux LVM
7. Make disk partition for extending LVM
[root@iscsiclient /]#
fdisk /dev/mapper/mpath1
Command (m for help): p
Disk /dev/mapper/mpath1: 943 MB, 943718400 bytes
255 heads, 63 sectors/track, 114 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (102-114, default 102): <enter>
Using default value 102
Last cylinder or +size or +sizeM or +sizeK (102-114, default
114): <enter>
Using default value 114
Command (m for help): p
Disk /dev/mapper/mpath1: 943 MB, 943718400 bytes
255 heads, 63 sectors/track, 114 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
8e Linux LVM
/dev/mapper/mpath1p2
102 114 104422+
83 Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): p
Disk /dev/mapper/mpath1: 943 MB, 943718400 bytes
255 heads, 63 sectors/track, 114 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot Start End Blocks
Id System
/dev/mapper/mpath1p1 1 101 811251
8e Linux LVM
/dev/mapper/mpath1p2 102 114 104422+
8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22:
Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@iscsiclient /]#
partprobe /dev/mapper/mpath1
device-mapper: remove ioctl failed: Device or resource busy
Warning: parted was unable to re-read the partition table on
/dev/mapper/mpath1 (Device or resource busy).
This means Linux won't know anything about the modifications you made.
device-mapper: create ioctl failed: Device or resource busy
device-mapper: remove ioctl failed: Device or resource busy
[root@iscsiclient /]#
partprobe /dev/mapper/mpath1p2
Note: above both commands
(partprobe /dev/mapper/mpath1 & partprobe /dev/mapper/mpath1p2) require to
run. Error comes on first command. It is ok
8. Check new device mapper list
[root@iscsiclient /]# ls
-l /dev/mapper/
total 0
crw------- 1 root root
10, 60 Aug 28 18:37 control
brw-rw---- 1 root disk 253,
4 Aug 28 18:37 mpath0
brw-rw---- 1 root disk 253,
7 Aug 29 14:58 mpath0p1
brw-rw---- 1 root disk 253,
5 Aug 29 15:35 mpath1
brw-rw---- 1 root disk 253,
6 Aug 29 14:54 mpath1p1
brw-rw---- 1 root disk
253, 9 Aug 29 15:36 mpath1p2
brw-rw---- 1 root disk 253,
8 Aug 29 15:22 mpath1vg-mpath1--lv
brw-rw---- 1 root disk 253,
2 Aug 28 18:37 vg0-home
brw-rw---- 1 root disk 253,
0 Aug 28 18:37 vg0-root
brw-rw---- 1 root disk 253,
3 Aug 28 18:37 vg0-swap
brw-rw---- 1 root disk 253,
1 Aug 28 18:37 vg0-var
[root@iscsiclient /]#
9. Create PV and extend VG & LVM
[root@iscsiclient /]#
pvcreate /dev/mapper/mpath1p2 -t
[root@iscsiclient /]#
pvcreate /dev/mapper/mpath1p2
[root@iscsiclient /]#
vgextend mpath1vg /dev/mapper/mpath1p2 -t
[root@iscsiclient /]#
vgextend mpath1vg /dev/mapper/mpath1p2
[root@iscsiclient /]#
lvextend -l +100%FREE /dev/mpath1vg/mpath1-lv -t
Test mode: Metadata
will NOT be updated and volumes will not be (de)activated.
Extending logical
volume mpath1-lv to 892.00 MB
Logical volume
mpath1-lv successfully resized
[root@iscsiclient /]#
lvextend -l +100%FREE /dev/mpath1vg/mpath1-lv
Extending logical
volume mpath1-lv to 892.00 MB
Logical volume
mpath1-lv successfully resized
Note: for specific size
run below command
[root@iscsiclient /]# lvextend -L +500M
/dev/mpath1vg/mpath1-lv
10. Resize file system
[root@iscsiclient /]#
resize2fs /dev/mpath1vg/mpath1-lv
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mpath1vg/mpath1-lv is mounted on
/mpath1-lv; on-line resizing required
Performing an on-line resize of /dev/mpath1vg/mpath1-lv to
228352 (4k) blocks.
The filesystem on /dev/mpath1vg/mpath1-lv is now 228352
blocks long.
11. Check disk space
[root@iscsiclient /]# df
-h
Filesystem
Size Used Avail Use% Mounted on
/dev/mapper/vg0-root
20G 3.1G 16G
17% /
/dev/mapper/vg0-var
9.7G 222M 9.0G
3% /var
/dev/mapper/vg0-home
992M 34M 908M
4% /home
/dev/sda1
244M 14M 218M
6% /boot
tmpfs
500M 0 500M
0% /dev/shm
/dev/mapper/mpath0p1
4.0G 73M 3.7G
2% /datalv
/dev/mapper/mpath1vg-mpath1--lv
879M 17M
820M 2% /mpath1-lv
[root@iscsiclient /]#
No comments:
Post a Comment