Skip to content
  • There are no suggestions because the search field is empty.

Mounting Block Storage in Linux

To partition and mount your Block Storage in a Linux system follow this guide.

Mount Block Storage in Linux

Once you connect to your instance run lsblk to view the current drives:

[root@vm-qb11p1fjc ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 1024M 0 rom
vda 253:0 0 40G 0 disk
├─vda1 253:1 0 1G 0 part /boot
└─vda2 253:2 0 37G 0 part /
vdb 253:16 0 100G 0 disk 
 
 

 

# fdisk /dev/vdb

This will bring a commandline menu:

 
 

To create a new partition press n:

 
 

Select p for primary. Leave the Partition number, First sector and Last sector with the default values. This will partition the full drive.

 
 
 

To view the created partition table press p.

 

Once you are done press w to write the changes. Now the partition has been created, can verify with lsblk.

 

Next you will have to format the drive with the preffered file system. This can be done with the mkfs commands. In this case we will make an ext4 partition so we will use the mkfs.ext4 command.

 
[root@vm-qb11p1fjc ~]# mkfs.ext4 /dev/vdb1
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 26214144 4k blocks and 6553600 inodes
Filesystem UUID: 4e4cde18-8662-4e76-9e0d-e6f8d9a353db
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 8 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
 

Once the format is complete you can mount the drive with the mount command. In this case we will mount the drive to the /mnt directory with mount /dev/vdb1 /mnt. You can view the mounted drive with the lsblk command.

 

Persist the mount

To make drive stays mounted after reboots you must add it in the /etc/fstab file. Fist get the UUID of the partition with the blkid command.

 

Copy the UUID of the drive and edit the /etc/fstab file like this.

 
 

For more information about the fstab file we recommend reading this guide.