Cloud Guides & Tutorials
Mount Block Storage in your sy...
Mounting Block Storage in Linux
7min
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 new block storage devices are shown as unpartitioned drives in the above case it's the vdb drive first you need to partition the drive for that use the fdisk command \# fdisk /dev/vdb this will bring a commandline menu 	\[root\@vm qb11p1fjc ]# fdisk /dev/vdb 	welcome to fdisk (util linux 2 37 4) 	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 	created a new dos disklabel with disk identifier 0x6fe3ef1e 	 	command (m for help) to create a new partition press n 	command (m for help) n 	partition type 	 p primary (0 primary, 0 extended, 4 free) 	 e extended (container for logical partitions) 	select (default p) select p for primary leave the partition number , first sector and last sector with the default values this will partition the full drive 	select (default p) p 	partition number (1 4, default 1) 	first sector (2048 209715199, default 2048) 	last sector, +/ sectors or +/ size{k,m,g,t,p} (2048 209715199, default 209715199) 	 	created a new partition 1 of type 'linux' and of size 100 gib 	 	command (m for help) to view the created partition table press p 	command (m for help) p 	disk /dev/vdb 100 gib, 107374182400 bytes, 209715200 sectors 	units sectors of 1 512 = 512 bytes 	sector size (logical/physical) 512 bytes / 512 bytes 	i/o size (minimum/optimal) 512 bytes / 512 bytes 	disklabel type dos 	disk identifier 0x6fe3ef1e 	 	device boot start end sectors size id type 	/dev/vdb1 2048 209715199 209713152 100g 83 linux 	 	command (m for help) once you are done press w to write the changes now the partition has been created, can verify with lsblk 	command (m for help) w 	the partition table has been altered 	calling ioctl() to re read partition table 	syncing disks 	 	\[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 	└─vdb1 253 17 0 100g 0 part next you will have to format the drive with the preffered file system this can be done with the mkfs https //linux die net/man/8/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, 	 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 https //linux die net/man/8/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 	\[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 	└─vdb1 253 17 0 100g 0 part /mnt 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 https //linux die net/man/8/blkid command 	\[root\@vm qb11p1fjc ]# blkid 	/dev/vda2 uuid="dbfed337 0438 4685 8a2e eed84bb9e46a" type="xfs" partuuid="11ec2d3d 02" 	/dev/vdb1 uuid="4e4cde18 8662 4e76 9e0d e6f8d9a353db" type="ext4" partuuid="6fe3ef1e 01" 	/dev/vda1 uuid="90b9c72b b26b 4c27 a83c fcdad7d45178" type="xfs" partuuid="11ec2d3d 01" copy the uuid of the drive and edit the /etc/fstab file like this 	uuid=dbfed337 0438 4685 8a2e eed84bb9e46a / xfs defaults 0 0 	uuid=90b9c72b b26b 4c27 a83c fcdad7d45178 /boot xfs defaults 0 0 	\# \<device> \<dir> \<type> \<options> \<fsck> 	uuid=4e4cde18 8662 4e76 9e0d e6f8d9a353db /mnt ext4 defaults 0 0 for more information about the fstab file we recommend reading this guide https //linux die net/man/5/fstab