LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 05-23-2020, 01:04 PM   #1
peter7089
Member
 
Registered: May 2016
Posts: 143

Rep: Reputation: Disabled
Can i move /var to anothre partition and link it with symlink?


I know i can move /var to another partition and then mount the partition, but my question is can i move var directory to another partition and create symlink to it? For example, the second partition is mounted on /drive1. Then i move /var using rsync and then create symlink: ln -s /drive1/var /var.
 
Old 05-23-2020, 01:13 PM   #2
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 1,512

Rep: Reputation: Disabled
Sure, you can. Symlinks work across partition boundaries, hardlinks don't.
 
1 members found this post helpful.
Old 05-23-2020, 01:58 PM   #3
peter7089
Member
 
Registered: May 2016
Posts: 143

Original Poster
Rep: Reputation: Disabled
Do i have to do that from live usb?
 
1 members found this post helpful.
Old 05-23-2020, 02:01 PM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,883

Rep: Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250
yes, most probably you cannot change /var of a living system (so you need to boot from live usb, change it and reboot)

(I'm not really sure if a symbolic link was a good idea, I would rather mount another partition. But anyway, you can try it).
 
1 members found this post helpful.
Old 05-23-2020, 07:11 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,505

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
If you have SELinux enabled, then you will have to do a bit of magic so that files under /drive1/var get labeled the same way as would files under /ver.
Code:
fcontext -a -e /var /drive1/var
See the fcontext manpage for an explanation of that.

If you actually mounted the /drive1/var partition on /var, then you wouldn't have to worry about that.
 
Old 05-23-2020, 07:24 PM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351
You should be able to just copy the files across, make changes to fstab, reboot and be OK (though the old contents of /var will still be on the original drive and inaccessible to delete). Not a recommendation, and I assume anyone doing this kind of thing backs up their data first.
 
Old 05-23-2020, 09:26 PM   #7
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,973

Rep: Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843
You could also try a bind mount as an alternative to a symlink. From the mount manual page:
Code:
mount --bind olddir newdir
 
1 members found this post helpful.
Old 05-24-2020, 02:11 AM   #8
peter7089
Member
 
Registered: May 2016
Posts: 143

Original Poster
Rep: Reputation: Disabled
If mounting the partition is better choice can i move multiple folders to the same partitions? I don't want to create new partition for each folder i want to move, because i may need to move /usr and /home folders too.
 
Old 05-24-2020, 03:35 AM   #9
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 5,973

Rep: Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843Reputation: 1843
A bind mount doesn't mount a partition, but a directory.
 
Old 05-24-2020, 07:43 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,883

Rep: Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250Reputation: 5250
I think you ought to keep /usr, moving it to another partition may cause problems.
You can move /home and /var to the same partition, it is actually not impossible, but I would not do that.
 
Old 05-24-2020, 09:20 AM   #11
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 4,505

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by pan64 View Post
I think you ought to keep /usr, moving it to another partition may cause problems.
You can move /home and /var to the same partition, it is actually not impossible, but I would not do that.
Indeed, having a separate /usr partition has been broken, to a steadily increasing degree, for the last 15 years or so.

As for /home, I have a directory /var/home bind-mounted to /home. I'm the only user on this system, and having to decide how to divide up the disk free space between /var and /home makes no sense.
 
1 members found this post helpful.
  


Reply


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
[SOLVED] symlink to symlink confusion, Reprovo Linux - Newbie 2 11-18-2014 03:17 PM
[SOLVED] get var value when var name is part of another var bilyboy65 Linux - Newbie 9 10-21-2012 10:32 AM
Question How to get stat() of symlink and not of target of symlink ? ronbarak Programming 3 11-08-2010 01:14 PM
Hanging symlink: /var/X11 rkelsen Slackware 1 06-24-2010 01:30 PM
Symlink/ link question... can someone explain please! ta spoovy Linux - Newbie 4 03-02-2010 08:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:13 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration