1

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 ?

jango
  • 59
  • 2
  • 3
  • 12

2 Answers2

1

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

  • copy things
  • modify /etc/fstab
  • reboot

... as described here (and in many places): https://linuxconfig.org/how-to-move-var-directory-to-another-partition

V-Mark
  • 111
  • 5
0

One option is to only put some of the contents of /var on another volume. Shut down any affected services, copy the content over, and mount your new /var/lib/whatever/

Not everything will be moved over. Less risky because you are not changing other dynamic data like /var/log/ /var/run/ /var/spool/

If you ever rebuild the host for this service, then it is easy to split out /var/ from the beginning.

(Note that once again, the "best" solution depends on your requirements.)

John Mahowald
  • 32,050
  • 2
  • 19
  • 34