{"id":302,"date":"2018-09-08T23:03:26","date_gmt":"2018-09-08T21:03:26","guid":{"rendered":"http:\/\/hentati.org\/?p=302"},"modified":"2020-12-06T20:55:45","modified_gmt":"2020-12-06T19:55:45","slug":"logical-volume-manager-lvm","status":"publish","type":"post","link":"https:\/\/hentati.org\/index.php\/2018\/09\/08\/logical-volume-manager-lvm\/","title":{"rendered":"Logical volume manager (LVM)"},"content":{"rendered":"<p><span style=\"color: #000000;\">What is LVM ?<\/span><\/p>\n<p><span style=\"color: #000000;\">Logical volume manager (<strong>LVM<\/strong>) introduces an extra layer between the physical disks and the file system allowing file systems to be resized and moved easily and online without requiring a system-wide outage.<\/span><\/p>\n<p><span style=\"color: #000000;\">LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes<\/span><\/p>\n<p><span style=\"color: #000000;\"><img loading=\"lazy\" class=\"wp-image-307 aligncenter\" src=\"http:\/\/hentati.org\/wp-content\/uploads\/2019\/10\/lvm-300x178.png\" alt=\"\" width=\"428\" height=\"254\" srcset=\"https:\/\/hentati.org\/wp-content\/uploads\/2019\/10\/lvm-300x178.png 300w, https:\/\/hentati.org\/wp-content\/uploads\/2019\/10\/lvm.png 582w\" sizes=\"(max-width: 428px) 100vw, 428px\" \/><\/span><\/p>\n<p>&nbsp;<\/p>\n<h6><span style=\"color: #000000;\">Here there is two examples to practice LVM :<\/span><\/h6>\n<h4><span style=\"color: #000000;\">Example 1 :<\/span><\/h4>\n<p><span style=\"color: #000000;\">Create the &#8220;LVM&#8221; with the name &#8220;source&#8221; by using 26PE&#8217;s from the volume group &#8220;open&#8221;. Consider the PE size as &#8220;8MB&#8221;. Mount it on \/mnt\/secret with filesystem vfat.<\/span><\/p>\n<h5><span style=\"color: #000000;\"><strong>create a partition <\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># fdisk \/dev\/sda (n, p, 3, +300M, t, 8e , w)<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>Force reading partition table by the kernel<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># partprobe \/dev\/sda<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>create a physical volume<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># pvcreate \/dev\/sda3<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>create a volume group with a size of PE = 8M<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># vgcreate \u2013s 8M open \/dev\/sda3<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>creatie a logical volume from the volume group 26PE&#8217;s<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># lvcreate \u2013n source \u2013l 26 open\u00a0<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>assign the vfat file system type to the logical volume<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># mkfs.vfat \/dev\/open\/source\u00a0<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>create the mount point<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># mkdir \/mnt\/secret\u00a0<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\"><strong>mounting the logical volume persistently<\/strong><\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># vim \/etc\/fstab\u00a0<\/strong><\/span><\/pre>\n<p><span style=\"color: #000000;\"><strong>\/dev\/mapper\/open-source \/mnt\/secret vfat defaults 1 2<\/strong><\/span><\/p>\n<pre><span style=\"color: #000000;\"><strong># mount -a<\/strong><\/span><\/pre>\n<p>&nbsp;<\/p>\n<h4><span style=\"color: #000000;\">Example 2 :<\/span><\/h4>\n<p><span style=\"color: #000000;\">Resize the lvm &#8220;\/dev\/vgsrv\/home&#8221; (\/dev\/myvol\/vo) so that after reboot size should be in between 90MB to 120MB..<\/span><\/p>\n<h5><span style=\"color: #000000;\">Show details about the logical volume<\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># lvdisplay \/dev\/vgsrv\/home\u00a0<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\">Show details about the volume group<\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># vgdisplay vgsrv\u00a0<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\">Extend the logical group<\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># lvextend \u2013L +volume_to_add \/dev\/vgsrv\/home<\/strong><\/span><\/pre>\n<h5><span style=\"color: #000000;\">Extend the file system<\/span><\/h5>\n<pre><span style=\"color: #000000;\"><strong># mount | grep \/dev\/mapper\/vgsrv-home (To show\u00a0file system type)<\/strong><\/span>\r\n\r\n<span style=\"color: #000000;\"><strong># xfs_growfs file_system_name\u00a0<\/strong><strong>(if type of the file system is xfs)<\/strong><\/span>\r\n\r\n<span style=\"color: #000000;\"><strong># resize2fs logical_volume_name\u00a0<\/strong><strong>(if type of the file system is ext4)<\/strong><\/span><\/pre>\n<p><span style=\"color: #000000;\"><strong>\u00a0<\/strong><\/span><\/p>\n<h4><span style=\"color: #000000;\">Note: If we want to reduce the size of 100Mb<\/span><\/h4>\n<pre><span style=\"color: #000000;\"><strong># umount \/dev\/vgsrv\/home <\/strong><\/span>\r\n\r\n<span style=\"color: #000000;\"><strong># Lvreduce \u2013L 100M \/dev\/vgsrv\/home -r<\/strong><\/span>\r\n\r\n<strong><span style=\"color: #000000;\"># mount \/dev\/vgsrv\/home<\/span> <\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is LVM ? Logical volume manager (LVM) introduces an extra layer between the physical disks and the file system allowing file systems to be resized and moved easily and &#8230;<\/p>\n","protected":false},"author":1,"featured_media":307,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/posts\/302"}],"collection":[{"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":12,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":652,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/posts\/302\/revisions\/652"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/media\/307"}],"wp:attachment":[{"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hentati.org\/index.php\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}