safely mv directory to another partition and replace with symlink
So I'm running a little Slackware LAMP server.
I have a couple partitions:
Currently, they're stored in /var/lib/mysql.
What I'd like to do is something like
mv /var/lib/mysql /www/mysql
ln -s /www/mysql /var/lib/mysql
(I probably messed up that syntax.)
Before I do something really stupid, though, I want to filter this idea with you guys.
So, uh, do I have the right mv and ln syntax? Will mysql explode when it encounters a symlink?
Or, even better, is there an option in my.cnf or a similar file that lets me change the directory properly? I didn't see anything, but mysql has a huge man page...
(Currently, there's no data I cherish in the databases, but I figure I should probably learn to do this right before I have to move actually valuable data.)
Looks all good to me; whether or not MySQL will throw a hissy-fit (I don't think it will)
I don't know; same w/ simply changing a config-setting. But if all else fails you can
always revert back ;}
Just make sure you stop it before you move.
You'd better do:
Both ways work :)
You might want to consider the use of a hard link rather than a soft link. If you're using a Linux file system (like ext, btrfs, etc.) that uses inodes, a hard link to a file increase the "in use" number of the nodes in the file by one. If the "in use" number is greater than zero, the node is not deleted when it's change by writing to the file. Instead, a new free (i.e., node with a zero "in use" number) is used. The "in use" number will not decrease to zero until the the hard link is deleted.
Thus a hard link to a file creates, essentially, a "snapshot" of the file. This minimizes the amount of disk space used by the backup, since only the changed nodes need actual disk space. That's unlike a copy that uses a new node for every node in the base file.
This, by the way, is how it's possible to write to a file (like, e.g., a system file) that's being used by a running Linus system, since the kernel, in essence, hard links opened files, and uses the "virtual hard link" when it references the file, releasing it when the file is closed.
The OP appears to want to move to a new partition; hard links can only exist in one partition as each partition has its own inode list (ie same ids as any other partition).
IOW, you can symlink across partitions, but not hard link.
Oops! :redface: I meant to post that to a different thread where that OP was asking about writing into a file, but was afraid that he might get it "wrong." (And I found the wrong thread when I looked for it after I woke up the next day with the realization that the hard link might be a good solution for that OP.)
|All times are GMT -5. The time now is 10:30 PM.|