I am learning linux system administration on ubuntu trusty and I had to create logical volumes from two partitions created off the disk in the ubuntu VM.
Now this is how it went:
sudo pvcreate /dev/sda3
sudo pvcreate /dev/sda4
sudo vgcreate myvg /dev/sda3 /dev/sda4
sudolvcreate -L 300M -n mylvm myvg
sudo mkdir mylvm
sudo mkfs.ext4 /dev/myvg/mylvm
sudo mount /dev/myvg/mylvm /mylvm
sudo lvextend -L 350M /dev/myvg/mylvm
Then added this to /etc/fstab
/dev/myvg/mylvm /mylvm ext4 defaults 0 0
Now if I run lsblk
I see this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 18G 0 part /
├─sda2 8:2 0 1K 0 part
├─sda3 8:3 0 3.9G 0 part
│ └─myvg-mylvm (dm-0) 252:0 0 352M 0 lvm /mylvm
├─sda4 8:4 0 4.8G 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sr0 11:0 1 1024M 0 rom
Now why is the /dev/sda3
the only physical volume with the assigned size, would have thought /dev/sda4
would also have a branch too. Perhaps I have not understood how LVM works. A good explanation would really clear me.
You have create two LVM physical volumes sda3 with 3.9 GB in size and sda4 with 4.8 GB in size.
After that you have created volume group myvg which spans across LVM physical volumes sda3 and sda4 to total of 7.7 GB size.
You continued with creating logical volume mylvm with 300 MB size. Currently mylvm is smaller than physical volume sda3, which means that logical volume mylvm resides only on pyhsical volume sda3.
Try to extend logical volume for a size larger than sda3 (for example 5 GB) and don't forget to resize ext4 file system after that with commands
Check output of command
lsblk
, logical volume myvg-mylvm should be spanned across sda3 and sda4 . There are other commands for LVM as well - for examplevgs
for volume group status andlvs
for logical volume status.