Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, I want to know the procedure to extend the root file system in Linux . How to extend the root file system? Can we use lvextend command directly online ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    May 2012
    Posts
    110

    Increase root filesytem using "lvextend " ?


    Hi,

    I want to know the procedure to extend the root file system in Linux .

    How to extend the root file system?

    Can we use lvextend command directly online to increase the root file system?

    Will their be any effect on the server, if we increase the file system online using lvextend command?


    What does resize2fs command do?

    Please help me with the info.


    Regards,
    Aparna.

  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    779
    It's not generally a good idea to play with the root fs while the system online, but according to this article it can be done: Resize a root filesystem on the fly - Robert's Blog
    If you're using logical volumes / lvm, then you can try. If you're not using logical volumes, lvextend won't help you.
    lvextend is used to extend the size of your logical volume. In order to do this, the volume group must have free space.

    resize2fs resizes your ext3/ext4 (or whatever) file system to the size of the disk/partition/logical volume that it resides on.

  3. #3
    Linux Newbie
    Join Date
    May 2012
    Posts
    110
    is it possible to make the file system as it was before after using lvextend command ?


    we use lvextend command to increase the filesystem,similarly is it possible to decrease the file system as it was earlier ?

  4. #4
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    779
    Quote Originally Posted by redhat70 View Post
    is it possible to make the file system as it was before after using lvextend command ?


    we use lvextend command to increase the filesystem,similarly is it possible to decrease the file system as it was earlier ?
    You would want lvreduce, not lvextend for that operation. It will take longer, because the system will have to move everything that's outside the smaller lvm's disk footprint inside of that footprint.

    So, if you have a 10gb file system, there may be some data written in the first 20% of the blocks, some in the next 50% of blocks, and some data written at the very last blocks of the file system. It has to move all that data into just those blocks. If your grow a file system with lvextend, you're adding blocks only, so data doesn't have to be moved.

    I'm not too sure how much of a concern this is, but I know shrinking a live logical volume is to be avoided.

  5. #5
    Linux Newbie
    Join Date
    May 2012
    Posts
    110
    is it possible to make the file system as it was before after using lvextend command ?


    we use lvextend command to increase the filesystem,similarly is it possible to decrease the file system as it was earlier ?

    For examply,if my root filesystem was 10 GB earlier.

    After increasing it using lvextend, it is increased to 15 GB. that means 5GB added.But now, i want to make it back to 10 GB only. Is this possible ?

  6. #6
    Linux Newbie
    Join Date
    Apr 2012
    Posts
    112
    Quote Originally Posted by redhat70 View Post
    is it possible to make the file system as it was before after using lvextend command ?


    we use lvextend command to increase the filesystem,similarly is it possible to decrease the file system as it was earlier ?

    For examply,if my root filesystem was 10 GB earlier.

    After increasing it using lvextend, it is increased to 15 GB. that means 5GB added.But now, i want to make it back to 10 GB only. Is this possible ?
    You can use lvdreduce or lvresize.

    read the manual page for either before you do though.

    Depending on what you have done with your filesystem after you expanded the lv, reducing the lv might lead to data loss

  7. #7
    Just Joined!
    Join Date
    Sep 2012
    Location
    India
    Posts
    29
    Increase /root file system using lvm

    ----------------------------------------------------------------------------------------
    EXTEND ROOT PARTITION - LVEXTEND

    Is root partition an LVM partition?? If Yes follow the below step

    Step1:
    Get detailed description about LVM

    Identify volume group on which root partition is located
    Volgroup
    Free Space
    PE Size

    You can find this information using following commands
    vgdisplay
    vgs -v

    Step2: Resize your root partition
    Once you have these details you can extend your partition if space is available.

    Lvextend -L|-l size root-partition

    * Note there is difference between -L exact size; -l is PE size

    Step3:
    resize2fs -p partition

    ----------------------------------------------------------------------------------------
    REDUCE PARTITION USING LVREDUCE

    * IMPORTANT
    CHANCES OF DATA LOSS ARE HIGH WHEN YOU LVREDUCE ON ONLINE FILESYSTEM.

    STEP1:
    resize2fs /partition size
    lvreduce -L|-l size partition

    * be cautious while performing lvreduce ; it can lead to loss of data


    Best Regards
    Nikhil Shinde

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •