SUSE Support

Here When You Need Us

How to move or relocate /var folder to a new partition in Linux

This document (7015338) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 11

Situation

How to move or relocate /var folder to a new partition in Linux

Resolution

Sometimes it may be necessary to move linux directories to separate partitions because the root partition is too small and cannot be resized or extended.

To relocate or move the /var folder to a new partition in Linux, please follow the steps below:
 
  1. Add a new hard disk to the server.
    Note: If this is a virtual machine, see how to add a new virtual hard disk to the VM with a corresponding vendor.
  2. Mount the new filesystem in /mnt, from YaST:
    • Launch YaST, select Partitioner | expand Hard Disks | select Add Partition...
      • New Partition Type: Primary Partition
      • Select Maximum Size, if preferred.
      • Formatting Options: ext3 (default)
      • Mounting Options: Mount Partition and specify Mount Point as /mnt/newvar
        Note: If there is a problem, the directory may need to be created first.
      • Select Finish and then Next.
         
  3. Switch to single-user mode:
    init 1
    Note: This will reboot the server into single-user mode where services aren't started and networking is offline for the server. Please login as root when the login dialog is presented and proceed to open a terminal window.
 
  1. Copy the data in var only to the new mounted filesystem:
    cp -apx /var/* /mnt/newvar
  2. Rename the current /var directory for backup purposes:
    mv /var /var.old
  3. Make the new var directory:
    mkdir /var
  4. Edit the /etc/fstab file:
    • Replace /mnt/newvar with /var
    • Save and Close the file.
      Note: The new partition is now configured to be mounted at /var on boot.
 
  1. Restart the server.

 

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7015338
  • Creation Date: 07-Jul-2014
  • Modified Date:12-Aug-2022
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.