Go to the instance where you have attached your block volume.
Now go to the ssh terminal of this instance and execute:
[opc@instance-infra-for-test ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 47G 0 disk
├─sda1 8:1 0 100M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 45.5G 0 part
├─ocivolume-root 252:0 0 35.5G 0 lvm /
└─ocivolume-oled 252:1 0 10G 0 lvm /var/oled
sdb 8:16 0 50G 0 disk
└─sdb1 8:17 0 50G 0 part /fortest
You can see your block volume has been mounted on /fortest
Now in OCI console, increase by 1G your block volume. As a result the console gives you command lines that must be executed. In these commands you must replace <paste device suffix here>:
sudo dd iflag=direct if=/dev/oracleoci/oraclevd<paste device suffix here> of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/`readlink /dev/oracleoci/oraclevd<paste device suffix here> | cut -d'/' -f 2`/device/rescan
To get the suffix device you can just execute the following:
[root@instance-infra-for-test ~]# ll /dev/oracleoci/orac*
lrwxrwxrwx. 1 root root 6 Sep 6 15:31 /dev/oracleoci/oraclevda -> ../sda
lrwxrwxrwx. 1 root root 7 Sep 6 15:31 /dev/oracleoci/oraclevda1 -> ../sda1
lrwxrwxrwx. 1 root root 7 Sep 5 09:55 /dev/oracleoci/oraclevda2 -> ../sda2
lrwxrwxrwx. 1 root root 7 Sep 5 09:55 /dev/oracleoci/oraclevda3 -> ../sda3
lrwxrwxrwx. 1 root root 6 Sep 6 15:35 /dev/oracleoci/oraclevdb -> ../sdb
lrwxrwxrwx. 1 root root 7 Sep 6 15:35 /dev/oracleoci/oraclevdb1 -> ../sdb1
The suffix is ‘b’
[root@instance-infra-for-test ~]# sudo dd iflag=direct if=/dev/oracleoci/oraclevdb of=/dev/null count=1
1+0 records in
1+0 records out
512 bytes copied, 0.00113204 s, 452 kB/s
[root@instance-infra-for-test ~]# echo "1" | sudo tee /sys/class/block/`readlink /dev/oracleoci/oraclevdb | cut -d'/' -f 2`/device/rescan
1
If you can’t find a symbolic link inside /dev/oracleoci/ you can also simply rescan directly /dev/sdb:
sudo dd iflag=direct if=/dev/sdb of=/dev/null count=1
echo "1" | sudo tee /sys/class/block/sdb/device/rescan
Now execute again lsblk:
[root@instance-infra-for-test ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 47G 0 disk
├─sda1 8:1 0 100M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 45.5G 0 part
├─ocivolume-root 252:0 0 35.5G 0 lvm /
└─ocivolume-oled 252:1 0 10G 0 lvm /var/oled
sdb 8:16 0 51G 0 disk
└─sdb1 8:17 0 50G 0 part /fortest
You can see that the size of your block volume has changed (sdb is now 51G).
But your partition on /fortest doesn’t use 100% of your block volume space, it only uses 50G as before. Then we need to modify the partition to indicate the new end of the partition.
umount /fortest:
[root@instance-infra-for-test ~]# umount /fortest
NOTE: if /fortest is shared via NFS you will have an error ‘/fortest : target busy’. Then you should stop your NFS server (systemctl stop nfs), and at the end you start again your NFS server (systemctl start nfs).
Now use parted on /dev/sdb and execute the following:
it’s important to note the answer to the question “Not all of the space available to /dev/sdb appears to be used……. Fix/Ignore?” ===> answer Fix
Then after you remove the partition number 1 with rm 1 (in case you have only one partition), and you recreate a primary partition of type ext4 that starts to 2048s (it was the previous start of the partition before you rm it, it’s important to respect it for better performance), and that ends at 100% of the volume size.
[root@instance-infra-for-test ~]# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) print
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra 2097152
blocks) or continue with the current setting?
Fix/Ignore? Fix
Model: ORACLE BlockVolume (scsi)
Disk /dev/sdb: 106954752s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 2048s 104857566s 104855519s ext4 gpt
(parted) rm 1
(parted) mkpart primary ext4 2048s 100%
(parted) quit
Then execute e2fsck -f /dev/sdb1 and resize2fs /dev/sdb1:
[root@instance-infra-for-test ~]# e2fsck -f /dev/sdb1
e2fsck 1.46.2 (28-Feb-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/sdb1: 11/3276800 files (0.0% non-contiguous), 284558/13106939 blocks
[root@instance-infra-for-test ~]# resize2fs /dev/sdb1
resize2fs 1.46.2 (28-Feb-2021)
Resizing the filesystem on /dev/sdb1 to 13368832 (4k) blocks.
The filesystem on /dev/sdb1 is now 13368832 (4k) blocks long.
[root@instance-infra-for-test ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 47G 0 disk
├─sda1 8:1 0 100M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 45.5G 0 part
├─ocivolume-root 252:0 0 35.5G 0 lvm /
└─ocivolume-oled 252:1 0 10G 0 lvm /var/oled
sdb 8:16 0 51G 0 disk
└─sdb1 8:17 0 51G 0 part
NOTE: you don’t work directly on the partition /dev/sdb1 with parted command, but on the disk /dev/sdb, it’s the disk that you partition.
Leave a Reply