The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Extending root partition [critical]

Discussion in 'Data Protection' started by raamee, Dec 26, 2012.

  1. raamee

    raamee Active Member

    Joined:
    Mar 18, 2011
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Hello all,

    I have a server (Cent OS 6.3 64 bit) , whose root partition is very small (only 9 GB) and now its almost full. The OS installers, made partitions like that while installing the OS. Please review my df -h output:

    /http://pastebin.com/760k6Caa Filesystem Size Used Avail Use% Mounted on /dev/mapper/web-LogVol01 - Pastebin.com

    Now, its in critical stage. I need to extend the size of / partition. Can any one suggest best method of extending it without affecting any data?

    Best Regards.
     
  2. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Same here.

    The partition can be extended using lvmextend, however, its risky I think. If a lvm is lost then the server may not load. Lets see if someone else reply.
     
  3. quietFinn

    quietFinn Well-Known Member

    Joined:
    Feb 4, 2006
    Messages:
    998
    Likes Received:
    10
    Trophy Points:
    18
    Location:
    Finland
    cPanel Access Level:
    Root Administrator
    I suggest you check these directories:
    /var/log
    /usr/local/apache/logs
    /usr/local/cpanel/logs

    You should be able to free quite a lot disk space by removing older log files.
     
  4. raamee

    raamee Active Member

    Joined:
    Mar 18, 2011
    Messages:
    38
    Likes Received:
    0
    Trophy Points:
    6
    Thank you.

    But I have already cleared up log files, although there were not much data on it. The / partition is in critical disk space and I need to act fast.
     
  5. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1

    Logs use a very small percentage of the diskspace. Most of the diskspace used on our server is the mysql databases located at /var/lib/mysql which is being increased every day.
     
  6. vivekvsist

    vivekvsist Active Member

    Joined:
    May 29, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    Root lvm size can be increased using the command
    Code:
    lvextend
    We have just increased the size of our root lvm
    Code:
    lvextend -L +10G /dev/sunshell/lv_root
    
    Please note that there should be free space available in your VolumeGroup in order to extend the lvm. We did not have free space on our Vg so we had to reduce our swap partition by 10Gb ( from 32GB to 22GB ) and used this space for /


    Code:
    root@server [~]# swapoff /dev/sunshell/lv_swap
    
    Code:
    root@server [~]# lvreduce -L -10G /dev/sunshell/lv_swap 
      WARNING: Reducing active logical volume to 21.52 GiB
      THIS MAY DESTROY YOUR DATA (filesystem etc.)
    Do you really want to reduce lv_swap? [y/n]: y
      Reducing logical volume lv_swap to 21.52 GiB
      Logical volume lv_swap successfully resized
    
    Code:
    root@server [~]# mkswap /dev/sunshell/lv_swap 
    mkswap: /dev/sunshell/lv_swap: warning: don't erase bootbits sectors
            on whole disk. Use -f to force.
    Setting up swapspace version 1, size = 22560764 KiB
    no label, UUID=8b05ed3b-8327-4125-83d6-0485e8779d37
    

    Code:
    root@server [~]# swapon /dev/sunshell/lv_swap 
    
    Code:
                                          
    root@server [~]# lvextend -L +10G /dev/sunshell/lv_root 
      Extending logical volume lv_root to 60.00 GiB
      Logical volume lv_root successfully resized
    
    Code:
    root@server [~]# resize2fs /dev/sunshell/lv_root 
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/sunshell/lv_root is mounted on /; on-line resizing required
    old desc_blocks = 4, new_desc_blocks = 4
    Performing an on-line resize of /dev/sunshell/lv_root to 15728640 (4k) blocks.
    The filesystem on /dev/sunshell/lv_root is now 15728640 blocks long.
    
    
    If you do not have free space left on your VG, create a new physical volume and add that physical volume to the Volume Group. Then use the space for extending the lvm.

    Note: if you are reducing the size of an lvm, always unmount it first.

    Hope this helps
     
  7. sahostking

    sahostking Well-Known Member

    Joined:
    May 15, 2012
    Messages:
    300
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Cape Town, South Africa
    cPanel Access Level:
    Root Administrator
    Great tutorial on how to do this. Always wanted to know how.

    Very risky I'm sure though? On our servers we've played i very safe and gave root partitions enough space just incase.
     
Loading...

Share This Page