LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (http://www.linuxquestions.org/questions/fedora-35/)
-   -   LVM Partition Resizing (http://www.linuxquestions.org/questions/fedora-35/lvm-partition-resizing-666683/)

ChairmanMeoww 08-31-2008 12:03 PM

LVM Partition Resizing
 
Hi guys...an old question I'm sure but having spent the last few hours searching the net and ending up no closer than when I started to achieving this I need help..

How do I go about resizing my Fedora 9 partition? Gparted, etc are out the window as it's a LVM partition and any other suggestions would be gratefully received.....

I've got 50 gb of free space I want to expand it into without losing my current data and no access to an external HDD to store the stuff on temporarily....anything else you want to know then just ask

Thanks for taking the time to read

Brian1 08-31-2008 02:22 PM

Never used LVM because of things I never liked about it. But what would be easiest is create the remaining as a new LVM partition and then create the partitions within that and then you can merge the new partitions with existing partitions in the orginal LVM partition and increase size that way. I only know there is commands to do all this. As for thier names not sure. Search here for LVM commands.

Brian

syg00 08-31-2008 04:45 PM

I don't think there is a pvextend type command yet. Add the new space as a pv, add it to the vg, extend the lv, then resize the filesystem within the lv.
Seems sensible - but I don't use LVM either, so ... have a look at the LVM howto on tldp.org. Redhat used to have doco on things like this too.

mpdavig 09-15-2008 10:25 PM

Increase an existing LV
 
Taken from my LVM management notes. I had first used this when I imaged an 80GB drive to a 120GB drive and wanted to make use of the 40GB of free space.

1. fdisk /dev/sda then press p

Code:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        1188    9438187+  8e  Linux LVM

2. Press d then 2 to remove the partition
3. Press n then primary p start cylinder 14 last cylinder 4865 to add the newly re-sized partition. WARNING: Make sure the old and new partition start at the same cylinder position, not doing so will destroy your data.
4. Press t partition 2 Hex code 8e
5. Press p

Code:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        4865    38973690  8e  Linux LVM

6. Finally press w write table to disk and exit and reboot
7. Use vgdisplay, pvdisplay, or lvdisplay to show the current and later ending size of your LV
8. Run pvresize /dev/sda2 to expand the PV on /dev/sda2 after enlarging the partition with fdisk
9. You could also extend the volume group across disks and partitions: pvcreate /dev/hdb1; vgextend videovg /dev/hdb1; vgdisplay videovg. With this method use fdisk to create a new partition instead of recreating the original one. This is certainly safer since there is less risk to your existing data and it makes it easier to break up volume groups in the future.
10. Use vgdisplay to find the Free PE / Size

Code:

  --- Volume group ---
  VG Name              SystemVG
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              37.17 GB
  PE Size              4.00 MB
  Total PE              9515
  Alloc PE / Size      2176 / 8.50 GB
  Free  PE / Size      7339 / 28.67 GB
  VG UUID              Bl4LEQ-R70i-3Qse-9z1p-BRcK-ibd7-2aelYx

11. Use lvdisplay to display current logical volumes

Code:

  --- Logical volume ---
  LV Name                /dev/SystemVG/RootLV
  VG Name                SystemVG
  LV UUID                dxB6Fs-6sQr-AaLg-1zQ6-Q1f9-AN6V-cbSovF
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                8.00 GB
  Current LE            2048
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

  --- Logical volume ---
  LV Name                /dev/SystemVG/SwapLV
  VG Name                SystemVG
  LV UUID                vSRWGx-zy8N-FrXK-3HP5-7pwW-F6SQ-IRJNeA
  LV Write Access        read/write
  LV Status              available
  # open                2
  LV Size                512.00 MB
  Current LE            128
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:1

12. lvextend -l +7339 /dev/SystemVG/RootLV (you can use the following to reduce again lvreduce -l -7339 /dev/SystemVG/RootLV)
13. lvdisplay /dev/SystemVG/RootLV to see the result

Code:

  --- Logical volume ---
  LV Name                /dev/SystemVG/RootLV
  VG Name                SystemVG
  LV UUID                dxB6Fs-6sQr-AaLg-1zQ6-Q1f9-AN6V-cbSovF
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                36.67 GB
  Current LE            9387
  Segments              2
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

14. ext2online /dev/SystemVG/RootLV while the filesystem is mounted or to be safe use resize2fs /dev/SystemVG/RootLV while the filesystem is unmounted. Note: resize2fs may require running e2fsck -f /dev/SystemVG/RootLV first.
Note: I did not have much luck with this on SLES 10 x86_64 (ext2online) however with Fedora Core 5 x86 this worked first try without errors.

haertig 09-19-2008 08:59 PM

Quote:

Originally Posted by mpdavig (Post 3281556)
1. fdisk /dev/sda

It is safer to use fdisk -u /dev/sda, or use the u command from within fdisk, to set the units to sectors instead of cylinders. If your partitions do not currently begin and end on cylinder boundaries telling fdisk that your resized partition needs to start at "cylinder 14" could be quite disastrous for your data! To help avoid potential problems, use fdisk with the smallest unit of measure it supports - a "sector". i.e., the -u option.

RottenMutt 09-28-2010 12:06 AM

Quote:

Originally Posted by mpdavig (Post 3281556)
Taken from my LVM management notes. I had first used this when I imaged an 80GB drive to a 120GB drive and wanted to make use of the 40GB of free space.

1. fdisk /dev/sda then press p

Code:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        1188    9438187+  8e  Linux LVM

2. Press d then 2 to remove the partition
3. Press n then primary p start cylinder 14 last cylinder 4865 to add the newly re-sized partition. WARNING: Make sure the old and new partition start at the same cylinder position, not doing so will destroy your data.
4. Press t partition 2 Hex code 8e
5. Press p

Code:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        4865    38973690  8e  Linux LVM

6. Finally press w write table to disk and exit and reboot
7. Use vgdisplay, pvdisplay, or lvdisplay to show the current and later ending size of your LV
8. Run pvresize /dev/sda2 to expand the PV on /dev/sda2 after enlarging the partition with fdisk
9. You could also extend the volume group across disks and partitions: pvcreate /dev/hdb1; vgextend videovg /dev/hdb1; vgdisplay videovg. With this method use fdisk to create a new partition instead of recreating the original one. This is certainly safer since there is less risk to your existing data and it makes it easier to break up volume groups in the future.
10. Use vgdisplay to find the Free PE / Size

Code:

  --- Volume group ---
  VG Name              SystemVG
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              37.17 GB
  PE Size              4.00 MB
  Total PE              9515
  Alloc PE / Size      2176 / 8.50 GB
  Free  PE / Size      7339 / 28.67 GB
  VG UUID              Bl4LEQ-R70i-3Qse-9z1p-BRcK-ibd7-2aelYx

11. Use lvdisplay to display current logical volumes

Code:

  --- Logical volume ---
  LV Name                /dev/SystemVG/RootLV
  VG Name                SystemVG
  LV UUID                dxB6Fs-6sQr-AaLg-1zQ6-Q1f9-AN6V-cbSovF
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                8.00 GB
  Current LE            2048
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

  --- Logical volume ---
  LV Name                /dev/SystemVG/SwapLV
  VG Name                SystemVG
  LV UUID                vSRWGx-zy8N-FrXK-3HP5-7pwW-F6SQ-IRJNeA
  LV Write Access        read/write
  LV Status              available
  # open                2
  LV Size                512.00 MB
  Current LE            128
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:1

12. lvextend -l +7339 /dev/SystemVG/RootLV (you can use the following to reduce again lvreduce -l -7339 /dev/SystemVG/RootLV)
13. lvdisplay /dev/SystemVG/RootLV to see the result

Code:

  --- Logical volume ---
  LV Name                /dev/SystemVG/RootLV
  VG Name                SystemVG
  LV UUID                dxB6Fs-6sQr-AaLg-1zQ6-Q1f9-AN6V-cbSovF
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                36.67 GB
  Current LE            9387
  Segments              2
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

14. ext2online /dev/SystemVG/RootLV while the filesystem is mounted or to be safe use resize2fs /dev/SystemVG/RootLV while the filesystem is unmounted. Note: resize2fs may require running e2fsck -f /dev/SystemVG/RootLV first.
Note: I did not have much luck with this on SLES 10 x86_64 (ext2online) however with Fedora Core 5 x86 this worked first try without errors.

Wow, thanks mpdavig. i did one thru eight, with the exception on step 3 i had to enter a partition number (2 in my case) when creating the new larger partition. instead of 9 and on, i used the graphical LVM manager, and in volume groups i selected my root Logical Volume and selected edit at the bottom. in edit i selected "use remaining" and hit ok. done.
FC13

Desert-Fox 06-16-2012 06:00 AM

Excellent Steps. This works, I've tested
 
This is an excellent explanation to fulfill your requirement. I have tested this :) works fine. !caution! backup your data before proceed.

Quote:

Originally Posted by mpdavig (Post 3281556)
Taken from my LVM management notes. I had first used this when I imaged an 80GB drive to a 120GB drive and wanted to make use of the 40GB of free space.

1. fdisk /dev/sda then press p

Code:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        1188    9438187+  8e  Linux LVM

2. Press d then 2 to remove the partition
3. Press n then primary p start cylinder 14 last cylinder 4865 to add the newly re-sized partition. WARNING: Make sure the old and new partition start at the same cylinder position, not doing so will destroy your data.
4. Press t partition 2 Hex code 8e
5. Press p

Code:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        4865    38973690  8e  Linux LVM

6. Finally press w write table to disk and exit and reboot
7. Use vgdisplay, pvdisplay, or lvdisplay to show the current and later ending size of your LV
8. Run pvresize /dev/sda2 to expand the PV on /dev/sda2 after enlarging the partition with fdisk
9. You could also extend the volume group across disks and partitions: pvcreate /dev/hdb1; vgextend videovg /dev/hdb1; vgdisplay videovg. With this method use fdisk to create a new partition instead of recreating the original one. This is certainly safer since there is less risk to your existing data and it makes it easier to break up volume groups in the future.
10. Use vgdisplay to find the Free PE / Size

Code:

  --- Volume group ---
  VG Name              SystemVG
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                2
  Open LV              2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              37.17 GB
  PE Size              4.00 MB
  Total PE              9515
  Alloc PE / Size      2176 / 8.50 GB
  Free  PE / Size      7339 / 28.67 GB
  VG UUID              Bl4LEQ-R70i-3Qse-9z1p-BRcK-ibd7-2aelYx

11. Use lvdisplay to display current logical volumes

Code:

  --- Logical volume ---
  LV Name                /dev/SystemVG/RootLV
  VG Name                SystemVG
  LV UUID                dxB6Fs-6sQr-AaLg-1zQ6-Q1f9-AN6V-cbSovF
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                8.00 GB
  Current LE            2048
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

  --- Logical volume ---
  LV Name                /dev/SystemVG/SwapLV
  VG Name                SystemVG
  LV UUID                vSRWGx-zy8N-FrXK-3HP5-7pwW-F6SQ-IRJNeA
  LV Write Access        read/write
  LV Status              available
  # open                2
  LV Size                512.00 MB
  Current LE            128
  Segments              1
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:1

12. lvextend -l +7339 /dev/SystemVG/RootLV (you can use the following to reduce again lvreduce -l -7339 /dev/SystemVG/RootLV)
13. lvdisplay /dev/SystemVG/RootLV to see the result

Code:

  --- Logical volume ---
  LV Name                /dev/SystemVG/RootLV
  VG Name                SystemVG
  LV UUID                dxB6Fs-6sQr-AaLg-1zQ6-Q1f9-AN6V-cbSovF
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                36.67 GB
  Current LE            9387
  Segments              2
  Allocation            inherit
  Read ahead sectors    0
  Block device          253:0

14. ext2online /dev/SystemVG/RootLV while the filesystem is mounted or to be safe use resize2fs /dev/SystemVG/RootLV while the filesystem is unmounted. Note: resize2fs may require running e2fsck -f /dev/SystemVG/RootLV first.
Note: I did not have much luck with this on SLES 10 x86_64 (ext2online) however with Fedora Core 5 x86 this worked first try without errors.



All times are GMT -5. The time now is 08:53 AM.