how to add new disk in Linux (centos 7 in virtual box)
Hello everyone, this lesson is suited for beginner level Linux admins. It takes you through how to:
A. Add new disc to a Linux virtual machine
B. Add new disc to new volume group
C. Mount the new disk in a new file system
Detailed steps:
1. Add a new disc to a Linux virtual machine
steps:
– add the disc to the VM (For the demo we are using a CentOS 7 system running in VirtualBox)
– fdisk -l /dev/sdb – to validate the disc space has been added
– for a VMware virtual Linux system scsi bus needs a rescan. Details are outlined here https://www.cyberciti.biz/tips/vmware-add-a-new-hard-disk-without-rebooting-guest.html
2. Partition the disc using fdisk
Options used:
n – for new partition
p – print details of new partition
t – 8e to set to system id to Linux LVM
3. Create a new file system
commands:
pvcreate /dev/sdb1
vgcreate vg2 /dev/sdb1
lvcreate -n lvopt2 -L 4.9G vg2
mkfs.xfs /dev/mapper/vg2-lvopt2
4. Mount the new file system /dev/mapper/vg2-lvopt2 from /opt2
edit /etc/fstab and add the following line
/dev/mapper/vg2-lvopt2 /opt2 xfs defaults 0 0
5. Write a 1GB file to the new file system
dd if=/dev/zero of=/opt2/testfile bs=1024k count=1024
Feedback and comments are most welcome.
source
centos 7