Sunday, July 01, 2007

CentOS5: Moving /var/log to a separate volume

One thing I like to do is put /var/log on its own volume. That keeps the root volume from overflowing and also gets the log files out of the way. However, in CentOS5 (and probably RHEL5), SELinux is probably going to complain unless we tell it to "fixup" the new filesystem.

  1. Create the filesystem (I use ext3, so # /sbin/mke2fs -j /dev/mdX)
  2. Mount it at a temporary location: # mkdir /mnt/log ; mount /dev/mdX /mnt/log
  3. Copy the contents: # cp -a /var/log/* /mnt/log/
  4. It may be necessary to "fixup" the new volume: # cd /mnt/log ; /sbin/restorecon -R *
  5. Edit the /etc/fstab file to mount the new volume at /var/log
  6. Reboot

AFAIK, that's the extent of what's needed. Looking at the directory listings using "ls -lZ" seems to show the correct SELinux flags on the files between the two different directories.

No comments: