LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 01-30-2012, 02:33 PM   #1
mmtrebuchet
LQ Newbie
 
Registered: Jan 2012
Posts: 4

Rep: Reputation: Disabled
safely mv directory to another partition and replace with symlink


Hi, all.
So I'm running a little Slackware LAMP server.
I have a couple partitions:

Code:
Filesystem  Size  Mounted on
/dev/root    49G  / 
/dev/md1    147G  /www #website and stuff
I'd like to store my databases on /www, as it's raided and not likely to be accidentally formatted if I reinstall the OS.
Currently, they're stored in /var/lib/mysql.

What I'd like to do is something like
mv /var/lib/mysql /www/mysql
and then
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.)
 
Old 01-30-2012, 03:09 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
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.
 
1 members found this post helpful.
Old 01-30-2012, 03:14 PM   #3
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
You'd better do:
Code:
ln -s /www/mysql /var/lib
(edit)
Both ways work

Last edited by Cedrik; 01-30-2012 at 03:19 PM.
 
1 members found this post helpful.
Old 06-01-2012, 12:31 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,151

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
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.
 
Old 06-03-2012, 07:07 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,280

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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.
 
Old 06-04-2012, 02:09 PM   #6
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,151

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Oops! 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.)
 
  


Reply

Tags
ln, mv, mysql, symlink


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to safely uninstall awstats from a directory kitesurfa Linux - Server 1 11-20-2009 12:26 AM
Can't Delete Directory SymLink Luvz2Fly Linux - Newbie 2 12-05-2006 12:45 PM
symlink home-directory? SteQve Linux - General 2 01-26-2006 04:42 PM
How to safely re-partition squinn Linux - Newbie 3 08-23-2005 02:38 PM
moving a symlink in a directory e1000 Linux - General 2 02-23-2004 05:09 PM


All times are GMT -5. The time now is 03:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration