In Centos7 (Linux), mount the data disk (new partition) to the specified directory; or merge the data disk to the root directory

In Centos7 (Linux), mount the data disk (new partition) to the specified directory; or merge the data disk to the root directory

Some VPSs come with a data disk, or a data disk purchased separately. The following steps are to mount the data disk to a specified directory; or merge the data disk into the root directory. Choose 1 from the second and third parts below.

In fact, it is not only applicable to CentOS systems, but also other Linux systems.

1. Partition the new hard disk (data disk) (ignore the already partitioned disk)

1. Check whether it is mounted

 df -h

If the data disk is not visible, you did not mount it.

2. View partitions

 fdisk -l

Usually /dev/vdb, whether it is a mounted data disk

3. Partition the data disk

 fdisk /dev/vdb

Enter n, then accept the defaults, and finally enter w to save.

4. Synchronize partition to system

 partprobe

5. Format the partition

 mkfs -t ext4 /dev/vdb1

2. Mount the data disk to the specified directory

1. Mount to the specified directory

a. Create a directory

 mkdir /www

b. Mount to the /www directory

 mount /dev/vdb1 /www

2. Mount at startup

 vi /etc/fstab

Add a line at the end

 /dev/vdb1 /www ext4 defaults 1 2

Finally, reboot to see if it succeeds.

3. Merge the data disk to the root directory

1. To create a physical volume, first use lvdisplay to obtain the LV Path and VG Name .

 pvcreate /dev/vdb1 vgextend centos /dev/vdb1

After the execution is complete, if Volume group "VolGroup" successfully extended is displayed, it indicates that everything is OK.

2. Check the remaining space

 vgdisplay

Check Free PE / Size.

3. Capacity Expansion

 lvresize -L +49.8G /dev/centos/root

/dev/centos/root is the LV Path obtained in step 4. Slightly subtracting 0.2G from the integer will not go wrong.

Please use mount | grep root to view the format

 resize2fs /dev/centos/root

or xfs format please use

 xfs_growfs /dev/centos/root

<<:  NexusBytes: $3/month/1GB memory/30GB NVMe+30GB space/1TB traffic/1Gbps bandwidth/KVM/l Los Angeles

>>:  GetWebHosting: £10/year/512MB RAM/10GB NVMe space/2TB bandwidth/1Gbps port/DDOS/KVM/UK OVH

Recommend

MediaTemple: 20% discount on New Year's Day, minimum annual payment of US$288

MediaTemple, an American hosting company, is quit...

Srvis: $7/month/2GB memory/60GB space/750GB traffic/1 IP/OpenVZ

Srvis LLC, an American hosting company, was estab...

HostFav: $12/year/1GB memory/15GB space/1TB traffic/KVM/Fremont

HostFav, a newly established hosting provider, pr...

RentVps: $5/month/1GB RAM/25GB storage/unlimited traffic/10Gbps/KVM/UK OVH

RentVps is a foreign merchant that may be newly e...