How to resize iscsi volume in Linux

root's picture

Resize of iscsi device is pretty simple and the modification can be seen on linux client without reboot even.

Adding the iscsi disk can be done like in the example below:

root@pluto:~# iscsiadm -m discovery -t sendtargets -p 192.168.69.1
192.168.69.1:3260,1 iqn.2014-07.ro.gz.sun:backups
192.168.69.1:3260,1 iqn.2014-07.ro.gz.sun:swap-pluto
[color=green]192.168.69.1:3260,1 iqn.2014-07.ro.gz.sun:backups-file[/color]
root@pluto:~# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2014-07.ro.gz.sun:backups-file, portal: 192.168.69.1,3260] (multiple)
Login to [iface: default, target: iqn.2014-07.ro.gz.sun:backups-file, portal: 192.168.69.1,3260] successful.

With fdisk -l you can see the disk size and apparently it is kinda small:

root@pluto:~# fdisk -l /dev/sdd

Disk /dev/sdd: [color=red]367 MB[/color], 367001600 bytes
12 heads, 59 sectors/track, 1012 cylinders, total 716800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdd doesn't contain a valid partition tabl

In this situation, you have to go back to storage machine (FreeNAS in my case) resize the iscsi device, and re-scan it on the linux client:

iscsiadm -m node --targetname iqn.2014-07.ro.gz.sun:backups-file -R

The output should be as follows:
root@pluto:~# iscsiadm -m node --targetname iqn.2014-07.ro.gz.sun:backups-file -R
Rescanning session [sid: 3, target: iqn.2014-07.ro.gz.sun:backups-file, portal: 192.168.69.1,3260]

Now, if we do again the fdisk command, iscsi disk should have the new size:

root@pluto:~# fdisk -l /dev/sdd
Disk /dev/sdd: [color=green]375.8 GB[/color], 375809638400 bytes
255 heads, 63 sectors/track, 45689 cylinders, total 734003200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk identifier: 0x00000000

Disk /dev/sdd doesn't contain a valid partition table

How to resize ISCSI in multipath:

Here you may need to umount your filesystem(s) unless you have mirroring and you can take off the mirrors one after another.

1. The size of the disk was initially 100G:

root@pluto:~# multipath -ll
oglebkp (33000000019d54e80) dm-10 FreeBSD,iSCSI Disk
size=[color=red]100G[/color] features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=0 status=active
  |- 4:0:0:0  sdf 8:80  active ready running
  `- 5:0:0:0  sdg 8:96  active ready running

2. Disconnect your ISCSI disks:

root@pluto:~# iscsiadm -m node --targetname iqn.2014-07.ro.gz.ogle:backups -u
Logging out of session [sid: 3, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.69.104,3260]
Logging out of session [sid: 4, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.70.104,3260]
Logout of [sid: 3, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.69.104,3260] successful.
Logout of [sid: 4, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.70.104,3260] successful.

3. Go to your storage (FreeNAS in my case) and resize the ISCSI devices:

4. Reattach the ISCSI devices:

root@pluto:~# iscsiadm -m node --login -p 192.168.69.104
Logging in to [iface: default, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.69.104,3260] (multiple)
Login to [iface: default, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.69.104,3260] successful.
root@pluto:~# iscsiadm -m node --login -p 192.168.70.104
Logging in to [iface: default, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.70.104,3260] (multiple)
Login to [iface: default, target: iqn.2014-07.ro.gz.ogle:backups, portal: 192.168.70.104,3260] successful.

Now you should see the new size on multipath command and fdisk of course:

root@pluto:~# multipath -ll
oglebkp (33000000019d54e80) dm-10 FreeBSD,iSCSI Disk
size=[color=green]200G[/color] features='1 queue_if_no_path' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=0 status=active
  |- 21:0:0:0 sdg 8:96  active ready running
  `- 20:0:0:0 sdf 8:80  active ready running

root@pluto:~# fdisk -l /dev/mapper/oglebkp

Disk /dev/mapper/oglebkp: [color=green]214.7 GB[/color], 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk identifier: 0x00000000

              Device Boot      Start         End      Blocks   Id  System
/dev/mapper/oglebkp1              63   209715199   104857568+  a5  FreeBSD

If you do not see the new size, you may have to rescan your multipath device:

root@pluto:~# multipathd -k'resize map oglebkp'
ok

Thou shalt not steal!

If you want to use this information on your own website, please remember: by doing copy/paste entirely it is always stealing and you should be ashamed of yourself! Have at least the decency to create your own text and comments and run the commands on your own servers and provide your output, not what I did!

Or at least link back to this website.

Recent content

root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root