Changing Mount Point In Linux / Unix

 

Changing Mount Point In Linux / Unix

         Linux / Unix machine changing mounting point is crucial. While changing the mount points you need to be very careful or else data lose might occurs.

        Suppose consider a situation like this, you have a partition for your SQL Database and the partition is mounted in /Database with size of 1024 MB and almost 730 MB is been utilized so you are planning to increase the size of the partition. In the mean while their is an another partition called /linux with size 2048 MB with only 30+ MB is been utilized.

        Then to increase the size of the /Database partition we going to swap the /Database partition to /linux partition. The main thing you need to concentrate here is you need to do this with out data lose. Then why waiting lets go!!!

 

Step 1: First verify the size of the both partitions and check the entries in fstab

To check the size of all mounted partitions use the below command

#df -Th

 

Check the exact filesystem by below command

#cat /etc/fstab

 

Step 2: Take backup of both the partition to prevent from Data Lose

Take backup of /linux partition

#rsync -avzxl /linux /linux.backup

 

Take backup of /Database partition

#rsync -avzxl /Database /Database.backup

 

 

Step 3: Change the mount point in the fstab and mount all partitions

Edit the fstab entry by swapping the mount point of /Database and /linux

#vi /etc/fstab

 

Verify it by using the below command

#cat /etc/fstab

 

Mount all the partition in the /etc/fstab by using the below command

#mount -a

 

Verify all the partitions are mounted by the below command

#df -Th

 

 

Step 4: Check the data present the folders and swap it

Find out what are the data present in both the folders by the below command

#ls -l /Database

#ls -l /linux

 

We found that data are placed in wrong folder because of mount point changing, then don’t wait swap the data

#mv /Database/* /Database.2ndbackup

#mv /linux/* /Database/

#mv /Database.2ndbackup /linux

 

Again check out what are the data present in both the folders by the below command

#ls -l /Database

#ls -l /linux

 

Every thing looks fine now. Verify the folder size by below command

#df -Th