1

I have a server with 2TB (Raid, 2x2TB), and this partition schema

/ => /dev/md2 - 20GB
/home => /dev/md3 - 1.8TB

This is a ISPConfig server, so we need many space in /var and almost nothing into /home, so i think that the best way to do this is put /home in /dev/md2 and /var into /dev/md3

My fstab is this:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/md2        /       ext4    errors=remount-ro       0       1
/dev/md3        /home   ext4    defaults        1       2
/dev/sda4       swap    swap    defaults        0       0
/dev/sdb4       swap    swap    defaults        0       0

Which is the best way to do this? I think move /home contents to /homeold, remove from fstab, umount and now copy from /homeold to /home, and then change /var name (i dont have enough space to do the copy), mount new /var and move content, is this correct?

Also, i need to stop all server services to avoid errors (mysql, apache, mongodb, named, etc), any fast way to do this? Or maybe i should restart in rescue mode to do this?

Maybe another way is a full change between / and /home, i mean, put / in /md3 and /home in md2, is this possible only by edit fstab and reboot?

Thank you sou much,

1 Answers1

1

I think that your best friend in this case would rsync. Create directory /home/var. Sync it with existing /var directory.

rsync -avh /var/ /home/var/ --delete man rsync

When initial sync is done, do the same with /home partition.

After that you get very little downtime. Stop all services, run again rsync. Check if no files is begin used in var and home. lsof | grep '/var' and the same for /home. Here has chance that some libs is used from /var/lib. But that can be ignored. Now you have 2 options.

Option 1. mount /dev/md3 to /media/ and then symlink /media/var to /var

Option 2. move /home stuff to /home_new (except /home/var). then move all from /home/var to /home/, then remount /dev/md3 to /var, rename /home_new to /home. Make changes in fstab. Reboot server to see if all is working correctly.

I better like option 2. I also suggest You to add LVM to /dev/md3. Hope You get idea.

Similar question:

  1. https://unix.stackexchange.com/questions/131311/moving-var-home-to-separate-partition
  2. CentOS & moving /var to a new disk/partition
Guntis
  • 673
  • 1
  • 10
  • 20
  • Hi, Thank you for you support. I made everytihing and i opted for option two, but at server reboot, connection refused on SSH login. I go to rescue mode, check fstab and all appears to be right, /md2 is / and md3 is /var, i checked everything, mount partitions and all fine... do you have any idea what's going on? I dosn't have KVM on this server. Thanks! – Carlos Lopez Infante Dec 19 '16 at 17:26
  • maybe permission issue? do you have old `/var` directory? Can You see syslog and dmesg.log. Maybe there is some useful info. – Guntis Dec 19 '16 at 17:54
  • Apparently rsync fails at some point, because some folders was missing from new var directory, like the /var/empt/sshd was missing and some others, so i made a cp from old /var to new and now all works fine, so thank you so much! – Carlos Lopez Infante Dec 19 '16 at 18:27