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
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.
Step3: New block volume has been created and you can view and find it available.
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-->
Step2: Choose Attachment and Access type and select instance name and the path. Click Attach.
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
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
Step3: Run lsblk command to check the existing volumes in the server.
lsblk
Step4: Go to the attached block volumes and then click on the 3 dots at the end.
Step5: Click ISCSI commands and information
Step6: Copy the connect command
Step7: Paste in the putty server.
Step8: Run again lsblk to check the BV and one new volume is created.
lsblk
Step9: Run df –h command to check if this volume is showing or not.
df -h
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
Step2: Type “n” to create a new partition. Select default.
Step3: Type w in help to write the partition and then run lsblk to check the partition.
6.5_Create a Physical Volume
Step1:Run pvcreate command to create physical volume.
pvcreate /dev/sdb1
Step2: Run pvdisplay to see the volume.
pvdisplay /dev/sdb1
6.5_Create a Volume Group
Step1: Create a volume group by running vgcreate.
vgcreate vg_u01 /dev/sdb1
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
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
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.
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