Attach additional disk to Linux

By | April 2, 2018

 

it’s a best practice to use one or more separate disks to store a virtual machine’s data.

In this example Linux is Ubuntu 16.04 LTS but this steps is a same for CentOS

 

sudo grep SCSI /var/log/syslog

sudo fdisk /dev/sdb

press n

press p

Choose 1 -> Enter -> Enter (Default settings)

Type p

Type w to write the settings for the disk

Now will create the file system on the new partition /dev/sdb1

sudo mkfs -t ext4 /dev/sdb1

Now create directory exp: /datadisk1

sudo mkdir /datadisk1

datadisk1 will be our mount point for sdb1

Execute: sudo mount /dev/sdb1 /datadisk1

Execute: sudo -i blkid

We need UUID for sdb1 to add in fstab file copy UUID=91ee28ef-ef1f-4119-8263-fd48179af646

nano /etc/fstab and add UUID

UUID=91ee28ef-ef1f-4119-8263-fd48179af646(press Tab) /datadisk1(press Tab) ext4(pres Tab) defaults,nofail(pres Tab) 1(press Tab) 2

Ctr+0 to save and Ctr+x to exit

Quick test:

sudo umount /datadisk1

sudo mount /datadisk1

To make writable disk /datadisk1 for everyone

chmod 777 /datadisk1 or chmod go+w /datadisk1

now we can reboot server

and check new datadisk1

df -h