pvcreate
expects the name of a block device, but above you are giving it two parameters, mylvm
(which I presume is a logical volume name) and the block device /dev/sda3
.
Create the physical volume
You've said you need to extend your root logical volume, first, you need to create the new physical volume with pvcreate /dev/sda3
, pvdisplay
will list them.
Add to the volume group
Now, add your new physical volume, /dev/sda3
, to your volume group. To find what volume group your root
logical volume is using, run lvdisplay
and find your root:
$ lvdisplay
--- Logical volume ---
LV Path /dev/vg/root
LV Name root
VG Name vgdata
...
The VG Name
line is the name of the volume group in use, so that's what needs to be extended - above the volume group is called vgdata
.
Running vgextend vgdata /dev/sda3
will extend the vgdata
volume group using your /dev/sda3
physical volume.
Extend the logical volume
Now you need to extend your root logical volume. The LV Path
line in the above output gives you the path to your logical volume, in this case it is /dev/vg/root
. You just have to call lvextend
now:
$ lvextend -L +1G /dev/vg/root
This will extend by 1 GiB. To use all of the free space you added to your volume group, you need to call lvextend
with -l +100%FREE
which tells it to use all the extents left in the volume group.
$ lvextend -l +100%FREE /dev/vg/root
Resize the filesystem
Finally, you need to grow the filesystem. If using ext2/3/4
run:
$ resize2fs /dev/vg/root
If using xfs
run:
$ xfs_growfs /dev/vg/root