Thank you very much guys for your input.
I finally found the time to do it.
Although @ScIT had a wonderful idea, I took my risks with a variant of @jtdoank because lvm does not allow to downsize easily.
#I ommited the test parts that check if origin is a symlink and if destination has not been previously created.
#set origin and destination
origen="/home/$1"
destino="/home2/$1"
origenb="$origen/"
destinob="$destino/"
#stop all services
#/usr/local/hestia/bin/v-list-sys-services | grep running | cut -d" " -f1 | xargs -I {} sh -c "echo 'Parando {}'; service {} stop; echo 'Fin.'"
#stop some services (I tried with all and took very long) I am also not hosting websites in that server.
service bind9 stop
service dovecot stop
service exim4 stop
#copy files to destination
mkdir $destino
rsync -alH $origenb $destino
#remove files on origin
chattr -i $origen/conf
rm -Rf $origen
#create link
ln -s $destino $origen
#start all stopped services
/usr/local/hestia/bin/v-list-sys-services | grep stopped | cut -d" " -f1 | xargs -I {} sh -c "echo 'Iniciando {}'; service {} start; echo 'Fin.'"
For now, all my tests seem to work.
___ EDIT ____
Problem1:
Okay. Had trouble with permissions and bind.
Very subtle stuff. Migrated DNS zones didn’t load correctly.
Fix:
- EDIT /etc/apparmor.d/local/usr.sbin.named
- ADD LINE: /home2/** rwm,
Problem2: Maybe unrelated
rc-local.service didn’t load upon restart.
Fix:
-
EDIT: /etc/systemd/system/rc-local.service
-
ADD:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
systemctl start rc-local.service
systemctl status rc-local.service
Look for green line saying: Active: active (running)