-
Notifications
You must be signed in to change notification settings - Fork 1
The Kubuntu install process names the volume group (vg) vgkubuntu
and the root logical
volume root
when use guided LVM is chosen. Those names are used in the example commands here.
May be helpful to run sudo lvs
before and after to see the change. This example assumes that
the root LV is larger than 50G to start and that you are shrinking it down to 50G.
I changed the resize2fs command to create the minimum fs size initially, shrink the partition and then resize the fs to the new partition size, instead of trying to resize to the size we plan to shrink the partition to.
sudo lvs
sudo e2fsck -fy /dev/vgkubuntu/root
sudo resize2fs -M /dev/vgkubuntu/root
sudo lvreduce -L 50G /dev/vgkubuntu/root
sudo resize2fs /dev/vgkubuntu/root
sudo lvs
Using a +
prefix on the -L
option size value to the lvextend
command is the amount to grow
instead of a new absolute size.
sudo umount /dev/mapper/vgkubuntu-projects
sudo e2fsck -fy /dev/mapper/vgkubuntu-projects
sudo lvextend -L +10G /dev/mapper/vgkubuntu-projects
sudo resize2fs /dev/mapper/vgkubuntu-projects
The mkfs.ext4
-L
option specifies the label for the partition
sudo lvcreate -L 20G -n userdata vgkubuntu
sudo mkfs.ext4 -L userdata /dev/mapper/vgkubuntu-userdata
There are a couple of different ways, the example shows using arguments of vg-name old-lv-name new-lv-name
.
Remember if you are renaming the root lv to also update the /etc/fstab
AND the /boot/grub/grub.cfg
.
The example also includes setting the ext4 filesystem label, assuming the lv is formatted as ext4.
sudo lvrename vgkubuntu root ku2204_root
sudo e2label /dev/mapper/vgkubuntu-ku2204_root "ku2204-root"
Use the lvremove [VG]/[LV]
utility to remove (delete) a logical volume from a volume group.
The LV must be unmounted.
Specifying a VG without an LV will remove ALL LV of that VG!
lvremove removes one or more LVs. For standard LVs, this returns the logical extents that were used by the LV to the VG for use by other LVs. Removing an origin LV will also remove all dependent snapshots.
Example removing the projects
LV from the vgkubuntu
VG
sudo lvremove vgkubuntu/projects
Here's an example /etc/fstab
mounting LVs in the vgkubuntu
volumegroup
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/mapper/vgkubuntu-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/nvme0n1p2 during installation
UUID=32729611-d5e0-4f13-84be-2b864e4ca75c /boot ext4 defaults 0 2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=A340-E58F /boot/efi vfat umask=0077 0 1
/dev/mapper/vgkubuntu-swap_1 none swap sw 0 0
/dev/mapper/vgkubuntu-var /var ext4 defaults 0 2
/dev/mapper/vgkubuntu-userdata /userdata ext4 defaults 0 2
/dev/mapper/vgkubuntu-projects /home/mjl/Projects ext4 defaults 0 2
The encrypted pv shows in the Partition Manager as luks encrypted, I saw it as nvme0n1p3
Running cryptsetup to ask for the password and create the volume group ? mount point
sudo cryptsetup -v luksOpen /dev/nvme0n1p3 vgkubuntu
- https://www.redhat.com/sysadmin/introduction-logical-volume-manager
- https://www.redhat.com/sysadmin/create-physical-volume
- https://www.redhat.com/sysadmin/create-volume-group
- https://www.redhat.com/sysadmin/creating-logical-volumes
- https://www.rootusers.com/lvm-resize-how-to-decrease-an-lvm-partition/
- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/high_availability_add-on_administration/s1-lvmsetupnfs-haaa