Tuesday, December 9, 2014

Mount SAN Storage to Linux Server

Following are the steps to permanently mount a SAN storage Disk on to a Linux Server.

Your system administrator will configure the Storage disk space and map it to the server, where you should use the below steps to mount it permanently on the server,

1. To list the disks that were mapped from SAN storage to the server use the below fdisk list command. Note that due to multipath rpm module not configured on the server it is showing four disks /dev/sda, /dev/sdb, /dev/sdc, /dev/sdd which is actually the one disk from the SAN device but showing four due to multipath fiber channels.

As general steps,
firstly Create the Physical Volume (PVCREATE)
then Volume Group (VGCREATE)
then Logical Volume (LVCREATE) 
then format the Logical Volume using ext3 file system (MKFS) 
and finally permanently mount the Logical Volume.

[root@edolraclin1 ~]# fdisk -l

Disk /dev/cciss/c0d0: 299.9 GB, 299966445568 bytes
255 heads, 32 sectors/track, 71798 cylinders
Units = cylinders of 8160 * 512 = 4177920 bytes

           Device Boot      Start         End      Blocks   Id  System
/dev/cciss/c0d0p1   *           1          25      101984   83  Linux
/dev/cciss/c0d0p2              26       16473    67107840   82  Linux swap / Solaris
/dev/cciss/c0d0p3           16474       71798   225726000   8e  Linux LVM

Disk /dev/dm-0: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 123.7 GB, 123748745216 bytes
255 heads, 63 sectors/track, 15044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn't contain a valid partition table

Disk /dev/sda: 858.9 GB, 858993459200 bytes
255 heads, 63 sectors/track, 104433 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

Disk /dev/sdb: 858.9 GB, 858993459200 bytes
255 heads, 63 sectors/track, 104433 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

Disk /dev/sdc: 858.9 GB, 858993459200 bytes
255 heads, 63 sectors/track, 104433 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

Disk /dev/sdd: 858.9 GB, 858993459200 bytes
255 heads, 63 sectors/track, 104433 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

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

2. Using PVCREATE command, Create the physical volume from the mounted SAN storage disk

[root@edolraclin1 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/cciss/c0d0p3
  VG Name               VolGroup00
  PV Size               215.27 GB / not usable 19.55 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              6888
  Free PE               0
  Allocated PE          6888
  PV UUID               eBQiHf-sgd6-itbc-QJvu-pTMY-WhE9-mqtU2V

[root@edolraclin1 ~]# pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created

3. Using VGCREATE, create the Volume Group,

[root@edolraclin1 ~]# vgcreate VG_DB01 /dev/sdd
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdb not /dev/sda
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdc not /dev/sdb
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdd not /dev/sdc
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sda not /dev/sdd
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdb not /dev/sda
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdc not /dev/sdb
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdd not /dev/sdc
  Volume group "VG_DB01" successfully created

On another server2, I used the below to rename the Vol_DB01 group name to VG_DB01. This step is not required on this server1
[root@edolraclin2 ~]# vgrename Vol_DB01 VG_DB01 

[root@edolraclin1 ~]# vgdisplay
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdb not /dev/sda
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdc not /dev/sdb
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdd not /dev/sdc
  --- Volume group ---
  VG Name               VG_DB01
  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               800.00 GB
  PE Size               4.00 MB
  Total PE              204799
  Alloc PE / Size       0 / 0
  Free  PE / Size       204799 / 800.00 GB
  VG UUID               JuS0EN-aJgI-4dyH-ytgz-ePn0-hJLD-NOzTy1

  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               215.25 GB
  PE Size               32.00 MB
  Total PE              6888
  Alloc PE / Size       6888 / 215.25 GB
  Free  PE / Size       0 / 0
  VG UUID               8GB3cq-T6kK-bnZm-zsfG-dggD-GF9a-PlTqIm

4. Using LVCREATE command, Now create the 800GB logical volume /dev/VG_DB01/LVol_DB01 for the Volume group VG_DB01

[root@edolraclin1 ~]# lvcreate -L 800G -n /dev/VG_DB01/LVol_DB01 VG_DB01
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdb not /dev/sda
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdc not /dev/sdb
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdd not /dev/sdc
  Volume group "VG_DB01" has insufficient free space (204799 extents): 204800 required.

Above didn't got created since I used 800G but when used 799G it worked,

[root@edolraclin1 ~]# lvcreate -L 799G -n /dev/VG_DB01/LVol_DB01 VG_DB01
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdb not /dev/sda
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdc not /dev/sdb
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdd not /dev/sdc
  Logical volume "LVol_DB01" created

[root@edolraclin1 ~]# lvdisplay
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdb not /dev/sda
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdc not /dev/sdb
  Found duplicate PV gN5jnth8YSccwW5U42pzlpLYTQTAeRJe: using /dev/sdd not /dev/sdc
  --- Logical volume ---
  LV Name                /dev/VG_DB01/LVol_DB01
  VG Name                VG_DB01
  LV UUID                lnktqC-AjHx-xwNq-tvky-EOte-SP8A-R9lfxf
  LV Write Access        read/write
 LV Status              available
  # open                 0
  LV Size                799.00 GB
  Current LE             204544
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                o3iXhS-NWXg-42ca-OmOB-jV3u-x3Ai-NRml0g
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                100.00 GB
  Current LE             3200
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                RaY7SC-Gdzq-eB2k-nmyT-PQcN-ybxn-23LSDV
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                115.25 GB
  Current LE             3688
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

5. Now format the logical volume with ext3 file type,

[root@edolraclin1 ~]# mkfs -t ext3 /dev/VG_DB01/LVol_DB01
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
104726528 inodes, 209453056 blocks
10472652 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
6392 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

6. Now mount the logical volume permanently on the server as /u02,

[root@edolraclin1 ~]# cd /
[root@edolraclin1 ~]# mkdir u02
[root@edolraclin1 ~]# vi /etc/fstab

/dev/VG_DB01/LVol_DB01  /u02                    ext3    defaults        1 2

[root@edolraclin1 ~]# mount -a

[root@oiamsrv1 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00  97G  8.2G   84G   9% /
/dev/mapper/VolGroup00-LogVol01  112G   64G   43G  60% /u01
/dev/mapper/VG_DB01-LVol_DB01     787G  197M  747G   1% /u02
/dev/cciss/c0d0p1      97M   31M   62M  34% /boot
tmpfs                  16G     0   16G   0% /dev/shm

You can also use the below GUI tool to configure the LVM.
[root@oiamsrv1 ~]# system-config-lvm

This way you can mount the new SAN storage disk of 800GB on the server.

For any queries please don't hesitate to email me: samiora@gmail.com