{"id":59,"date":"2022-03-30T10:54:00","date_gmt":"2022-03-30T08:54:00","guid":{"rendered":"https:\/\/blubb.fish\/?p=59"},"modified":"2022-03-25T10:54:50","modified_gmt":"2022-03-25T09:54:50","slug":"create-lvm-volume","status":"publish","type":"post","link":"https:\/\/blubb.fish\/index.php\/2022\/03\/30\/create-lvm-volume\/","title":{"rendered":"Create LVM Volume"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">How to create an LVM volume<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only needed if no Physical Volume exists or additional disks are added<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">create physical volume and view it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># adds the physical disk to lvm\n$ pvcreate \/deb\/sdx\n#view if the new physical disk is visible\n$ pvs\n  PV         VG     Fmt  Attr PSize  PFree \n  \/dev\/sdx          lvm2 a--  &lt;1.82t &lt;1.14t<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Only needed when no VG exists or additional one is needed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">a VG can contain multiple physical<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create volume group on physical volume:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># create volume group\n$ vgcreate testvg \/dev\/sdx\n#view vulume groups\n$ vgs\n  VG     #PV #LV #SN Attr   VSize  VFree \n  testvg   1   0   0 wz--n- &lt;1.82t &lt;1.14t<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Now we create the logical volume on the volume group there can be multiple logical volumes on an volume group<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># create new logical volume\n$ lvcreate -n testlv -L1G datavg                                                                                   \n  Logical volume \"testlv\" created\n# -n sets the name of the logical volume\n# -L sets the Size in G\n# last option is the volume group to place the lv on\n\n# check if correct\n$ lvs\n   LV     VG     Attr       LSize   Pool Origin                                               \n  testlv datavg -wi-a-----   1.00g                                                    <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The lv is now setup but not usable<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before we can use it, it needs to have an Filesystem<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">we will use mkfs for this. Filesystem can be chosen as you prefer<br>(mkfs.ext4, mkfs.xfs, mkfs.btrfs)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">create filesystem on lv:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mkfs.ext4 \/dev\/mapper\/datavg-testlv                                                                              \nmke2fs 1.46.5 (30-Dec-2021)\nDevice blocks are discarded: done                        \nA file system with 262144 (4k) blocks and 65536 inodes is created.\nUUID of the file system: 89f36f09-9155-466d-af6e-180524b832ce\nSuperblock backup copies stored in blocks: \n\t32768, 98304, 163840, 229376\n\nwhen requesting memory for the group tables: done                        \ninode tables are written: done                        \nThe journal (8192 blocks) is created: done\nThe superblocks and the file system usage information are\nwritten: done<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now it is ready to be used and receive Data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mount it once:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># mount to \/mnt\/test (folder has to exist)\n$ mount \/dev\/mapper\/datavg-testlv \/mnt\/test\n# check if mount is up\n$ mount | grep testlv                                                                                              \n\/dev\/mapper\/datavg-testlv on \/mnt\/test type ext4 (rw,relatime)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Mount permanently:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">permanent mount will be done via \/etc\/fstab. the entries in this file will be mounted every time the OS is booted or the command &#8220;mount -a&#8221; is issued<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">open file for edit:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ vim \/etc\/fstab<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following entry (don&#8217;t forget to change according to your setup ex.: path, filesystem other mount options)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># add the following line at the end of file\n\/dev\/mapper\/datavg-testlv \/mnt\/test ext4 defaults 0 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">mount and check<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ mount -av                                                                                                       \n\/mnt\/test                : successfully mounted\n$ mount | grep testlv                                                                                            \n\/dev\/mapper\/datavg-testlv on \/mnt\/test type ext4 (rw,relatime)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can place data and other stuff on the volume<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to create an LVM volume Only needed if no Physical Volume exists or additional disks are added create physical volume and view it: Only needed when no VG exists or additional one is needed. a VG can contain multiple physical Create volume group on physical volume: Now we create the logical volume on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":2,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":73,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/posts\/59\/revisions\/73"}],"wp:attachment":[{"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blubb.fish\/index.php\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}