SelfMountingExportedVolumes

From ISCSItarget

Jump to: navigation, search

Contents

Mounting volumes exported by IET on the exporting machine

In many usage situations (e.g.: High availability) it might be desirable to use the same backing storage as an IET export or on the local machine: How this works depends on the kind of backing storage exported via IET:

A: disks (sdX, hdX):

No Problem, you can partition them from the initiator and directly mount the partitions (sdXn, hdXn) on the exporting machine after ending the export

B: files, partitions, RAID devices (md), LVM volumes, etc:

You have to do some extra steps.

Here is why - as an example we use a scenario, where /dev/sda3 is exported via IET, this export is partitioned and used on the initiator host. When we now want to mount it locally, we face a dilemma:

  • For the initiator host sda3 (as imported from the target via IET) is a DISK, which must be partioned
  • For the target sda3 is a PARTITION which is again partitioned by the initiator

So to mount this 'partition inside a partition' we first need to "unnest" it - there are some ways to do this, but a loop device might be the easiest way.

4 Steps are needed:

Step 1: Get the partition geometry - You only need to do this once

fdisk -lu /dev/sda3 You see something like

=Disk /dev/sda3: 180.0 GB, 180034928640 bytes
255 heads, 63 sectors/track, 21888 cylinders
Units cylinders of 16065 * 512 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda3p1 63 351614654 175807296 7 HPFS/NTFS=

Note the Start (63) and End (351614654 ) Values - they tell you, that inside sda3 your "partition in a partition" starts at sector 63 and ends at sector 351614654
So:
Offset 63 Blocks 63*512 Bytes=32256 Bytes
Length 351614654-63+1 351614592 Blocks 351614592*512 Bytes 180026671104 Bytes

If you use the last partition up to the end of the disk, you don't need the length, but I'll take it here for clarity

Step 2: Get a free loop device - you have to do this for every boot

Variante 1 (New versions of losetup):
losetup -a
You see something like

=/dev/loop0: 0805:1740 (/var/install/suse93.dvd)
/dev/loop7: 0805:2065 (/var/tmp/aoe/volume)=

You now know, that loop devices 0 and 7 are in use, making 1-6 free. No output means all loop devices are free

Variante 2 (if 1 fails on older versions):
If losetup -a complains, you have an older version that dosesn't understand the -a flag. in this case do
losetup /dev/loop0
losetup /dev/loop1
...
until you get "no such device or address" - again you have found a free loop device.

I now assume that loop1 is free

Step 3: Set up the loop device - you have to do this for every boot

losetup -o 32256 -s 180026671104 /dev/loop1 /dev/sda3

  • option -o 32256 is offset from step 1
  • option -s 180026671104 is length from step 1

parameter /dev/loop1 is free loop device from step 2
parameter /dev/sda3 is your exported volume

Step 4: Mount the loop device - mount/unmount at your discretion

mount /dev/loop1 /your/mount/point

Personal tools