Showing posts with label OCI. Show all posts
Showing posts with label OCI. Show all posts

Monday, September 14, 2020

Attach block volume and extending the volume in Linux Instance

 

  1. Create 50GB Block volume
  2. Attach to the instance in Console
  3. Executed iSCSI commands to attach the Block volume to the instance
  4. Created LVM partition
  5. Attached another 50GB of space to the Instance
  6. Extended the existing partition from 50GB to 100GB
  7. Permanently mount the file system to the Server

 

 

[opc@instance-1 ~]$ sudo su -

Last login: Mon Sep 14 10:33:26 GMT 2020 on pts/0

[root@instance-1 ~]# lsblk

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sdb      8:16   0   50G  0 disk

sda      8:0    0 46.6G  0 disk

├─sda2   8:2    0    8G  0 part [SWAP]

├─sda3   8:3    0 38.4G  0 part /

└─sda1   8:1    0  200M  0 part /boot/efi

[root@instance-1 ~]# fdisk /dev/sdb

 

[root@instance-1 ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x61ad2704.

 

The device presents a logical sector size that is smaller than

the physical sector size. Aligning to a physical sector (or optimal

I/O) size boundary is recommended, or performance may be impacted.

 

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

Command (m for help): t

No partition is defined yet!

 

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-104857599, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):

Using default value 104857599

Partition 1 of type Linux and of size 50 GiB is set

 

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): L

 

0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris

1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-

2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-

3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-

4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx

5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data

6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .

7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility

8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt

9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access

a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O

b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor

c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs

e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT

f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/

10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b

11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor

12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor

14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary

16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS

17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep

1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT

1e  Hidden W95 FAT1 80  Old Minix

Hex code (type L to list all codes): 8e

Changed type of partition 'Linux' to 'Linux LVM'

 

Command (m for help): p

 

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 1048576 bytes

Disk label type: dos

Disk identifier: 0x61ad2704

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048   104857599    52427776   8e  Linux LVM

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

 

[root@instance-1 ~]# pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created.

[root@instance-1 ~]# pvdisplay

  "/dev/sdb1" is a new physical volume of "<50.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sdb1

  VG Name

  PV Size               <50.00 GiB

  Allocatable           NO

  PE Size               0

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               lQ1owD-n8Pi-uGvD-5ZO9-Tn4O-uzeA-ulKi4E

 

 

[root@instance-1 ~]# vgcreate block_vol_1 /dev/sdb1

  Volume group "block_vol_1" successfully created

[root@instance-1 ~]# vgdisplay

  --- Volume group ---

  VG Name               block_vol_1

  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               <50.00 GiB

  PE Size               4.00 MiB

  Total PE              12799

  Alloc PE / Size       0 / 0

  Free  PE / Size       12799 / <50.00 GiB

  VG UUID               ZwvYXs-soYp-RZWx-wzho-4qlj-oCvd-u9Hzbp

 

[root@instance-1 ~]# lvcreate -n lv_block_vol_1 -l 100%FREE block_vol_1

  Logical volume "lv_block_vol_1" created.

[root@instance-1 ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/block_vol_1/lv_block_vol_1

  LV Name                lv_block_vol_1

  VG Name                block_vol_1

  LV UUID                wrnCm3-Y0kn-tDYf-xfVJ-SKbn-1CdE-41QpdE

  LV Write Access        read/write

  LV Creation host, time instance-1, 2020-09-14 10:55:53 +0000

  LV Status              available

  # open                 0

  LV Size                <50.00 GiB

  Current LE             12799

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           252:0

 

[root@instance-1 ~]# mkdir /u02

 

 

[root@instance-1 ~]# mkfs.ext4 /dev/block_vol_1/lv_block_vol_1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=256 blocks

3276800 inodes, 13106176 blocks

655308 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2162163712

400 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424

 

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

[root@instance-1 ~]# mount /dev/block_vol_1/lv_block_vol_1 /u02

[root@instance-1 ~]# df -h

Filesystem                              Size  Used Avail Use% Mounted on

devtmpfs                                458M     0  458M   0% /dev

tmpfs                                   486M     0  486M   0% /dev/shm

tmpfs                                   486M  6.8M  479M   2% /run

tmpfs                                   486M     0  486M   0% /sys/fs/cgroup

/dev/sda3                                39G  4.6G   34G  12% /

/dev/sda1                               200M  9.7M  191M   5% /boot/efi

tmpfs                                    98M     0   98M   0% /run/user/0

tmpfs                                    98M     0   98M   0% /run/user/1000

/dev/mapper/block_vol_1-lv_block_vol_1   50G   53M   47G   1% /u02

 

 

 

pvcreate /dev/sdb1

 

pvdisplay

 

vgcreate block_vol_1 /dev/sdb1

 

vgdisplay

 

lvcreate -n lv_block_vol_1 -l 100%FREE block_vol_1

 

lvdisplay

 

blkid

 

mkfs.ext4 /dev/block_vol_1/lv_block_vol_1

 

mount /dev/block_vol_1/lv_block_vol_1 /u02

 

 

sudo iscsiadm -m node -o new -T iqn.2015-12.com.oracleiaas:f67bccaa-1f3a-4211-abb0-3025aa59efb9 -p 169.254.2.4:3260

sudo iscsiadm -m node -o update -T iqn.2015-12.com.oracleiaas:f67bccaa-1f3a-4211-abb0-3025aa59efb9 -n node.startup -v automatic

sudo iscsiadm -m node -T iqn.2015-12.com.oracleiaas:f67bccaa-1f3a-4211-abb0-3025aa59efb9 -p 169.254.2.4:3260 -l

 

 

[root@instance-1 ~]# lsblk

NAME                           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sdb                              8:16   0   50G  0 disk

└─sdb1                           8:17   0   50G  0 part

  └─block_vol_1-lv_block_vol_1 252:0    0   50G  0 lvm  /u02

sdc                              8:32   0   50G  0 disk

sda                              8:0    0 46.6G  0 disk

├─sda2                           8:2    0    8G  0 part [SWAP]

├─sda3                           8:3    0 38.4G  0 part /

└─sda1                           8:1    0  200M  0 part /boot/efi

 

[root@instance-1 ~]# fdisk /dev/sdc

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x01325a11.

 

The device presents a logical sector size that is smaller than

the physical sector size. Aligning to a physical sector (or optimal

I/O) size boundary is recommended, or performance may be impacted.

 

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-104857599, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):

Using default value 104857599

Partition 1 of type Linux and of size 50 GiB is set

 

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): 8e

Changed type of partition 'Linux' to 'Linux LVM'

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@instance-1 ~]# partprobe

[root@instance-1 ~]# lsblk

NAME                           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sdb                              8:16   0   50G  0 disk

└─sdb1                           8:17   0   50G  0 part

  └─block_vol_1-lv_block_vol_1 252:0    0   50G  0 lvm  /u02

sdc                              8:32   0   50G  0 disk

└─sdc1                           8:33   0   50G  0 part

sda                              8:0    0 46.6G  0 disk

├─sda2                           8:2    0    8G  0 part [SWAP]

├─sda3                           8:3    0 38.4G  0 part /

└─sda1                           8:1    0  200M  0 part /boot/efi

[root@instance-1 ~]# pvcreate /dev/sdc1

  Physical volume "/dev/sdc1" successfully created.

[root@instance-1 ~]# vgdisplay

  --- Volume group ---

  VG Name               block_vol_1

  System ID

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  2

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               <50.00 GiB

  PE Size               4.00 MiB

  Total PE              12799

  Alloc PE / Size       12799 / <50.00 GiB

  Free  PE / Size       0 / 0

  VG UUID               0v7BiH-N4jV-KeOQ-V0Wt-xaBl-gZaF-V8RUDX

 

[root@instance-1 ~]# vgextend block_vol_1 /dev/sdc1

  Volume group "block_vol_1" successfully extended

[root@instance-1 ~]# pvscan

  PV /dev/sdb1   VG block_vol_1     lvm2 [<50.00 GiB / 0    free]

  PV /dev/sdc1   VG block_vol_1     lvm2 [<50.00 GiB / <50.00 GiB free]

  Total: 2 [99.99 GiB] / in use: 2 [99.99 GiB] / in no VG: 0 [0   ]

[root@instance-1 ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/block_vol_1/lv_block_vol_1

  LV Name                lv_block_vol_1

  VG Name                block_vol_1

  LV UUID                CzZlRb-Ge5d-db0e-9w6Y-r2bC-lDdH-xSbuyM

  LV Write Access        read/write

  LV Creation host, time instance-1, 2020-09-14 11:59:21 +0000

  LV Status              available

  # open                 1

  LV Size                <50.00 GiB

  Current LE             12799

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           252:0

 

[root@instance-1 ~]# df -h

Filesystem                              Size  Used Avail Use% Mounted on

devtmpfs                                458M     0  458M   0% /dev

tmpfs                                   486M     0  486M   0% /dev/shm

tmpfs                                   486M  6.9M  479M   2% /run

tmpfs                                   486M     0  486M   0% /sys/fs/cgroup

/dev/sda3                                39G  4.6G   34G  12% /

/dev/sda1                               200M  9.7M  191M   5% /boot/efi

tmpfs                                    98M     0   98M   0% /run/user/0

tmpfs                                    98M     0   98M   0% /run/user/1000

/dev/mapper/block_vol_1-lv_block_vol_1   50G   56M   47G   1% /u02

 

 

[root@instance-1 ~]# lvextend /dev/mapper/block_vol_1-lv_block_vol_1 /dev/sdc1

  Size of logical volume block_vol_1/lv_block_vol_1 changed from <50.00 GiB (12799 extents) to 99.99 GiB (25598 extents).

  Logical volume block_vol_1/lv_block_vol_1 successfully resized.

 

[root@instance-1 ~]# resize2fs /dev/mapper/block_vol_1-lv_block_vol_1

resize2fs 1.42.9 (28-Dec-2013)

Filesystem at /dev/mapper/block_vol_1-lv_block_vol_1 is mounted on /u02; on-line resizing required

old_desc_blocks = 7, new_desc_blocks = 13

The filesystem on /dev/mapper/block_vol_1-lv_block_vol_1 is now 26212352 blocks long.

 

[root@instance-1 ~]# df -h

Filesystem                              Size  Used Avail Use% Mounted on

devtmpfs                                458M     0  458M   0% /dev

tmpfs                                   486M     0  486M   0% /dev/shm

tmpfs                                   486M  6.9M  479M   2% /run

tmpfs                                   486M     0  486M   0% /sys/fs/cgroup

/dev/sda3                                39G  4.6G   34G  12% /

/dev/sda1                               200M  9.7M  191M   5% /boot/efi

tmpfs                                    98M     0   98M   0% /run/user/0

tmpfs                                    98M     0   98M   0% /run/user/1000

/dev/mapper/block_vol_1-lv_block_vol_1   99G   64M   94G   1% /u02

[root@instance-1 ~]#

 

[root@instance-1 ~]# blkid

/dev/sda1: SEC_TYPE="msdos" UUID="38DB-ABB6" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="8b9e0da1-e967-49c2-9dd6-57d5671f9cc3"

/dev/sda2: UUID="bf8f71d6-5bae-4981-8eae-2171e78524d6" TYPE="swap" PARTUUID="620b3dc0-3d7f-4858-8676-4069975e3566"

/dev/sda3: UUID="553c3110-8f96-454c-9399-3c5c18f3d631" TYPE="xfs" PARTUUID="13aef1c9-027f-4c13-887d-c5c90607548d"

/dev/sdb1: UUID="3H0nPI-MDd8-x5MK-pCfF-gM08-UcpZ-BKMtZ7" TYPE="LVM2_member"

/dev/mapper/block_vol_1-lv_block_vol_1: UUID="705f125c-e2d0-432a-8cf2-9b3eac232531" TYPE="ext4"

/dev/sdc1: UUID="70Lq3q-09n5-3qb6-ptL3-JwZh-DrUh-UJQ35z" TYPE="LVM2_member"

 

[root@instance-1 ~]# vi /etc/fstab

UUID=705f125c-e2d0-432a-8cf2-9b3eac232531 /u02  ext4    defaults        0 0

 

 

[root@instance-1 ~]# init 6

login as: opc

Authenticating with public key "rsa-key-20200709"

Last login: Mon Sep 14 12:36:22 2020 from 49.207.204.138

[opc@instance-1 ~]$ df -h

Filesystem                              Size  Used Avail Use% Mounted on

devtmpfs                                458M     0  458M   0% /dev

tmpfs                                   486M     0  486M   0% /dev/shm

tmpfs                                   486M  6.8M  479M   2% /run

tmpfs                                   486M     0  486M   0% /sys/fs/cgroup

/dev/sda3                                39G  4.6G   34G  12% /

/dev/sda1                               200M  9.7M  191M   5% /boot/efi

tmpfs                                    98M     0   98M   0% /run/user/0

/dev/mapper/block_vol_1-lv_block_vol_1   99G   64M   94G   1% /u02

tmpfs                                    98M     0   98M   0% /run/user/1000

[opc@instance-1 ~]$