6_Creating_Attaching_Block_Volume - Nirvan-Pandey/OCI_DOC GitHub Wiki

Steps to create a Block Volume & attach to a Compute Instance

6.1_Steps to create a Block Volume

Step1: Navigate to Burger Menu --> Storage --> Block Volumes --> Create Block Volume

image

image

Step2: Fill in the details - Block Volume Name, Compartment Name, Availability zone etc and click on "Create Block Volume".

Note: Please ensure to create the Block volume in the same Compartment and Availability zone as the compute instance, so that it can be added to it.

image

image image image

Step3: New block volume has been created and you can view and find it available.

image

6.2_Attaching a Block Volume to a Compute Instance

Step1: Navigate Storage-->Block Volumes-->Select the newly created Block Volume-->Click on the Attached Instances(Left hand side)-->Attach to a instance-->

image image image

Step2: Choose Attachment and Access type and select instance name and the path. Click Attach.

image image image

Step3: Reconfirm the instance has attached volume. Navigate to Burger Menu --> Compute --> Instances --> Click on the Instance where the Block Volume was attached --> Go to "Attached Block Volumes" -->

The added Block volume can be seen image

6.3_Reflecting the Block Volume in server

Step1: After the Block Volume had been attached, Login to the server through Putty, in order to update the new volume in the server.

Step2: You will login through opc user which is the instance user. For performing to root user, we need to use the sudo command.

sudo su - root

image

Step3: Run lsblk command to check the existing volumes in the server.

lsblk

image

Step4: Go to the attached block volumes and then click on the 3 dots at the end.

image

Step5: Click ISCSI commands and information

image

Step6: Copy the connect command

image

Step7: Paste in the putty server.

image

Step8: Run again lsblk to check the BV and one new volume is created.

lsblk

image

Step9: Run df –h command to check if this volume is showing or not.

df -h

image

As the volume is still not showing, we need to mount this volume to be ready to be used.

6.4_Create a New Partition

Step1: Format the disk and type m for help.

fdisk /dev/sdb

image image

Step2: Type “n” to create a new partition. Select default.

image

Step3: Type w in help to write the partition and then run lsblk to check the partition.

image image

6.5_Create a Physical Volume

Step1:Run pvcreate command to create physical volume.

pvcreate /dev/sdb1

image

Step2: Run pvdisplay to see the volume.

image

pvdisplay /dev/sdb1

6.5_Create a Volume Group

Step1: Create a volume group by running vgcreate.

vgcreate vg_u01 /dev/sdb1

image

vgdisplay vg_u01

Run “vgdisplay vg_u01” to display the volume group created and to see the Number of Physical Extent.

6.6_Create a logical volume by lvcreate and map it to our volume group

Step1: Creating Logical Volume & Mapping it Volume group

lvcreate -l 12799 -n lv_u01 vg_u01

ls -l /dev/mapper/vg_u01-lv_u01

image

Logical volume is created inside our volume group .

6.7_Formatting this logical volume using a file system

Step1: Running the command mkfs using ext4 file system.

mkfs.ext4 /dev/mapper/vg_u01-lv_u01

image

6.8_Creating a Directory to mount the logical volume

Step1: Making directory and mounting it.

mkdir /u01

mount -t ext4  /dev/mapper/vg_u01-lv_u01  /u01

Step2: After mounting run df -h to see that the logical volume is mounted.

image

6.9_Mount the volume permanently in /etc/fstab or else it will get removed after the server reboots.

Step1: Go to etc folder

cd /etc

Step2: Edit the fstab file and add the line below in it.

vi fstab
/dev/mapper/vg_u01-lv_u01  /u01  ext4  defaults,_netdev,nofail 0 2

Step3: After adding this line in /etc/fstab, we have to run mount –a command.

mount -a

Step4: Run the command "systemctl daemon-reload" to mount this volume premanently.

systemctl daemon-reload

Step5: See Again to confirm by using df -h

image