bishma
asked on
swaping mount points and preserving data
My project at work just got a hand-me-down debian box. Everything on it is in fine working order but I need to change the mount point of one of the drives.
The drives are set up thusly:
/dev/hdd1 - mounted on /
/dev/hdc1 - mounted on /home
In the machine's previous like it had a lot of user files so having almost half of it's storage dedicated to the home directory made sense. My needs for are different, however, and I would like to have hdc1 mounted on /var/lib/mysql since most of the machines job is handling large databases.
Can someone please walk me through, step by step, the best way to change the mount location from /home to /var/lib/mysql on hdc1 without changing any of the files in either directory? I'm pretty new to the world of *nix so I need to have it explained clearly. If it matters the machine is running Debian 3.1r1.
Thank you in advance.
The drives are set up thusly:
/dev/hdd1 - mounted on /
/dev/hdc1 - mounted on /home
In the machine's previous like it had a lot of user files so having almost half of it's storage dedicated to the home directory made sense. My needs for are different, however, and I would like to have hdc1 mounted on /var/lib/mysql since most of the machines job is handling large databases.
Can someone please walk me through, step by step, the best way to change the mount location from /home to /var/lib/mysql on hdc1 without changing any of the files in either directory? I'm pretty new to the world of *nix so I need to have it explained clearly. If it matters the machine is running Debian 3.1r1.
Thank you in advance.
ASKER
Sorry, I forgot to mention that /home and /var/lib/mysql already has a fair amount of stuff in each them. So it I do it this way does the data get transfered? I want every thing that's in /home to end up on hda1 and everything that's in /var/lib/mysql to end up on hdc1 with their ownership and permissions intact.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked perfectly and was exactly what I was looking for. Thank you for your help wesly_chen.
Hi,
wesly_chen, init 0 is to halt the system. init 1 is more like it. I suggest you do this:
1. First move the home directory...
1.1 As root, go to Single User Mode
# init 1
1.2 Make a directory /home2 which will resides in hdd1 and copy the data from /home to /home2 (use copy so that you won't lose data)
# mkdir /home2
# cp -R /home/* /home2
1.3 Unmount the /home from hdc1 and edit the fstab to disable mounting /home on hdc1 on boot
# umount /home
edit /etc/fstab and add a # infront of the line that contains /dev/hdc1
1.4 Now move the files from /home2 back to /home and delete the /home2 directory afterwards
# mv /home2/* /home
# rmdir /home2
1.5 Time to reboot and check if you system still working properly
# init 6
If you are fine until this steps, send a tinker back into EE, we will move forward from there. Otherwise, we have to roll back what we have done.
wesly_chen, init 0 is to halt the system. init 1 is more like it. I suggest you do this:
1. First move the home directory...
1.1 As root, go to Single User Mode
# init 1
1.2 Make a directory /home2 which will resides in hdd1 and copy the data from /home to /home2 (use copy so that you won't lose data)
# mkdir /home2
# cp -R /home/* /home2
1.3 Unmount the /home from hdc1 and edit the fstab to disable mounting /home on hdc1 on boot
# umount /home
edit /etc/fstab and add a # infront of the line that contains /dev/hdc1
1.4 Now move the files from /home2 back to /home and delete the /home2 directory afterwards
# mv /home2/* /home
# rmdir /home2
1.5 Time to reboot and check if you system still working properly
# init 6
If you are fine until this steps, send a tinker back into EE, we will move forward from there. Otherwise, we have to roll back what we have done.
Thanks slyong for the correction. My brain didn't work well at that time.
As root,
umount /home
mkdir /var/lib/mysql
Then edit /etc/fstab and change the following line
/dev/hdc1 /home .....
to
/dev/hdc1 /var/lib/mysql .....
Then
mount /var/lib/mysql