N6REJ

Revision 3 as of 2005-11-23 11:12:22

Clear message

How to Painlessly move a mount point

Tonight I had the undesirable experience of spending hours trying to figure out why after I moved my mount point it would no longer automount on reboot! It turns out the answer is extremely simple if you know it and painfully hidden if you don't. It will take you longer to read this wiki then it will to fix the problem. Its easiest to do this from a terminal so if your not there already, start by opening a terminal window.

Now in my case I had created a partition /dev/hda6 as mount point /usr/local/mysql because I was expecting a large database and wanted to be sure it had enough room devoted just to it. BUT it turns out that mysql likes its data in /var/lib/mysql! *UGH* So I needed to move the mount point. This tutorial had not been written yet and is NOT covered in the mount man page so I spent hours trying to get my system to work properly. The only indication that anything was even wrong was when it keept saying "mounting local file system failed" at Boot Time. So if that happens to you after reading this wiki, then you've skipped a step or made a typo!

Anticipate this job to take 5-10 minutes from start to finish. More if you have to read this and do it at the same time.

First thing we need to do is stop mysql and save our data!

sudo /etc/init.d/mysql stop
sudo mv /var/lib/mysql /var/lib/mysql_temp

ok, now lets take at look at /etc/fstab

sudo nano -w /etc/fstab

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc        /proc             proc         defaults                    0  0  
/dev/hda10  /                 ext3         defaults,errors=remount-ro  0  1  
/dev/hda1   /boot             ext3         defaults                    0  2  
/dev/hda5   /ftp              ext3         noexec,user_xattr           0  2  
/dev/hda7   /home             ext3         defaults                    0  2  
/dev/hda9   /tmp              ext3         defaults                    0  2  
/dev/hda12  /usr              ext3         defaults                    0  2  
/dev/hda6   /usr/local/mysql  ext3         defaults                    0  2  
/dev/hda13  /var              ext3         defaults                    0  2  
/dev/hda11  /var/www          ext3         defaults                    0  2  
/dev/hda2   /share            ext3         defaults                    0  2  
/dev/hda8   none              swap         sw                          0  0  
/dev/hdc    /media/cdrom0     udf,iso9660  user,noauto                 0  0  
/etc/fstab (END) 

Now while we're in here looking lets go ahead and make the changes we need to make.

move your cursor down to the line you want to change and make your change 

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc        /proc             proc         defaults                    0  0  
/dev/hda10  /                 ext3         defaults,errors=remount-ro  0  1  
/dev/hda1   /boot             ext3         defaults                    0  2  
/dev/hda5   /ftp              ext3         noexec,user_xattr           0  2  
/dev/hda7   /home             ext3         defaults                    0  2  
/dev/hda9   /tmp              ext3         defaults                    0  2  
/dev/hda12  /usr              ext3         defaults                    0  2  
/dev/hda6   /var/lib/mysql  ext3         defaults                    0  2  
/dev/hda13  /var              ext3         defaults                    0  2  
/dev/hda11  /var/www          ext3         defaults                    0  2  
/dev/hda2   /share            ext3         defaults                    0  2  
/dev/hda8   none              swap         sw                          0  0  
/dev/hdc    /media/cdrom0     udf,iso9660  user,noauto                 0  0  
/etc/fstab (END) 

Now notice that /var/lib/mysql comes BEFORE "/var" This will never work! This is why I had so many problems. All the mount points in "/etc/fstab" must be in alphabetical order. "Trunk" first then "limbs". So lets fix that while we're here.

While your cusor is still on the line that you changed, hit '''~+^k+~''' [CTRL]+K if your used to windows verbage.
Then move down to where it should be and hit '''~+^u+~''' [CTRL]+u. 

Now your work should look like this....

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc        /proc             proc         defaults                    0  0  
/dev/hda10  /                 ext3         defaults,errors=remount-ro  0  1  
/dev/hda1   /boot             ext3         defaults                    0  2  
/dev/hda5   /ftp              ext3         noexec,user_xattr           0  2  
/dev/hda7   /home             ext3         defaults                    0  2  
/dev/hda9   /tmp              ext3         defaults                    0  2  
/dev/hda12  /usr              ext3         defaults                    0  2  
/dev/hda13  /var              ext3         defaults                    0  2  
/dev/hda6   /var/lib/mysql    ext3         defaults                    0  2  
/dev/hda11  /var/www          ext3         defaults                    0  2  
/dev/hda2   /share            ext3         defaults                    0  2  
/dev/hda8   none              swap         sw                          0  0  
/dev/hdc    /media/cdrom0     udf,iso9660  user,noauto                 0  0  
/etc/fstab (END) 

Notice "/dev/hda6" its now been moved to where it should live. a few more simple steps and we're done.

Now hit '''~+^x+~'''  or [CTRL]+x, followed by two [ENTER]'s to save your work.

That being done lets do the final steps..

sudo mkdir -p /var/lib/mysql
sudo mount --move /usr/local/mysql /var/lib/mysql
sudo cp -rp /var/lib/mysql_temp/ /var/lib/mysql/
sudo mount -a
sudo /etc/init.d/mysql start
sudo rm -rf /usr/local/mysql
sudo rm -rf /var/lib/mysql_temp

Thats it! your done. Congratulations and enjoy your new mount point.

[MailTo(troy@cogyfarm.com)]]

List of pages in this category:

FullSearch()


CategoryCategory CategoryCleanup CategoryCleanup CategoryDocumentation CategoryHardware