Re: Adding a new HDD - how do I move /var/lib/mysql ?
[This message has also been posted to linux.debian.user.]
In article <7BUTU-Gifirstname.lastname@example.org>, Roberto C. Sanchez wrote:
> On Wed, Jan 10, 2007 at 02:46:29PM -0500, Kevin Mark wrote:
>> probably the simplest way is to just make a new /var on the new drive
>> and move all of it there.
>> -add new HD to computer
>> -partition HD
>> -format HD
>> -mount new HD as /mnt/newvar
>> -stop all processes (like single user mode)
>> -copy all of /var to /mnt/newvar
>> -move /var to /oldvar (not sure this works)
>> -create /var
>> -edit fstab to add mount point to make new partition point to /var
>> -reboot and hope it works
> A couple of points:
> - This will be lots easier and less painful if you do it all in pass [?]
[all in passing?] [all in one pass?] [huh?]
> from a LiveCD (though Knoppix is my favorite, I'd recommend the
> Ubuntu LiveCD since it suppors LVM--see next point)
I'd recommend against the live CD for this. If this is
a production system you want to use kernel and utilities
that were built together. If you'll be running the file
system with Sarge, don't build it with mke2fs from Sid.
Besides, the date and time zone are probably wrong on your live CD.
Set the time correctly before you make a file system or copy
To replace /var with minimum downtime,
1. shut down, add new drive
2. boot as usual
3. fdisk and build new file systems
4. telinit 1 # shuts down everything that's got files open on /var
5. mount new file system as /newvar, cp -a /var /newvar
6. cd / ; mv var oldvar && ln -s newvar var && ls /var
7. if /var looks right, telinit 2 # starts it all up again
8. dont forget to put /newvar in /etc/fstab
9. when you're sure things are good, rm -rf /oldvar
Don't run telinit 1 if you don't have access to the console,
but then how did you add the drive?
Notice I made the symlink without the leading slash. This comes
in handy if you need to boot a live CD and run your system from
a chroot some day. Symlinks should usually be relative paths.
In any case, I wouldn't just move all of /var. If the problem
is /var/lib/mysql, then just move that. Make a partition or
a logical volume /extra and copy /var/lib/mysql to
/extra/lib/mysql. Then you don't have to go through the
telinit run level change, you can just stop and start mysql.
> - Save yourself some trouble and setup LVM and then create a single
> volume group and put your logical volume on that.
That sounds like good advice.