How To Expand A Filesystem in AIX (df, lsvg, chfs)

Really quick tutorial on expanding a filesystem in AIX. This is assuming you already have the disk that you need in place.

AIX cilpart

For the impatient….


Sponsored Links



  • df -k [FILESYSTEM] to find out existing filesystem usage and LV for that filesystem
  • lslv [LVNAME] to find out VG for that LV
  • lsvg [VGNAME] to find out how many PPs are free
  • chfs -a size=[size setting] [FILESYSTEM] to grow the filesystem

    If your chfs command above errors out with 0516-787 extendlv: Maximum allocation for logical volume LVNAME is NUMBER, then you need to: chlv -x [num] [lvname]

  • df -k [FILESYSTEM] to see changes made

Full Story..


Sponsored Links



  1. Our /home directory reached 90%
  2. # df -k /home
    Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
    /dev/hd1 2097152 218780 90% 25894 30% /home
    #

  3. Do we have enough space available in VG to expand?
  4. Find out the VG.

    # lslv hd1
    LOGICAL VOLUME: hd1 VOLUME GROUP: rootvg
    LV IDENTIFIER: 0007b8420000d9000000011f2491100e.8 PERMISSION: read/write
    VG STATE: active/complete LV STATE: opened/syncd
    TYPE: jfs2 WRITE VERIFY: off
    MAX LPs: 512 PP SIZE: 128 megabyte(s)
    COPIES: 1 SCHED POLICY: parallel
    LPs: 20 PPs: 20
    STALE PPs: 0 BB POLICY: relocatable
    INTER-POLICY: minimum RELOCATABLE: yes
    INTRA-POLICY: center UPPER BOUND: 32
    MOUNT POINT: /home LABEL: /home
    MIRROR WRITE CONSISTENCY: on/ACTIVE
    EACH LP COPY ON A SEPARATE PV ?: yes
    Serialize IO ?: NO
    #

    How much space is available in the VG?

    # lsvg rootvg
    VOLUME GROUP: rootvg VG IDENTIFIER: 0007b8420000d9000000011f2491100e
    VG STATE: active PP SIZE: 128 megabyte(s)
    VG PERMISSION: read/write TOTAL PPs: 599 (76672 megabytes)
    MAX LVs: 256 FREE PPs: 282 (36096 megabytes)
    LVs: 13 USED PPs: 317 (40576 megabytes)
    OPEN LVs: 11 QUORUM: 2 (Enabled)
    TOTAL PVs: 1 VG DESCRIPTORS: 2
    STALE PVs: 0 STALE PPs: 0
    ACTIVE PVs: 1 AUTO ON: yes
    MAX PPs per VG: 32512
    MAX PPs per PV: 1016 MAX PVs: 32
    LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
    HOT SPARE: no BB POLICY: relocatable
    #

  5. Use chfs command to expand
  6. Examples

    chfs -a size=3G /home
    chfs -a size=3000M /home
    chfs -a size=+1G /home
    chfs -a size=+500M /home

    What those mean

    • The “M” stands for megabytes
    • The “G” stands for gigabytes
    • The “+” is relative sizing: change the current amount by adding this much
    • Without the “+” is absolute sizing: change the current amount TO this much
    • NOTE: You can use “-” to decrease a filesystem size. Generally speaking for LVs, it is harder to shrink a filesystem. Sometimes it cannot be done while the filesystem is mounted, and sometimes depending on fragmentation it may not be able to be done at all. I have found AIX to be more robust in this department than various Linux LVM implementations. Generally speaking, though, when you increase your filesystem size, it is best to think of it as permanent .. (for the most part).

    From the chfs man page …

    If Value has the M suffix, it is interpreted to be in Megabytes. If Value has a G suffix, it is interpreted to be in Gigabytes. If Value begins with a +, it is interpreted as a request to increase the file system size by the specified amount. If the specified size is not evenly divisible by the physical partition size, it is rounded up to the closest number that is evenly divisible.

    My example.. Change to absolute size 2.5G or 2500M


    # df -k /home
    Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
    /dev/hd1 2097152 218780 90% 25894 30% /home
    # chfs -a size=2500M /home
    Filesystem size changed to 5242880
    # df -k /home
    Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
    /dev/hd1 2621440 742988 72% 25894 13% /home
    #

  7. If chfs errors with 0516-787: extendlv: Maximum allocation (etc)…
  8. If you get an error like:

    0516-787 extendlv: Maximum allocation for logical volume vg01vol1
    is 512.

    This means that you have hit the limit on the LV of how large you can make it.

    The first time I hit this error I almost had a heart attack. Fortunately, you can extend this very easily either using chlv or smitty

    In this example I was trying to expand my LV (mydatalv01) to 600 PPs and the limit was 512 PPs


    # chlv -x 600 mydatalv01

    After that you can then do your chfs command

    # chfs -a size=+25G /mydata01

    In smitty:


    smitty chlv -> Change a Logical Volume -> [ENTER] -> LOGICAL VOLUME name -> [F4]

    And from there you can change LV properties.

  9. DONE!

Thanks!!

, Geek, Unix

24 thoughts on “How To Expand A Filesystem in AIX (df, lsvg, chfs)

  1. Another thank you…

    I’m a “former” unix sysadmin (HP-UX and linux), since moved onto Storage. But a call from my director at 4am this morning, when we couldn’t get a hold of any of our AIX admins, and this guide helped me save the day!

  2. Thank you!. AIX admin is out. Was going to run out of space in minutes. Found this page, excellent detailed instructions. Crisis averted

  3. Been awhile since I commented, I stopped replying to each comment individually mostly for readability sake (not to clog the comments area up even more). However, I am always grateful for everyone and anyone who takes the time to comment. Thanks!!

  4. Solo para agradecer este post, los pasos fueron sencillos y claros. No tenia idea de como ampliar mi filesystem pero afortunadamente me encontre con esta ayuda.
    Saludos y gracias desde Tlaxcala Mexico

  5. Hi Ben,

    I find your article useful,
    I’m new at aix world, and been assigned to me. I have a comment though is your item 2. and 3.
    for item 2, the result of # lslv hd1 command, what indication in the result that we know that there’s still space available in VG to expand?

    for item no. 3, the result of #lsvg rootvg,
    what indication in the result the availability of space in the VG?

    based on the command/result.
    what is our maximum size to expand a certain directory like /home?

    thanks, cheers,

    Noli

    • Hi there! Thanks for the questions.

      # lslv hd1

      is to find out which VG the LV is on. In my example, I highlighted in red the part you want to look for which tells me that the LV “hd1″ is in rootvg

      Then you want to run

      # lsvg rootvg

      For the output of the command look in the parts I highlighted in red which are:

      PP SIZE: 128 megabyte(s)
      TOTAL PPs: 599 (76672 megabytes)
      FREE PPs: 282 (36096 megabytes)
      USED PPs: 317 (40576 megabytes)

      The first line “PP SIZE” tells you the size of each “PP” which is basically a unit size for the LV/VG. In this case each PP is 128 megabytes

      The second line “TOTAL PP” is the total capacity of the VG in PP units. In this case, the total capacity of my rootvg is 599 PPs (or in parentheses, 76672 megabytes or roughly 76gig)

      The third line “FREE PP” tells you how much free space you have left, in this case 282 free PP, approximately 36gig

      The fourth line is “USED PP” which tells you how much space you currently have allocated to the LVs. In this case 317 PP, or 40 gig

      Short version: my full capacity is about 76gig. I am using about 40gig. I have 36gig free.

      Does this help?

      So my maximum free space available right now is 36gig free.

      If that’s not enough, you can look to shrinking other LV in rootvg to create more free space. I wouldn’t recommend it unless you absolutely have to

      Once you decide how much free space you want to use, you can use the chfs command. I would never recommend you use 100% free. Expansion is easy, reduction is hard. Expand only what you need to so you still have free PP left in case something else fills up.

      So let’s say you want to use 10gig of your 36gig free, then

      chfs -a size=+10G /home

      Hope that helps!

      Ben

  6. Thanks! I am doing this resize of “/tmp” on a DB2 server running AIX.
    If only IBM could write documentation which explains WHY we perform these steps, I think we’d better understand “how” to do them ourselves next time.

    Don’t let this data fade away!

Leave a Comment

Your email address will not be published. Required fields are marked *

Spam protection by WP Captcha-Free