How To Move VAR
How To Move VAR
By default when you install any Linux system, the /var directory is created automatically under
the root partition(‘/’). In some situations, you might want to separate out the /var directory on a
different mount point or partition altogether. Especially when you want to manage it
independently and have a large amount of data to be stored under /var.
Note: Please note that the below given procedure is online. But Make sure you have take a valida
backup of the root filesystem, just be sure in case of any failures.
1. View the available space in the existing VGs and disks. In case of space is not available on the
existent volume group, add a new disk or new partition. You may use the below commands to
view the available space and disks present on the system.
# vgdisplay
# fdisk -l
2. Initiatilize a new disk or a partition ona disk to be used by LVM to create new mount point. In
our example we are using partition on sdc disk.
# pvcreate /dev/sdc1
4. Verify the free space available in the newly created volume group var_vg:
# vgdisplay var_vg
5. Create a new logical volume (var_lv) on this volume group. In my case I have 20GB free
space in the VG. You may adjust the size as per your VG free space availability.
# mkfs.ext4 /dev/var_vg/var_lv
# mkdir /var_bkp
# rsync -avz /var/ /var_bkp
9. Copy all the contents from backup directory to the newly mounted /var.
1. First, find the UUID for the var_lv logical volume with the below command:
# blkid
2. Make and entry as shown below using the UUID from the above command.
# cat /etc/fstab
UUID=[UUID-for-var_lv] /var ext4 defaults 0 0
replace the [UUID-for-var_lv] with the actual UUID from blkid command we just fired above.
3. You can umount the /var now and try mounting it with “mount -a” command to verify if the
entry we just made in /etc/fstab is correct.
# umount /var
# mount -a ### (or mount /var)
4. Also make sure to set the permissions of new /var/tmp to 1777 if not already set. This is
required to set sticky bit on the /var mount point.