Rebuild /var inline / var logical volume naming

Posted on 2004-11-08
Last Modified: 2013-11-17
We have a pSeries box running AIX 5.1 which has had some bad corruption on the /var filesystem that fsck will not fix. We've decided to rebuild the filesystem from an old backup. The system is currently 'stable' on the existing /var except that certain portions of the fs (which normally go unused) will panic the box when accessed. We've decided to rebuild /var from an old backup but I have some questions:

1. Can we build /var on a new logical volume and then just swap them out by editing the mounts? This would give us the added safety net of being able to boot back on the original /var if we have problems with the new one.

2. If #1 is a yes, does /var have to be on the hd9var logical volume or can it have a different name? If it must be on hd9var, can we simply rename the original to hd9var-old and rename the new one to hd9var?

Looking for any pointers from someone who may have found themselves in a similar situation.

Question by:gripe
    LVL 38

    Expert Comment


    1. Yes.
    2. No. /var need to stick with hd9var. You need to boot your system into a limited function maintenance shell (Service or
    Maintenance mode) from bootable AIX media.
    Restore the backup of /var to /var.bak

    With bootable media of the same version and level as the system, boot the system into Service mode.
    The bootable media can be any ONE of the following:

    Bootable CD-ROM
    NON_AUTOINSTALL, bootable mksysb
    Bootable Install Tape
    Follow the screen prompts or icons to the Welcome to Base OS menu.

    Choose Start Maintenance Mode for System Recovery (Option 3). The next screen displays prompts for the Maintenance menu.

    Choose Access a Root Volume Group (Option 1).
    The next screen displays a warning that indicates you will not be able to return to the Base OS menu without rebooting.

    Choose 0 continue.
    The next screen displays information about all volume groups on the system.

    Select the root volume group by number. The logical volumes in rootvg will be displayed with two options.

    Choose Access this volume group and start a shell. (Option 1).
    If no errors occur, proceed with the following steps.    <====== very important

    Unmount the file system. (The following examples use /var. If you intend to reduce the /tmp file system, substitute /tmp for /var in the commands.) Execute:
        umount /var

    Remove the file system by executing:
        rmfs /var

    Determine the physical partition (PP) size of your rootvg volume group with the command:
       lsvg rootvg

    Create the logical volume with one of these commands:
        mklv -y hd9var rootvg [x]     (for /var)
    where x is the number of logical partitions you want to allocate. If your rootvg volume group has a PP size of 4MB, and you want the total size of the /var file system to be 40MB, then x would be 10.

    Create the file system with the following command:
        crfs -v jfs -d hd9var -m /var -a check=false -a free=false -a vol=/var

    NOTE: Substitute hd3 for hd9var and /tmp for /var if needed. Refer to the section Example of /etc/filesystems for the different attributes required for these filesystems.

    Mount the file system:
        mount /var

     Change the ownership and permissions to the proper values, as follows:
        chmod g-s /var
        chmod 755 /var
        chown bin.bin /var
    Then copy back the stuff from /var.bak. And edit /etc/filesystems to reflect the change for /var.
    Good luck,


    LVL 61

    Accepted Solution

    You can have /var on any disk controller, so no need to vorry about lv names etc.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now