Set up Block Volume on Oracle Cloud

In previous articles about Oracle Cloud’s Always Free Tier program, I introduced how to set up a free lifetime VPS that you can use for AdGuard Home, Pi-Hole or WireGuard VPN. Besides, there is another attractive offer that few people notice that Oracle Cloud also offers 200GB free storage.

By default, each VPS created on the Oracle Cloud system will use 1 Boot Volume with a capacity of 50GB. If you only use 1 VPS only, you can take advantage of the remaining 150GB of the free program to store data.

Here are the Block Volume settings and connecting to the VPS so you can take advantage of the full 200GB of free Oracle Cloud storage.

Table of contents

Create Block Volume

Log in to your Oracle Cloud account and access the Menu in the left corner, select Storage -> Block Volumes

Click the Create Block Volume button to create a new storage partition

The default capacity of Block Volume is 50GB. You can choose Custom and enter the amount of space (GB) you want.

If you enter a number that is too large, exceeding the free limit, the system will notify you that you need to upgrade your premium account.

I’m using 2 VPS on the system, so I only have 100 GB free. Therefore, I chose the size as 100GB, named it: Storage. The remaining items are left to default and click Create Block Volume.

Wait a few minutes, Block Volume is ready to serve.

Connect Block Volume to VPS

Right in the newly created Block Volume page, scroll down and click on Attached Instances

Select Attach to Instance next.

Select the following parameters:

  • Attachment type: Paravirtualized
  • Access Type: Read/Write
  • Instance: select the VPS you want to connect to this Block Volume.

Click Attach to confirm.

Wait a few minutes, the system will notify you that the connection is successful: the State item displays Attached.

Create a drive partition

After successfully connecting Block Volume to VPS, it will show up as a new hard drive on the system.

Check by command lsblk

$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0   49M  1 loop /snap/core18/2252
loop1     7:1    0 60.7M  1 loop /snap/lxd/21843
loop2     7:2    0 57.5M  1 loop /snap/core20/1380
loop4     7:4    0 57.5M  1 loop /snap/core20/1360
loop5     7:5    0 61.2M  1 loop /snap/lxd/22530
loop6     7:6    0 20.7M  1 loop /snap/oracle-cloud-agent/32
loop8     7:8    0   49M  1 loop /snap/core18/2289
loop9     7:9    0 20.7M  1 loop /snap/oracle-cloud-agent/31
loop11    7:11   0 37.7M  1 loop /snap/snapd/14982
sda       8:0    0 46.6G  0 disk
├─sda1    8:1    0 46.5G  0 part /
└─sda15   8:15   0   99M  0 part /boot/efi
sdc       8:32   0  100G  0 disk

The system appears 1 more drive with the code sdc.

I will use gdisk to create a partition for this new drive

gdisk /dev/sdc

Then choose the commands in turn o, n, w to create a new Linux partition.

sudo gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries in memory.

Command (? for help): ?
b       back up GPT data to a file
c       change a partition's name
d       delete a partition
i       show detailed information on a partition
l       list known partition types
n       add a new partition
o       create a new empty GUID partition table (GPT)
p       print the partition table
q       quit without saving changes
r       recovery and transformation options (experts only)
s       sort partitions
t       change a partition's type code
v       verify disk
w       write table to disk and exit
x       extra functionality (experts only)
?       print this menu

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-209715166, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-209715166, default = 209715166) or {+-}size{KMGTP}:
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.

Next, format the partition to standard ext4

sudo mkfs -t ext4 /dev/sdc1

Wait a few seconds and you’re done

mke2fs 1.45.5 (07-Jan-2020)
Creating filesystem with 26214139 4k blocks and 6553600 inodes
Filesystem UUID: aca9ad65-3411-41da-8e9e-0006563a657b
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done

Check again with the command lsblknow see the partition appear sdc1

$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0   49M  1 loop /snap/core18/2252
loop1     7:1    0 60.7M  1 loop /snap/lxd/21843
loop2     7:2    0 57.5M  1 loop /snap/core20/1380
loop4     7:4    0 57.5M  1 loop /snap/core20/1360
loop5     7:5    0 61.2M  1 loop /snap/lxd/22530
loop6     7:6    0 20.7M  1 loop /snap/oracle-cloud-agent/32
loop8     7:8    0   49M  1 loop /snap/core18/2289
loop9     7:9    0 20.7M  1 loop /snap/oracle-cloud-agent/31
loop11    7:11   0 37.7M  1 loop /snap/snapd/14982
sda       8:0    0 46.6G  0 disk
├─sda1    8:1    0 46.5G  0 part /
└─sda15   8:15   0   99M  0 part /boot/efi
sdc       8:32   0  100G  0 disk
└─sdc1    8:33   0  100G  0 part

Mount the partition to Linux

Create a new directory and mount the partition sdc1 go to this directory

sudo mkdir /media/storage
sudo mount /dev/sdc1 /media/storage

Check with lsblk

$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0   49M  1 loop /snap/core18/2252
loop1     7:1    0 60.7M  1 loop /snap/lxd/21843
loop2     7:2    0 57.5M  1 loop /snap/core20/1380
loop4     7:4    0 57.5M  1 loop /snap/core20/1360
loop5     7:5    0 61.2M  1 loop /snap/lxd/22530
loop6     7:6    0 20.7M  1 loop /snap/oracle-cloud-agent/32
loop8     7:8    0   49M  1 loop /snap/core18/2289
loop9     7:9    0 20.7M  1 loop /snap/oracle-cloud-agent/31
loop11    7:11   0 37.7M  1 loop /snap/snapd/14982
sda       8:0    0 46.6G  0 disk
├─sda1    8:1    0 46.5G  0 part /
└─sda15   8:15   0   99M  0 part /boot/efi
sdc       8:32   0  100G  0 disk
└─sdc1    8:33   0  100G  0 part /media/storage

In order for Linux to automatically mount the partition every time I reboot, I edit the file fstab

sudo nano /etc/fstab

Add the following line at the bottom and save. Notice need to change /dev/sdc1 to the corresponding partition code on your VPS.

/dev/sdc1       /meida/storage ext4    defaults        0       0

It is done. Now I have an extra 100 GB free on my free VPS to store data.

Note: you should not save important information and data on Oracle Cloud’s free VPS. Because it is a free product, it can be locked or damaged at any time. Should only be used to scratch the line for fun, lose no regrets.

If my article has provided valuable insights and information to you, consider showing your appreciation with a virtual pat on the back or a kind message. Your encouragement will drive me to continue creating and sharing informative content. Thank you for taking the time to read!

Leave a Reply

Your email address will not be published. Required fields are marked *