Moving directories into separate partition

skp18

New Member
Joined
Dec 4, 2022
Messages
3
Reaction score
0
Credits
33
I have an EC2 instance running on RHEL 7.9 with one volume /dev/sda. I am not a Linux admin. I just know some basic stuff. How do I move /var & /home directories into separate partitions? I have to do this due to some requirements. What would be the impacts of doing so? Thanks.
 


osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
414
Reaction score
333
Credits
3,819
skp18 wrote:
How do I move /var & /home directories into separate partitions?
Normally one would mount the separate partitions into the system and then copy the files across as user. One can use the "mount" command as root, and then the "cp" or "rsync" or "mv" commands to move the files. If the separate partitions don't already exist, you would need to create them with a tool like gparted, parted, fdisk or others.
What would be the impacts of doing so?
If, for example, one configures the separate /home partition to mount at boot in the /etc/fstab file, on booting, this mount will be largely invisible in work on the system. The advantage of a separate /home partition is that one can re-install the /root partition without touching the /home partition, so keeping all of one's data in the /home partition intact. To re-install when the /home partition is in the /root partition, one would usually need to back up the /home partition data if they wanted to keep it, and then restore it to the new installation.

In relation to the /var partition, the advantages are arguable, so I won't advance a case, but just observe that the size of the /var partition can be quite variable since it holds the logs, among other data, which can grow if not configured to be size-restricted. A large /root partition can manage /var quite easily whereas one probably needs to keep an eye on a small separate /var, though a separate /var can be inherently controlling of disk usage by logs and caches that the system creates.

On this machine which is used 24/7, /var sits within /root of 50G, there's a separate /home partition of 861G and a separate /swap of 6G. The logs are configured to grow to relatively small sizes (journal.conf has SystemMaxUse=50M). This machine once ran fedora, but that was replaced by debian without touching the /home partition. I expected problems, but none occurred. The fedora /home data was seemlessly accepted by the debian OS. The separate /home partition was very convenient. Usually here however, re-installing involves an updated point version of the same distribution.
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top