Extending and Shrinking Logical Partitions

(Difference between revisions)
Jump to: navigation, search
(Important Notes)
Line 1: Line 1:
 
We found out that the way our parititions were originally was that we did not have enough space for the root partition and more than enough on our home.  Since we're using LVMs, we needed to resize those, preferably with everything running and without losing data.
 
We found out that the way our parititions were originally was that we did not have enough space for the root partition and more than enough on our home.  Since we're using LVMs, we needed to resize those, preferably with everything running and without losing data.
 
+
test
 
== Important Notes ==
 
== Important Notes ==
 
*This messes with your logical volumes.  This can damage your data if you do it incorrectly or if you do not take proper precautions.  BACK UP YOUR DATA!
 
*This messes with your logical volumes.  This can damage your data if you do it incorrectly or if you do not take proper precautions.  BACK UP YOUR DATA!

Revision as of 21:06, 25 April 2013

We found out that the way our parititions were originally was that we did not have enough space for the root partition and more than enough on our home. Since we're using LVMs, we needed to resize those, preferably with everything running and without losing data. test

Contents

Important Notes

  • This messes with your logical volumes. This can damage your data if you do it incorrectly or if you do not take proper precautions. BACK UP YOUR DATA!
  • This method is intended for logical volumes. We take no responsibility for anything you do with this otherwise.
  • We used resize2fs for this process, but there are other tools (ex: ext2online or resize_reiserfs).

Overview

What this method does is shrink one partition (say, /home), and expand another (/, for instance). With LVMs, this becomes a matter of shrinking the filesystem on the volume and then the volume itself. Afterwards, when you want to expand the other partition, you do the same process in reverse, you increase the volume size and then increase the filesystem to fill the new volume.

Process

Shrink the filesystem and volume

  1. Cut a hole in the box.
  2. Unmount the partition you're about to shrink. If you're trying to do this to something like /, then you're going to need to do it from a live-cd or different installation.
  3. Run the following command
    resize2fs -p /dev/vg_ticc1/lv_home 200G
  4. You should get a note that you need to run
    e2fsck -f /dev/vg_ticc1/lv_home
  5. Run the command. If something goes wrong during this step, STOP. That could be an indicator of greater disk issues.
  6. Run the resize2fs command again.
  7. Remount the drive and check to ensure that it completed successfully.
  8. Run the command
    lvreduce -L 200G /dev/vg_ticc1/lv_home
  9. This WILL produce a warning telling you that you may destroy your data. This should have been mitigated by the backup procedure that you definitely followed, right? Additionally, if you try to reduce the volume to a size smaller than what you just set for the filesystem, you may encounter bugs. Like your data missing.
  10. Check that this freed up space by running vgdisplay. It should show some under "Free PE / Size."

Extend the other volume and filesystem

  1. Start by ensuring that you have the space available to extend the volume by running vgdisplay.
  2. You can use the lvdisplay command to check the proper names of your volumes as well as their sizes.
  3. Run the command
    lvextend -l +100%FREE /dev/vg_ticc1/lv_root
    This extends the logical volume to use up all of the free space within the group.
  4. Extend the filesystem by running
    resize2fs -p /dev/vg_ticc1/lv_root
  5. Check that everything worked as expected by running df -h.
  6. This should be everything.

References and External Links

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox