<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=Relocate_%2Fvar</id>
	<title>Relocate /var - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=Relocate_%2Fvar"/>
	<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Relocate_/var&amp;action=history"/>
	<updated>2026-10-16T06:40:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=Relocate_/var&amp;diff=6767&amp;oldid=prev</id>
		<title>Leo: Initial content</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=Relocate_/var&amp;diff=6767&amp;oldid=prev"/>
		<updated>2022-06-15T20:09:58Z</updated>

		<summary type="html">&lt;p&gt;Initial content&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Relocating the contents of /var to another storage device or partition might be useful when you are running low on storage on the root partition.&lt;br /&gt;
&lt;br /&gt;
To relocate /var from the root partition to another partition or storage device:&lt;br /&gt;
&lt;br /&gt;
# Add the new storage device or create a new partition or LVM volume.&lt;br /&gt;
# Format the new storage&lt;br /&gt;
# Mount the new storage to /mnt/var&lt;br /&gt;
# Ensure no programs have /var opened. Run lsof /var to verify. Alternatively, boot into single user mode before proceeding.&lt;br /&gt;
# Copy the /var contents to the new location. Run cp -apx /var/* /mnt/var&lt;br /&gt;
# Move the original /var to /var.original and recreate the /var directory&lt;br /&gt;
# Edit /etc/fstab so that /var is mounted appropriately on startup&lt;br /&gt;
&lt;br /&gt;
In summary, on a system using LVM, I ran the following:&lt;br /&gt;
&lt;br /&gt;
{{Highlight&lt;br /&gt;
| code = ## Expand the LVM partition if the disk was grown.&lt;br /&gt;
# /usr/bin/growpart /dev/sda 2&lt;br /&gt;
&lt;br /&gt;
## Expand the LVM volume group&lt;br /&gt;
# /usr/sbin/pvresize -y -q /dev/sda2&lt;br /&gt;
&lt;br /&gt;
## Create a new LVM volume for /var&lt;br /&gt;
# lvcreate -n var -L 20G rl&lt;br /&gt;
&lt;br /&gt;
## Create a filesystem&lt;br /&gt;
# mkfs.xfs /dev/mapper/rl-var&lt;br /&gt;
&lt;br /&gt;
## Copy data to the new partition&lt;br /&gt;
# mkdir /mnt/var&lt;br /&gt;
# mount /dev/mapper/rl-var /mnt/var&lt;br /&gt;
# cp -apx /var/* /mnt/var&lt;br /&gt;
&lt;br /&gt;
## Ensure that fstab has an entry for this volume.&lt;br /&gt;
# cat &amp;lt;&amp;lt;EOF &amp;gt;&amp;gt; /etc/fstab&lt;br /&gt;
/dev/mapper/rl-var      /var                    xfs    defaults        0 0&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
## Cleanup&lt;br /&gt;
# mv /var /var.original&lt;br /&gt;
# mkdir /var&lt;br /&gt;
# mount -a&lt;br /&gt;
| lang = terminal&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Leo</name></author>
	</entry>
</feed>