-3

This is what I needed,

1. Add new disk
2. Create New pv, vg and lv as per below plan

Plan
/dev/mapper/PJR_sapvg1-USR_SAP_PJR  /usr/sap/PJR/sapmnt/GJR 20Gb      
/dev/mapper/PJR_sapvg1-SAPMNT_PJR   /sapmnt/PJR/db2/db2gjr  20Gb

This is what I have done:

pvcreate /dev/sdc

vgcreate vg_GJR /dev/sdc

lvcreate -L 1G -n lv_usr_ORACLE_GJR vg_GJR

lvcreate -L 1G -n lv_ORACLEmnt_GJR vg_GJR

mkfs -t ext4 /dev/vg_GJR/lv_usr_sap_GJR

mkfs -t ext4 /dev/vg_GJR/lv_sapmnt_GJR

mkdir /usr/sap/GJR /sapmnt/GJR

mount /dev/vg_GJR/lv_sapmnt_GJR /usr/sap/GJR

mount /dev/vg_GJR/lv_sapmnt_GJR /sapmnt/GJR

At this point, I can see partitions in df -h output. I can create files in both /usr/sap/GJR and /sapmnt/GJR. I added entries in fstab.

Now, just for checking, I did this :

fdisk /dev/sdc

and created a new partiton like below:

Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdbc7821a

Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1          14      112423+  83  Linux

I rebooted the server, but now when I do mount -a , I am getting below error:

[root@localhost ~]# mount -a
mount: special device /dev/vg_GJR/lv_usr_ORACLE_GJR does not exist
mount: special device /dev/vg_GJR/lv_ORACLEmnt_GJR does not exist

I want to know why this happens and how to recover. This is just testing environment with no data. And what should I have done to recover this.

1 Answers1

1

fdisk, gdisk, pvcreate etc normally put a partition label at the beginning of a disk so that different partitions can be created and used.

Doing

"pvcreate /dev/sdc"
normally initializes your /dev/sdc to be used for LVM and thus you were able to create a volume group out of that.

Running

"fdisk /dev/sdc"
should have given you a warning that this device is being used under LVM and but it didn't. Probably because by default, the LVM label is placed in the second 512-byte sector.

So, to sum everything up, if you have used a whole disk for LVM, never touch that disk with fdisk or gdisk. However, if you partition your disk using fdisk first and then do pvcreate on one of the partition, you can still play with the disk using fdisk without touching lvm partition. For example;

# fdisk /dev/sdc # create 2 partitions /dev/sdc1 and /dev/sdc2
# pvcreate /dev/sdc1
# vgcreate vg_GJR /dev/sdc1
# lvcreate -L 1G -n lv_usr_ORACLE_GJR vg_GJR
# lvcreate -L 1G -n lv_ORACLEmnt_GJR vg_GJR
# mkfs -t ext4 /dev/vg_GJR/lv_usr_sap_GJR
# mkfs -t ext4 /dev/vg_GJR/lv_sapmnt_GJR
# mkdir /usr/sap/GJR /sapmnt/GJR
# mount /dev/vg_GJR/lv_sapmnt_GJR /usr/sap/GJR
# mount /dev/vg_GJR/lv_sapmnt_GJR /sapmnt/GJR

Now you can do fdisk /dev/sdc but don't try to delete first partition.

Zul K Irshad
  • 154
  • 4