LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Moving /var (https://www.linuxquestions.org/questions/linux-newbie-8/moving-var-469479/)

Maverick1182 07-31-2006 03:40 PM

Moving /var
 
I've run out of space on my gentoo installed partition which specifically holds /var

I intend to move the folder into the maind drive under /

I have already created a folder in the main drive called /my/var into which ive copied all the files.

I was wondering if there is a was of mount /my/var as /var (as far as the computer can tell) so that it may give me time to delete the old partition on which /var originally resides so that i can create a new large partition onto which i will copy the /var back.

I have tried to use mount --bind /var /myvar

but doing an ls /var still points to the contents of the old folder.

Any ideas?

billymayday 07-31-2006 03:47 PM

Does it work if you create a symbolic link in / called var and point it to /my/var?

Try renaming /var ro /var.sav and create a link. If this doesn't work, you can just rename it back (even if you need a rescue disk).

jeelliso 07-31-2006 03:48 PM

You can create a softlink from /var to /my/var, so that anything trying to access /var will actually to to /my/var.

ln -s /var /my/var

[EDIT]Oops, beat me to it[EDIT]

~Justin

IsaacKuo 07-31-2006 03:57 PM

Whenever I do fiddly stuff like that, I like to boot up a LiveCD. I'm not enough of a Linux expert to know when messing with /var or /tmp will break the OS out from under me. With a LiveCD, I'd just be messing with some non-OS files.

My latest experimentation has been with diskless net-booting. It's almost creepy, being able to shut down the client computer entirely and still have access to its OS files on the server.

Maverick1182 07-31-2006 04:13 PM

hmmm, this hasnt worked, its still displaying the contents of the old /var when i type ls /var

i can tell this as i have created a new file in /my/var called temp.txt which isnt showing up

IsaacKuo 07-31-2006 04:28 PM

Remember that you need to unmount /var before moving it around. Really, trying to do this stuff on a "live" system seems a bit foolhardy to me. I'd personally boot up a LiveCD like Knoppix to do this stuff.

But assuming you can mess with /var in a live system without breaking it, here are the steps you'll need to do:

unmount /var
mv /var /varBACKUP
ln -s /my/var /var

Note that the existing /var folder should be empty (you use an empty directory to mark a mountpoint for another partition). Using "mv" to rename it rather than deleting it outright is merely an overly paranoid precaution.

The "ln -s" statement creates the symlink the correct way. The statement shown above has it the wrong way around. The example I give creates a new link in the position "/var", pointed at "/my/var".

Maverick1182 07-31-2006 06:37 PM

Thanks gang, yes, a live CD is a much better idea. I did as you described and worked perfectly... hope 5 gb is enough for /var! lol if not then i'll resize (another new and heartstopping experience)

thanks again :)


All times are GMT -5. The time now is 04:36 AM.