{"id":4988,"date":"2020-11-09T16:50:43","date_gmt":"2020-11-09T19:50:43","guid":{"rendered":"https:\/\/blog.clusterweb.com.br\/?p=4988"},"modified":"2020-11-09T16:51:48","modified_gmt":"2020-11-09T19:51:48","slug":"extending-a-logical-volume","status":"publish","type":"post","link":"https:\/\/blog.clusterweb.com.br\/?p=4988","title":{"rendered":"Extending a logical volume"},"content":{"rendered":"<p>To extend a logical volume you simply tell the lvextend command how much you want to increase the size. You can specify how much to grow the volume, or how large you want it to grow to:<\/p>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\"><b class=\"command\"># lvextend -L12G \/dev\/myvg\/homevol<\/b>\r\n<tt class=\"computeroutput\">lvextend -- extending logical volume \"\/dev\/myvg\/homevol\" to 12 GB\r\nlvextend -- doing automatic backup of volume group \"myvg\"\r\nlvextend -- logical volume \"\/dev\/myvg\/homevol\" successfully extended<\/tt>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><!--more--><\/p>\n<p>will extend\u00a0<tt class=\"filename\">\/dev\/myvg\/homevol<\/tt>\u00a0to 12 Gigabytes.<\/p>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\"><b class=\"command\"># lvextend -L+1G \/dev\/myvg\/homevol<\/b>\r\n<tt class=\"computeroutput\">lvextend -- extending logical volume \"\/dev\/myvg\/homevol\" to 13 GB\r\nlvextend -- doing automatic backup of volume group \"myvg\"\r\nlvextend -- logical volume \"\/dev\/myvg\/homevol\" successfully extended<\/tt>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>will add another gigabyte to\u00a0<tt class=\"filename\">\/dev\/myvg\/homevol<\/tt>.<\/p>\n<p>After you have extended the logical volume it is necessary to increase the file system size to match. how you do this depends on the file system you are using.<\/p>\n<p>By default, most file system resizing tools will increase the size of the file system to be the size of the underlying logical volume so you don&#8217;t need to worry about specifying the same size for each of the two commands.<\/p>\n<p>&nbsp;<\/p>\n<ol type=\"1\">\n<li><strong>ext2\/ext3<\/strong>Unless you have patched your kernel with the ext2online patch it is necessary to unmount the file system before resizing it. (It seems that the online resizing patch is rather dangerous, so use at your own risk)<br \/>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># umount \/dev\/myvg\/homevol\/dev\/myvg\/homevol\r\n   # resize2fs \/dev\/myvg\/homevol\r\n   # mount \/dev\/myvg\/homevol \/home<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>If you don&#8217;t have e2fsprogs 1.19 or later, you can download the ext2resize command from\u00a0ext2resize.sourceforge.net\u00a0and use that:<\/p>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># umount \/dev\/myvg\/homevol\/dev\/myvg\/homevol\r\n   # ext2resize \/dev\/myvg\/homevol\r\n   # mount \/dev\/myvg\/homevol \/home<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>For ext2 there is an easier way. LVM 1 ships with a utility called e2fsadm which does the lvextend and resize2fs for you (it can also do file system shrinking, see the next section).<\/p>\n<div class=\"warning\">\n<p>&nbsp;<\/p>\n<table class=\"warning\" border=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td align=\"CENTER\" valign=\"TOP\" width=\"25\"><img decoding=\"async\" src=\"https:\/\/tldp.org\/HOWTO\/images\/warning.gif\" alt=\"Warning\" hspace=\"5\" \/><\/td>\n<th align=\"LEFT\" valign=\"CENTER\"><b>LVM 2 Caveat<\/b><\/th>\n<\/tr>\n<tr>\n<td><\/td>\n<td align=\"LEFT\" valign=\"TOP\">There is currently no e2fsadm equivalent for LVM 2 and the e2fsadm that ships with LVM 1 does not work with LVM 2.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>so the single command<\/p>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># e2fsadm -L+1G \/dev\/myvg\/homevol<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>is equivalent to the two commands:<\/p>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># lvextend -L+1G \/dev\/myvg\/homevol\r\n   # resize2fs \/dev\/myvg\/homevol<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"note\">\n<p>&nbsp;<\/p>\n<table class=\"note\" border=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td align=\"CENTER\" valign=\"TOP\" width=\"25\"><img decoding=\"async\" src=\"https:\/\/tldp.org\/HOWTO\/images\/note.gif\" alt=\"Note\" hspace=\"5\" \/><\/td>\n<th align=\"LEFT\" valign=\"CENTER\"><b>Note<\/b><\/th>\n<\/tr>\n<tr>\n<td><\/td>\n<td align=\"LEFT\" valign=\"TOP\">You will still need to unmount the file system before running e2fsadm.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;<\/li>\n<li><strong>reiserfs<\/strong>Reiserfs file systems can be resized when mounted or unmounted as you prefer:\n<p>&nbsp;<\/p>\n<ul>\n<li>Online:<br \/>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># resize_reiserfs -f \/dev\/myvg\/homevol<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>Offline:<br \/>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># umount \/dev\/myvg\/homevol\r\n   # resize_reiserfs \/dev\/myvg\/homevol\r\n   # mount -treiserfs \/dev\/myvg\/homevol \/home<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/li>\n<li><strong>xfs<\/strong>XFS file systems must be mounted to be resized and the mount-point is specified rather than the device name.<br \/>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\">   <b class=\"command\"># xfs_growfs \/home<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>jfs<\/strong>Just like XFS the JFS file system must be mounted to be resized and the mount-point is specified rather than the device name. You need at least Version 1.0.21 of the jfs-utils to do this.<br \/>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\"><b class=\"command\"># mount -o remount,resize \/home<\/b>\r\n<\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"warning\">\n<p>&nbsp;<\/p>\n<table class=\"warning\" border=\"0\" width=\"100%\">\n<tbody>\n<tr>\n<td align=\"CENTER\" valign=\"TOP\" width=\"25\"><img decoding=\"async\" src=\"https:\/\/tldp.org\/HOWTO\/images\/warning.gif\" alt=\"Warning\" hspace=\"5\" \/><\/td>\n<th align=\"LEFT\" valign=\"CENTER\"><b>Known Kernel Bug<\/b><\/th>\n<\/tr>\n<tr>\n<td><\/td>\n<td align=\"LEFT\" valign=\"TOP\">Some kernel versions have problems with this syntax (2.6.0 is known to have this problem). In this case you have to explicitly specify the new size of the filesystem in blocks. This is extremely error prone as you\u00a0<em>must<\/em>\u00a0know the blocksize of your filesystem and calculate the new size based on those units.<\/p>\n<p>Example: If you were to resize a JFS file system to 4 gigabytes that has 4k blocks, you would write:<\/p>\n<table border=\"0\" width=\"100%\" bgcolor=\"#E0E0E0\">\n<tbody>\n<tr>\n<td>\n<pre class=\"screen\"><b class=\"command\"># mount -o remount,resize=1048576 \/home<\/b><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>To extend a logical volume you simply tell the lvextend command how much you want to increase the size. You can specify how much to grow the volume, or how large you want it to grow to: # lvextend -L12G \/dev\/myvg\/homevol lvextend &#8212; extending logical volume &#8220;\/dev\/myvg\/homevol&#8221; to 12 GB lvextend &#8212; doing automatic backup [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1082,1,730,830,42,51,439,495,127],"tags":[773,1506,1507,723],"class_list":["post-4988","post","type-post","status-publish","format-standard","hentry","category-centos-7-rhel-7","category-viazap","category-clusterweb","category-debian","category-leitura-recomendada","category-linux-linuxrs","category-midia","category-profissional-de-ti","category-sistemas-de-armazenamento","tag-a","tag-extending","tag-logical","tag-volume"],"_links":{"self":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4988"}],"version-history":[{"count":2,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4988\/revisions"}],"predecessor-version":[{"id":4991,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4988\/revisions\/4991"}],"wp:attachment":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}