joydeba
joydeba

Reputation: 1245

How to mount an external volume on a Linux virtual instance?

I have launched an instance from Ubuntu 18.04 image and attached a volume at /dev/vdc. I am not sure how I can mount it to media/data.

Upvotes: 0

Views: 1388

Answers (1)

joydeba
joydeba

Reputation: 1245

Found the solution

Create a partition on the volume with

[name@server ~]$ sudo fdisk /dev/vdb

fdisk will prompt you to enter a command. Use this sequence of single-character commands to create a new partition on your volume.

n => new partition
p => primary, only one partition on disk
1 => partition number 1
<return> => first sector (use default)
<return> => last sector (use default)
w => write partition table to disk and exit

Format the newly created partition with

[name@server ~]$ sudo mkfs -t ext4 /dev/vdb1

Create a place to mount the device with

[name@server ~]$ sudo mkdir /media/data

Finally, mount the volume with

[name@server ~]$ sudo mount /dev/vdb1 /media/data

If the VM is rebooted for some reason the volume will need to be remounted. To cause the VM to mount the volume automatically at boot time, edit /etc/fstab and add a line like

 /dev/vdb1 /media/data ext4 defaults 0 2

[name@server ~]$ sudo mount -a

Upvotes: 2

Related Questions