we have linux redhar 7
we want to keep the /var on other volume
so the plan is to:
mkdir /var_copy
cp -rp /var/* /var_copy
umount /dev/mapper/vg-a-var /var
rm -rf /var
mkdir /var
mount /dev/mapper/vg-b-var /var
cp -rp /var_copy/* /var
so my question is
is it good approach to use cp -rp in order to copy /var content ?
or maybe because /var include simbolic link or hard link need to use other approach ? as cp -a or other ?
Best Answer
Instead of cp I suggest
rsync -aqxP /var/* /var_copy
...but your plan will break many things (rm -rf /var "under" a running system).
Better to
... as described here (and in many places): https://linuxconfig.org/how-to-move-var-directory-to-another-partition