08. Creating Block Volume - CloudDarsh/OracleCloud GitHub Wiki

Creating and attaching a block volume to the server

image

image

YouTube Thumbnail (36)

image

After creation of block volume, we have to attach the block volume to the compute instance.

Attaching Block Volume to Instance

Navigation --> Compute --> Instances --> Resource(Attached block volume) --> Attach Block Volume.

image

image

image

image

Reflecting the Block Volume in server

After attaching the block volume, we have to go the server(Putty) , we have to update our new volume in the server.

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

image

Go to three dots  iSCSI commands & information

image

--> Copy the connect command.

image

Run these commands in the server.

image

After this we can check, one new volume will be created

image

We can run “df –h” command to check if this volume is showing or not.

image

It is still not showing so now we have to mount this volume to be ready to be used.

Create a new partition

Format the Disk

Run “fdisk /dev/sdb” command , and type m for help

image

Type “n” to create a new partition,

image

Create a Physical Volume

“pvcreate /dev/sdb1”

image

To display the physical volume created,

“pvdisplay /dev/sdb1”

image

Create a Volume Group

“vgcreate vg_u01 /dev/sdb1”

image

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

Create a logical volume and map it to our 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 .

Format this logical volume using a file system

“mkfs.ext4 /dev/mapper/vg_u01-lv_u01”

image

Create a Directory and mount the logical volume

“mkdir /u01”

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

image

Now we can see the logical volume is mounted.

Mount this volume permanently in /etc/fstab or else after server reboot this volume will be removed.

“/dev/mapper/vg_u01-lv_u01 /u01 ext4 defaults,_netdev,nofail 0 2”

image

We have to add this line in /etc/fstab and run mount –a command.

image

oci bv volume update --volume-id ocid1.volume.oc1.iad.abuwcljtamge5vgjl2clwaftugtldnsfgohessclzrpilo47p5y5j7zbtyvq --size-in-gbs 100

At Server level:-

Step1:- increase the size at device level


1> Verify existing size.

lsblk -ap /dev/sdb | head -2

2> run the scan command

sudo dd iflag=direct if=/dev/sdb of=/dev/null count=1

echo "1" | sudo tee /sys/class/block/sdb/device/rescan

[Result] Physical disk will get increased.

Step2:- Verify if partition exist:-


sudo parted /dev/sdb print

[Expected output]

Partition Table: msdos

Step3:- Increase the partition(part no -1) to new size:-

sudo growpart /dev/sdb 1

lvdisplay -am /dev/mapper/vg_u01-lv_u01

1> Check the current Physical Volume size: #pvdisplay /dev/sdb1 Total PE 12799

2> Resize the Physical Volume

pvresize /dev/sdb1

pvdisplay /dev/sdb1

Total PE 15359

Verfiy if size extended by lsblk.

3> Extend the Logical volume

lvextend -l +100%FREE /dev/mapper/vg_u01-lv_u01

4> resize the filesystem

resize2fs /dev/mapper/vg_u01-lv_u01