This procedure can you use to add a new disk to a Linux server and move data to that new volume.
First create an extra disk from VMWare to the Linux server. ( CentOS / RedHat )
In Linux:
Create disk
fdisk /dev/sdb
choose create partitie: n
choose primair: p
choose partitie: 1
choose last:<enter>
write the changes: w
Then you have to format the new disk
mkfs -t ext4 /dev/sdb1
( it’s the first partition on the new volume, so its called sdb1 )
Create mount point for /var/lib/mysqlnew
mkdir /var/lib/mysqlnew
mount -t ext4 /dev/sdb1 /var/lib/mysqlnew
Stop all services that would lock the data on the old volume.
example: service mysql stop
Copy all your data to the new mounted disk and path
cp /var/lib/mysql/* /var/lib/mysqlnew
After the copy, you have to unmount the new disk in order to rename it to the original and needed name.
umount /var/lib/mysqlnew
mv /var/lib/mysql /var/lib/mysqlold
mv /var/lib/mysqlnew /var/lib/mysql
Add line in fstab for mounting the disk after rebooting the server.
vi /etc/fstab
/dev/sdb1 /var/lib/mysql ext4 defaults 1 1
Start everything again, and check if it’s working 100%,
After that, you can remove /var/lib/mysqlold
rm -fr /var/lib/mysqlold
Views: 134