Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
[Solved] Resizing LVM
-
- Posts: 18
- Joined: 2018-08-19 16:26
[Solved] Resizing LVM
I do want to reduce the /home from 100 GB to 25 GB and I do want the remaining free space to assign to /var.
What exact commands should I perform in order to have those LVM partitions be resized as I do want to have it in right place?
What exact commands should I perform in order to have those LVM partitions be resized as I do want to have it in right place?
Last edited by vitaliok78 on 2018-09-05 16:25, edited 1 time in total.
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: Resizing LVM
How to resize a lvm partition on Debian
===============
https://wiki.debian.org/LVM
'fdisk' command, use the 'man fdisk' command to get details,
or can use the command 'gparted', if you have "gparted" installed.
===============
https://wiki.debian.org/LVM
Or you can use theList of LV commands
lvchange — Change attributes of a Logical Volume.
lvconvert — Convert a Logical Volume from linear to mirror or snapshot.
lvcreate — Create a Logical Volume in an existing Volume Group.
lvdisplay — Display the attributes of a Logical Volume.
lvextend — Extend the size of a Logical Volume.
lvreduce — Reduce the size of a Logical Volume.
lvremove — Remove a Logical Volume.
lvrename — Rename a Logical Volume.
lvresize — Resize a Logical Volume.
lvs — Report information about Logical Volumes.
lvscan — Scan (all disks) for Logical Volumes.
'fdisk' command, use the 'man fdisk' command to get details,
or can use the command 'gparted', if you have "gparted" installed.
"What we expect you have already Done"
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
Re: Resizing LVM
this is not for the fainthearted
i suggest you read a number of the links that garry posted to make sure that in your mind you understand what you are doing with each step
i suggest you read a number of the links that garry posted to make sure that in your mind you understand what you are doing with each step
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: Resizing LVM
If the OP at least showed us the existing partitions, structure, someone might be able to
give some better details, the 'df' command is good for that :
Example: and show us what shows.
Please use code boxes.
give some better details, the 'df' command is good for that :
Example:
Code: Select all
man df
Code: Select all
df -h
Please use code boxes.
Re: Resizing LVM
would be helpful also to know what filesystem is being used
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: Resizing LVM
Please post the output of
so we know more about your installation and can provide adequate advice.
Some filesystems types such as XFS cannot be reduced.
General steps :
Login directly as root, or preferably boot in rescue/maintenance/emergency/single user mode.
Unmount /home unless its filesystem type allows online shrinking (such as BTRFS or NILFS2).
Reduce the home filesystem with the appropriate tool (resize2fs for the ext* family).
Reduce the home logical volume to the same (or bigger, NOT smaller) size with lvreduce.
If a logical volume for /var does not already exist :
- Create a new logical volume for /var with lvcreate.
- Create a filesystem in the logical volume with the appropriate tool (mkfs.ext* for ext*).
- Mount the logical volume on a temporary mount point.
- Copy the contents of /var into the mount point.
- Reboot the system.
- Edit /etc/fstab to automatically mount the logical volume on /var at boot.
- If everything works as expected, bind mount / on a temporary directory to access the old contents hidden under /var and delete it.
If a logical volume for /var already exists :
- Extend the logical volume with lvextend.
- Resize the filesystem in the logical volume with the appropriate command (resize2fs for ext*)
- Remount /home if you had to unmount it.
Or you can do all this in a live system.
Code: Select all
lsblk
df -hT
Some filesystems types such as XFS cannot be reduced.
General steps :
Login directly as root, or preferably boot in rescue/maintenance/emergency/single user mode.
Unmount /home unless its filesystem type allows online shrinking (such as BTRFS or NILFS2).
Reduce the home filesystem with the appropriate tool (resize2fs for the ext* family).
Reduce the home logical volume to the same (or bigger, NOT smaller) size with lvreduce.
If a logical volume for /var does not already exist :
- Create a new logical volume for /var with lvcreate.
- Create a filesystem in the logical volume with the appropriate tool (mkfs.ext* for ext*).
- Mount the logical volume on a temporary mount point.
- Copy the contents of /var into the mount point.
- Reboot the system.
- Edit /etc/fstab to automatically mount the logical volume on /var at boot.
- If everything works as expected, bind mount / on a temporary directory to access the old contents hidden under /var and delete it.
If a logical volume for /var already exists :
- Extend the logical volume with lvextend.
- Resize the filesystem in the logical volume with the appropriate command (resize2fs for ext*)
- Remount /home if you had to unmount it.
Or you can do all this in a live system.
Fdisk and gparted cannot handle LVM logical volumes. Gparted can only be used to resize a partition containing an LVM physical volume.GarryRicketson wrote: Or you can use the
'fdisk' command, use the 'man fdisk' command to get details,
or can use the command 'gparted', if you have "gparted" installed.
Last edited by p.H on 2018-09-05 06:59, edited 1 time in total.
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: Resizing LVM
Thanks, some of the search results, mentioned fdisk and gparted, but just goes to show,... Apology on my part for the mis-information.
Looking at the Debian wiki: https://wiki.debian.org/LVM
If the OP does not have that installed, they will need it to be able to use the 'LVM' commands.
I am not posting all of what the wiki says, the OP needs to really look at that,
to get the details, but there seems to be a GUI available, :
Make a good backup first, before doing anything to change your partitions, and make sure the backup will work. There is no 100% safe way to do this, there is all ways the possibility something can go wrong.
Probably if the OP has good instructions, and follows the steps closely, nothing will go wrong, but there is no way anybody can guarantee nothing will go wrong. Make a good back up first. IF the OP does not know how to do that, then they need to concentrate on learning how to do that first.
==== edited, NOTE: ====
I have been looking at the various search results, on How to resize a LVM partition, and still am not finding any really good, clear tutorial, step by step:
(some that look good, but are not for Debian, and clearly state that on others distro , it might be different)
Which seems to be what the OP wants/needs
Looking at the Debian wiki: https://wiki.debian.org/LVM
Code: Select all
sudo apt-get install lvm2
I am not posting all of what the wiki says, the OP needs to really look at that,
to get the details, but there seems to be a GUI available, :
!!!MOST IMPORTANT!!!!If needed, you can install system-config-lvm, it's a utility for graphically configuring Logical Volumes.
Make a good backup first, before doing anything to change your partitions, and make sure the backup will work. There is no 100% safe way to do this, there is all ways the possibility something can go wrong.
Probably if the OP has good instructions, and follows the steps closely, nothing will go wrong, but there is no way anybody can guarantee nothing will go wrong. Make a good back up first. IF the OP does not know how to do that, then they need to concentrate on learning how to do that first.
==== edited, NOTE: ====
I have been looking at the various search results, on How to resize a LVM partition, and still am not finding any really good, clear tutorial, step by step:
(some that look good, but are not for Debian, and clearly state that on others distro , it might be different)
Which seems to be what the OP wants/needs
One main reason none of the tutorials are easy to follow is there are many, variations, like what filesystem, etc,...so any way, with more details, some one might be able to walk the OP through this. ThanksWhat exact commands should I perform in order to have those LVM partitions be resized as I do want to have it in right place?
-
- Posts: 1
- Joined: 2018-05-28 01:13
Re: Resizing LVM
I've found this of a little help in my situation. It's because I have a ext4 partition type:
https://www.systutorials.com/5621/exten ... -in-linux/
https://www.systutorials.com/5621/exten ... -in-linux/
-
- Posts: 18
- Joined: 2018-08-19 16:26
Re: Resizing LVM
GarryRicketson wrote:If the OP at least showed us the existing partitions, structure, someone might be able to
give some better details, the 'df' command is good for that :
Example:and show us whatCode: Select all
man df
shows.Code: Select all
df -h
Please use code boxes.
Filesystem Size Used Avail Use% Mounted on
/dev/dm-0 8.2G 3.8G 3.9G 50% /
udev 10M 0 10M 0% /dev
tmpfs 778M 8.9M 769M 2% /run
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 236M 33M 191M 15% /boot
/dev/mapper/zeus--vg-var 2.7G 2.7G 0 100% /var
/dev/mapper/zeus--vg-tmp 360M 2.1M 335M 1% /tmp
/dev/mapper/zeus--vg-home 128G 40G 82G 33% /home
tmpfs 389M 0 389M 0% /run/user/0
-
- Posts: 18
- Joined: 2018-08-19 16:26
Re: Resizing LVM
lsblkp.H wrote:Please post the output ofso we know more about your installation and can provide adequate advice.Code: Select all
lsblk df -hT
Some filesystems types such as XFS cannot be reduced.
General steps :
Login directly as root, or preferably boot in rescue/maintenance/emergency/single user mode.
Unmount /home unless its filesystem type allows online shrinking (such as BTRFS or NILFS2).
Reduce the home filesystem with the appropriate tool (resize2fs for the ext* family).
Reduce the home logical volume to the same (or bigger, NOT smaller) size with lvreduce.
Create a new logical volume for /var with lvcreate.
Create a filesystem in the logical volume with the appropriate tool (mkfs.ext* for ext*).
Mount the logical volume on a temporary mount point.
Copy the contents of /var into the mount point.
Edit /etc/fstab to automatically mount the logical volume on /var at boot.
Reboot the system.
If everything works as expected, bind mount / on a temporary directory to access the old contents hidden under /var and delete it.
Or you can do all this in a live system.
Fdisk and gparted cannot handle LVM logical volumes. Gparted can only be used to resize a partition containing an LVM physical volume.GarryRicketson wrote: Or you can use the
'fdisk' command, use the 'man fdisk' command to get details,
or can use the command 'gparted', if you have "gparted" installed.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 149.1G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 148.8G 0 part
├─zeus--vg-root 254:0 0 8.4G 0 lvm /
├─zeus--vg-swap_1 254:1 0 7.9G 0 lvm [SWAP]
├─zeus--vg-var 254:2 0 2.8G 0 lvm /var
├─zeus--vg-tmp 254:3 0 380M 0 lvm /tmp
└─zeus--vg-home 254:4 0 129.4G 0 lvm /home
sr0 11:0 1 1024M 0 rom
df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/dm-0 ext4 8.2G 3.8G 3.9G 50% /
udev devtmpfs 10M 0 10M 0% /dev
tmpfs tmpfs 778M 8.9M 769M 2% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 ext2 236M 33M 191M 15% /boot
/dev/mapper/zeus--vg-var ext4 2.7G 2.7G 0 100% /var
/dev/mapper/zeus--vg-tmp ext4 360M 2.1M 335M 1% /tmp
/dev/mapper/zeus--vg-home ext4 128G 40G 82G 33% /home
tmpfs tmpfs 389M 0 389M 0% /run/user/0
Re: Resizing LVM
right so you have home and var as seperate VGs.
can you provide please provide vgdisplay, pvdisplay and lvdisplay
can you provide please provide vgdisplay, pvdisplay and lvdisplay
Desktop: A320M-A PRO MAX, AMD Ryzen 5 3600, GALAX GeForce RTX™ 2060 Super EX (1-Click OC) - Sid, Win10, Arch Linux, Gentoo, Solus
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
Laptop: hp 250 G8 i3 11th Gen - Sid
Kodi: AMD Athlon 5150 APU w/Radeon HD 8400 - Sid
-
- Posts: 18
- Joined: 2018-08-19 16:26
Re: Resizing LVM
vgdisplaymilomak wrote:right so you have home and var as seperate VGs.
can you provide please provide vgdisplay, pvdisplay and lvdisplay
--- Volume group ---
VG Name zeus-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 5
Open LV 5
Max PV 0
Cur PV 1
Act PV 1
VG Size 148.81 GiB
PE Size 4.00 MiB
Total PE 38095
Alloc PE / Size 38095 / 148.81 GiB
Free PE / Size 0 / 0
VG UUID gp90hz-jwIV-V58L-UG7o-JILY-z883-7MsRGn
pvdisplay
--- Physical volume ---
PV Name /dev/sda5
VG Name zeus-vg
PV Size 148.81 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 38095
Free PE 0
Allocated PE 38095
PV UUID ucoGPe-d4T9-Nl9F-rGIj-Mp1L-qJV4-p3M7Qk
lvdisplay
--- Logical volume ---
LV Path /dev/zeus-vg/root
LV Name root
VG Name zeus-vg
LV UUID mGe4TC-fbzf-K3xq-lO1r-bfrY-ftv1-2fRbNt
LV Write Access read/write
LV Creation host, time (none), 2018-07-06 22:25:52 +0300
LV Status available
# open 1
LV Size 8.38 GiB
Current LE 2145
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/zeus-vg/var
LV Name var
VG Name zeus-vg
LV UUID wY75kH-fWZO-0l1D-kEdX-zQQe-qWDW-S7wEox
LV Write Access read/write
LV Creation host, time (none), 2018-07-06 22:25:52 +0300
LV Status available
# open 1
LV Size 2.79 GiB
Current LE 715
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:2
--- Logical volume ---
LV Path /dev/zeus-vg/swap_1
LV Name swap_1
VG Name zeus-vg
LV UUID ggvQdS-TOXj-8aGA-Bk9Q-6pxW-fi4R-YYbFMV
LV Write Access read/write
LV Creation host, time (none), 2018-07-06 22:25:52 +0300
LV Status available
# open 2
LV Size 7.85 GiB
Current LE 2010
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
--- Logical volume ---
LV Path /dev/zeus-vg/tmp
LV Name tmp
VG Name zeus-vg
LV UUID acrPFB-z5dt-N7TX-r4FJ-Hzbs-IMMG-2my08S
LV Write Access read/write
LV Creation host, time (none), 2018-07-06 22:25:52 +0300
LV Status available
# open 1
LV Size 380.00 MiB
Current LE 95
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:3
--- Logical volume ---
LV Path /dev/zeus-vg/home
LV Name home
VG Name zeus-vg
LV UUID lQGL8s-1lyF-qCd0-eKMN-8602-Wdif-LOE0kC
LV Write Access read/write
LV Creation host, time (none), 2018-07-06 22:25:52 +0300
LV Status available
# open 1
LV Size 129.41 GiB
Current LE 33130
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:4
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: Resizing LVM
Thank you for posting the needed details.
25 gb in the home partition , (to me, any way, it is really hard to sort the info when people do not use code boxes)
But any way here it shows:
If the home partition is currently using 40G , shrinking it to 25G , will cause quite a few problems. You could still resize it , but make sure you don't go
to small, it would need to be over 40g.
I am not any expert, but it does not look like it will be possible to usePostby vitaliok78 » 2018-08-31 12:40
I do want to reduce the /home from 100 GB to 25 GB and I do want the remaining free space to assign to /var.
25 gb in the home partition , (to me, any way, it is really hard to sort the info when people do not use code boxes)
But any way here it shows:
Code: Select all
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/zeus--vg-home ext4 128G 40G 82G 33% /home
to small, it would need to be over 40g.
-
- Posts: 18
- Joined: 2018-08-19 16:26
Re: Resizing LVM
I do want to extend /var directory.GarryRicketson wrote:Thank you for posting the needed details.I am not any expert, but it does not look like it will be possible to usePostby vitaliok78 » 2018-08-31 12:40
I do want to reduce the /home from 100 GB to 25 GB and I do want the remaining free space to assign to /var.
25 gb in the home partition , (to me, any way, it is really hard to sort the info when people do not use code boxes)
But any way here it shows:If the home partition is currently using 40G , shrinking it to 25G , will cause quite a few problems. You could still resize it , but make sure you don't goCode: Select all
Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/zeus--vg-home ext4 128G 40G 82G 33% /home
to small, it would need to be over 40g.
-
- Global Moderator
- Posts: 3049
- Joined: 2017-09-17 07:12
- Has thanked: 5 times
- Been thanked: 132 times
Re: Resizing LVM
Log in directly as root.
You can of course adjust the indicated sizes. I advise to not allocate all the available space to /var at once and keep some free space for future growth of any logical volume when needed. Extending a logical volume (and its filesystem) is easy : just repeat the above last two commands.
Code: Select all
# unmount /home because an ext4 filesystem cannot be reduced while mounted
umount /home
# resize the ext4 filesystem in logical volume zeus-vg/home to 50G
fsck -f /dev/mapper/zeus--vg-home
resize2fs /dev/mapper/zeus--vg-home 50G
# reduce the logical volume zeus-vg/home to 50G
lvreduce -L50G /dev/mapper/zeus--vg-home
# remount /home
mount /home
# extend the logical volume zeus-vg/var by 20G
lvextend -L+20G /dev/mapper/zeus--vg-var
# resize the ext4 filesystem in logical volume zeus-vg/var to the new volume size
resize2fs /dev/mapper/zeus--vg-var
-
- Posts: 18
- Joined: 2018-08-19 16:26
Re: Resizing LVM
p.H wrote:Log in directly as root.You can of course adjust the indicated sizes. I advise to not allocate all the available space to /var at once and keep some free space for future growth of any logical volume when needed. Extending a logical volume (and its filesystem) is easy : just repeat the above last two commands.Code: Select all
# unmount /home because an ext4 filesystem cannot be reduced while mounted umount /home # resize the ext4 filesystem in logical volume zeus-vg/home to 50G fsck -f /dev/mapper/zeus--vg-home resize2fs /dev/mapper/zeus--vg-home 50G # reduce the logical volume zeus-vg/home to 50G lvreduce -L50G /dev/mapper/zeus--vg-home # remount /home mount /home # extend the logical volume zeus-vg/var by 20G lvextend -L+20G /dev/mapper/zeus--vg-var # resize the ext4 filesystem in logical volume zeus-vg/var to the new volume size resize2fs /dev/mapper/zeus--vg-var
-
- Posts: 18
- Joined: 2018-08-19 16:26
Re: [Solved] Resizing LVM
I fully resolved the matter regarding resizing the LVM disk without issues.p.H wrote:What is the point of quoting my post without adding any comment ?
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: [Solved] Resizing LVM
Thanks P.H, for giving the instructions you gave, as for the full quote , with no additional comment, or anything, I don't know :
Please learn to stop misusing "full quoting."
It does not make sense to me either when some one does that.
Please learn to stop misusing "full quoting."
It does not make sense to me either when some one does that.
"What we expect you have already Done"
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?