Setting up your Block Storage for VPC data volume for use (Linux)
If you want to use your IBM® Cloud Block Storage for Virtual Private Cloud volume as a file system, you need to partition the volume, format it, and then mount it as a file system. You can perform this operation after you created a Block Storage for VPC volume and attached it to an instance.
Connect to your instance, then follow this procedure to use your Block Storage volume on a Linux® system.
Step 1 - Listing all storage volumes
Run the following command to list all Block Storage for VPC volumes from your instance.
lsblk
The output looks similar to this example.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 202:0 0 100G 0 disk
├─vda1 202:1 0 256M 0 part /boot
└─vda2 202:2 0 99.8G 0 part /
vdb 202:32 0 100G 0 disk
Volume vdb
is your Block Storage data volume.
Step 2 - Partitioning the volume
-
Run the following command to partition the volume.
fdisk /dev/vdb
-
Type the
n
command for a new partition, thenp
for primary partition.Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p
-
Complete the prompts to define the partition's first cylinder number and last cylinder number. You can use the default value for the first cylinder number. For the last cylinder, you can either define an absolute value for the last sector or you can define a relative value to the start sector. To define a relative value, use the + symbol followed by the partition size. The size can be specified in kibibytes (K), mebibytes (M), gibibytes (G), tebibytes (T), or pebibytes (P). For example, to set the partition size to 100 GiB, enter +100G.
-
After the partition is created, run the
w
command to save changes to the partition table. Restart your system to verify the newly created partition.
Step 3 - Formatting the volume partition
/sbin/mkfs -t ext4 /dev/vdb1
To check the size of the partition, run the following command.
fdisk -s /dev/vdb1
Step 4 - Updating the file systems table
Update /etc/fstab
.
fstab /dev/vdb1
disk_partition=/dev/vdb1
uuid=$(blkid -sUUID -ovalue $disk_partition)
mount_point=$mount_parent/$uuid
echo "UUID=$uuid $mount_point ext4 defaults,relatime 0 0" >> /etc/fstab
Step 5 - Creating a directory
mkdir /myvolumedir
mount /dev/vdb1 /myvolumedir
Step 6 - Mounting the volume as a file system
mount /dev/vdb1 /myvolumedir
Step 7 - Accessing the new file system
To see your new file system, run the following command.
df -k
The command produces an output like the following example.
file system 1K-blocks Used Available Use% Mounted on
udev 4075344 0 4075344 0% /dev
tmpfs 816936 8844 808092 2% /run
/dev/vda2 101330012 1261048 100052580 2% /
tmpfs 4084664 0 4084664 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 4084664 0 4084664 0% /sys/fs/cgroup
/dev/vda1 245679 64360 168212 28% /boot
tmpfs 817040 0 817040 0% /run/user/0
/dev/vdb1 103081248 61176 97777192 1% /myvolumedir
Go to the directory in your new file system and create a file.
cd /myvolumedir
touch myvolumefile1