{"id":79086,"date":"2026-11-17T01:59:38","date_gmt":"2026-11-17T01:59:38","guid":{"rendered":"http:\/\/bangla.sitestree.com\/?p=79086"},"modified":"2026-11-17T01:59:38","modified_gmt":"2026-11-17T01:59:38","slug":"linux-advanced-01-lvm","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=79086","title":{"rendered":"Linux Advanced 01 \u2014 LVM and Controlled Filesystem Growth"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1992\">Linux Advanced category<\/a> \u00b7 Lesson 1 of 9<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>AI disclosure<\/strong> \u2014 AI-generated content, posted as is. AI can make mistakes. This lesson draws on the linked Open Education posts and adds original explanations or lab examples where useful. The newly written explanations and examples may be freely reused. Linked source material retains its own terms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Learning goal<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create and expand an isolated LVM stack without touching the system disk.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts and setup<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A physical volume (PV) contributes space to a volume group (VG). An LV uses space from that group. The filesystem inside the LV is a separate layer. The site&#8217;s pvs, vgs, and lvs sequence helps you find where the free space is.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Work in a disposable VM with lvm2 and ext4 tools. Keep the same Bash session open. Stop after any error. This exercise initializes a unique file-backed loop device. Do not substitute \/dev\/sda, \/dev\/vda, or another existing disk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a fresh PV, VG, LV, and ext4 filesystem<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>lab=$(mktemp -d)\nvg=&quot;oe_lab_$(id -u)_$$&quot;\ntruncate -s 384M &quot;$lab\/disk.img&quot;\nloopdev=$(sudo losetup --find --show &quot;$lab\/disk.img&quot;)\n[[ $loopdev =~ ^\/dev\/loop[0-9]+$ ]] || exit 1\nsudo losetup &quot;$loopdev&quot;\n# Continue only if the output identifies your new disk.img.\nsudo pvcreate &quot;$loopdev&quot;\nsudo vgcreate &quot;$vg&quot; &quot;$loopdev&quot;\nsudo lvcreate -L 96M -n data &quot;$vg&quot;\nlv=&quot;\/dev\/$vg\/data&quot;\nsudo mkfs.ext4 -q &quot;$lv&quot;\nmkdir &quot;$lab\/mnt&quot;\nsudo mount &quot;$lv&quot; &quot;$lab\/mnt&quot;\nprintf 'before resize\\n' | sudo tee &quot;$lab\/mnt\/proof.txt&quot;\nsudo lvs &quot;$lv&quot; -o vg_name,lv_name,lv_size<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/dev\/loop8: ... (\/tmp\/tmp.ABC\/disk.img)\n...\nbefore resize\nVG                LV   LSize\noe_lab_1000_3250   data 96.00m<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the lab VM&#8217;s LVM policy does not allow the loop device, stop. Do not relax host-wide device scanning or substitute a real disk.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Grow both layers and verify the data<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo lvextend -L +64M &quot;$lv&quot;\nsudo resize2fs &quot;$lv&quot;\ndf -h &quot;$lab\/mnt&quot;\ncat &quot;$lab\/mnt\/proof.txt&quot;\nsudo lvs &quot;$lv&quot; -o lv_name,lv_size\n# Cleanup only after recording the results:\nsudo umount &quot;$lab\/mnt&quot; &amp;&amp;\n  sudo lvremove -y &quot;$lv&quot; &amp;&amp;\n  sudo vgremove -y &quot;$vg&quot; &amp;&amp;\n  sudo pvremove -y &quot;$loopdev&quot; &amp;&amp;\n  sudo losetup -d &quot;$loopdev&quot;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Possible output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Filesystem                        Size Used Avail Use% Mounted on\n\/dev\/mapper\/oe_lab_1000_3250-data  150M ...  ...    ...  \/tmp\/tmp.ABC\/mnt\nbefore resize\nLV   LSize\ndata 160.00m<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The displayed sizes are examples. XFS requires a different grow tool and does not support ordinary shrinking. If cleanup fails, leave the backing file in place until you resolve the error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Questions only<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Why can df stay unchanged immediately after lvextend?<\/li>\n\n\n<li>What does vgs show that lvs does not?<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment questions<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Identify the exact device the lab initialized and how you verified it.<\/li>\n\n\n<li>Explain why lvs and df can show different sizes after growth.<\/li>\n\n\n<li>What checks would you use to validate a real application storage expansion?<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Questions and answers<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Quick-check answers<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Why can df stay unchanged immediately after lvextend?<\/strong><br><strong>Answer<\/strong> \u2014 The LV has grown but the filesystem may still have its old size.<\/li>\n\n\n<li><strong>What does vgs show that lvs does not?<\/strong><br><strong>Answer<\/strong> \u2014 It shows group-wide capacity, including the unallocated space.<\/li>\n\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Assessment answer key<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li><strong>Identify the exact device the lab initialized and how you verified it.<\/strong><br><strong>Answer<\/strong> \u2014 Only the new \/dev\/loopN associated with this lab&#8217;s disk.img. Inspect it with losetup before pvcreate.<\/li>\n\n\n<li><strong>Explain why lvs and df can show different sizes after growth.<\/strong><br><strong>Answer<\/strong> \u2014 lvs reports block capacity, while df reports filesystem space with its own overhead and accounting.<\/li>\n\n\n<li><strong>What checks would you use to validate a real application storage expansion?<\/strong><br><strong>Answer<\/strong> \u2014 Check the device, mount, capacity, and filesystem state, then read and write known application data in an approved test.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Source articles on this site<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=14016\">Linux: LVM : Logical Volume Manager : Multiple Hard Disk and Partition and Volume Management<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=67592\">Disk\/Partition\/Logical Volume (LVM) Management related commands in Centos\/Redhat Linux #DevOps #RHCSA<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=14038\">On File Systems and Linux Commands (Redhat\/CentOs\/Fedora)<\/a><\/li>\n\n\n<li><a href=\"https:\/\/bangla.sitestree.com\/?p=78691\">Q &amp; A:  Linux: Switch Users, Boot Process, File System<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Continue the course<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next lesson 02 \u2014 NFS and On-Demand Mounting with AutoFS.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/bangla.sitestree.com\/?name=linux-course-index\">Linux course index<\/a> \u00b7 <a href=\"https:\/\/bangla.sitestree.com\/?cat=1992\">Linux Advanced category<\/a> \u00b7 Lesson 1 of 9<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create and expand an isolated LVM stack without touching the system disk.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1992],"tags":[],"class_list":["post-79086","post","type-post","status-publish","format-standard","hentry","category-linux-advanced","item-wrap"],"jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":79085,"url":"http:\/\/bangla.sitestree.com\/?p=79085","url_meta":{"origin":79086,"position":0},"title":"Linux Intermediate 09 \u2014 Block Devices, Filesystems, and Mounts","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Distinguish a block device from a filesystem and a mount point, and inspect each layer without changing it.","rel":"","context":"In &quot;Linux Intermediate&quot;","block_context":{"text":"Linux Intermediate","link":"http:\/\/bangla.sitestree.com\/?cat=1991"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79102,"url":"http:\/\/bangla.sitestree.com\/?p=79102","url_meta":{"origin":79086,"position":1},"title":"Linux Administration Course \u2014 Start Here and Lesson Index","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"A 33-lesson Linux course from shell fundamentals to server administration, performance, and a recovery capstone.","rel":"","context":"In &quot;Linux Basics&quot;","block_context":{"text":"Linux Basics","link":"http:\/\/bangla.sitestree.com\/?cat=1990"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79087,"url":"http:\/\/bangla.sitestree.com\/?p=79087","url_meta":{"origin":79086,"position":2},"title":"Linux Advanced 02 \u2014 NFS and On-Demand Mounting with AutoFS","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Create an indirect AutoFS map and distinguish a running automounter from a successful NFS mount.","rel":"","context":"In &quot;Linux Advanced&quot;","block_context":{"text":"Linux Advanced","link":"http:\/\/bangla.sitestree.com\/?cat=1992"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":14016,"url":"http:\/\/bangla.sitestree.com\/?p=14016","url_meta":{"origin":79086,"position":3},"title":"Linux: LVM : Logical Volume Manager : Multiple Hard Disk and Partition and Volume Management","author":"Sayed","date":"December 12, 2017","format":false,"excerpt":"On RedHat\/Centos Linux - LVM experiments Concepts to understand: Physical Volume: Physical Hard Drive or\u00a0 Partitions in Physical Hard Drive Physical Extent:\u00a0 One unit of space usually 4 MB. Volume Group: One or multiple Physical Volumes can be assigned to a Volume Group Logical Volume: Logical volumes are created from\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":79098,"url":"http:\/\/bangla.sitestree.com\/?p=79098","url_meta":{"origin":79086,"position":4},"title":"Linux Advanced 2 04 \u2014 Performance Triage with vmstat and PSI","author":"Sayed","date":"November 17, 2026","format":false,"excerpt":"Use related signals to decide whether to investigate CPU, memory, disk I\/O, or an application bottleneck.","rel":"","context":"In &quot;Linux Advanced 2&quot;","block_context":{"text":"Linux Advanced 2","link":"http:\/\/bangla.sitestree.com\/?cat=1993"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67592,"url":"http:\/\/bangla.sitestree.com\/?p=67592","url_meta":{"origin":79086,"position":5},"title":"Disk\/Partition\/Logical Volume (LVM) Management related commands in Centos\/Redhat Linux #DevOps #RHCSA","author":"Author-Check- Article-or-Video","date":"July 25, 2021","format":false,"excerpt":"echo \"Dec 22nd 2017\" 321 pvs 322 output 323 PV VG Fmt Attr PSize PFree 324 \/dev\/sda2 cl lvm2 a-- 19.00g 0 325 pvs 326 vgs 327 lsblk 328 vgdisplay 329 vgdisplay | grep \"PE Size\" 330 PE Size 4.00 MiB 331 vgdisplay > vgdisplay20171222.txt 332 vgdisplay | grep 'PE\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=79086"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/79086\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=79086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=79086"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=79086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}