visit
Please note that system administration understanding is extremely important. If you are not an experienced System Engineer, please do not try this.
Physical Volumes
These are regular storage devices. They provide space to store the logical volumes. They are used by the LVM as raw building material as a higher level of abstraction.Logical Volumes
It corresponds to partitions holding a file system. They can span across multiple disks, and do not have to be physically contiguous. They are the primary components that users and applications interact with.Volume Groups
It is a named collection of physical and logical volumes. They abstract the characteristics of the underlying devices and functions as a unified logical device with combined storage capacity.So, now we understand the basics. Lets implement this.
Create LVM Physical Volume
➜ ~ sudo lvmdiskscan
/dev/loop0 [ 88.48 MiB]
/dev/sda [ 596.17 GiB]
/dev/loop1 [ <97.42 MiB]
/dev/sdb2 [ <111.79 GiB]
/dev/sdc [ 931.51 GiB]
2 disks
3 partitions
0 LVM physical volume whole disks
0 LVM physical volumes
➜ ~ sudo pvcreate /dev/sda /dev/sdc
Wiping dos signature on /dev/sda.
Wiping dos signature on /dev/sdc.
Physical volume "/dev/sda" successfully created.
Physical volume "/dev/sdc" successfully created.
➜ ~ sudo pvs # To list the LVM physical Volumes
PV VG Fmt Attr PSize PFree
/dev/sda lvm2 --- 596.17g 596.17g
/dev/sdc lvm2 --- 931.51g 931.51g
Create a LVM Volume Group
Once the physical volumes are created, they can grouped using vgcreateas shown below:➜ ~ sudo vgcreate VgHulkStorage /dev/sda /dev/sdc
Volume group "VgHulkStorage" successfully created
➜ ~ sudo vgs # To list the Volume Groups created
VG #PV #LV #SN Attr VSize VFree
VgHulkStorage 2 0 0 wz--n- 1.49t 1.49t
Create a LVM Logical Volume Partition
Finally the logical volume can be created as below:➜ ~ sudo lvcreate -L 1.49t -n LvHulkStorage VgHulkStorage<br> Rounding up size to full physical extent 1.49 TiB<br> Logical volume "LvHulkStorage" created.
Its time create a file system and mount it.
We are now ready to create a file system in the logical volume and mount it for use.➜ ~ sudo mkfs.ext4 /dev/VgHulkStorage/LvHulkStorage
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 399969280 4k blocks and 99999744 inodes
Filesystem UUID: 13022223-d447-4a7c-9fb6-cd870f53f207
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
➜ ~ sudo mount /dev/VgHulkStorage/LvHulkStorage /mnt/hulkstorage
Extending an existing volume with a new external hard disk space
In future, if more disks are to be added, then the logical volume can be extended in similar way. A quick set of commands are here:➜ ~ sudo pvcreate /dev/sdd
Wiping dos signature on /dev/sdd.
Physical volume "/dev/sdd" successfully created.
➜ ~ sudo vgextend VgHulkStorage /dev/sdd
Volume group "VgHulkStorage" successfully extended
➜ ~ sudo lvextend -L +467.61g /dev/VgHulkStorage/LvHulkStorage
Rounding size to boundary between physical extents: 467.61 GiB.
Size of logical volume VgHulkStorage/LvHulkStorage changed from 1.49 TiB (390595 extents) to <1.95 TiB (510304 extents).
Logical volume VgHulkStorage/LvHulkStorage successfully resized.
➜ ~ sudo resize2fs /dev/VgHulkStorage/LvHulkStorage
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/VgHulkStorage/LvHulkStorage is mounted on /mnt/hulkstorage; on-line resizing required
old_desc_blocks = 191, new_desc_blocks = 250
The filesystem on /dev/VgHulkStorage/LvHulkStorage is now 522551296 (4k) blocks long.
➜ ~ sudo vgs
VG #PV #LV #SN Attr VSize VFree
VgHulkStorage 3 1 0 wz--n- <1.95t 4.00m
So, how does it really look like?
➜ ~ df -h --output=target,size
Mounted on Size
/dev 2.9G
/run 595M
/ 110G
/dev/shm 3.0G
/run/lock 5.0M
/sys/fs/cgroup 3.0G
/mnt/hulkstorage 2.0T
/run/user/1000 595M
Storage Engine
Hosting this local storage for home is pretty simple, actually. I started inside with docker. Running it is fairly simple.➜ ~ docker run -d --restart always --name storage_engine -p 8989:8989 -e UID=1000 -e GID=1000 -v /mnt/hulkstorage/StorageEngine:/files silverwind/droppy