วิธีการปรับขนาดพื้นที่ของ LINUX
<div class="kb-article-content" style="box-sizing: border-box; margin-bottom: 30px; font-size: 1.2em; line-height: 1.2em; color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"><p style="box-sizing: border-box; margin-bottom: 10px;">สิ่งที่ท่านจะได้เรียนรู้ต่อไปนี่คือจะเป็นของ Centos 7 สำหรับ Linux ตัวอื่น ใช้เป็นแหล่งอ้างอิงได้ครับ<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"><span style="box-sizing: border-box; font-size: 24pt; font-family: "arial black", sans-serif; color: rgb(255, 0, 0); background-color: rgb(204, 255, 204);"><span style="box-sizing: border-box; font-weight: 700;">New Solution</span></span></p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;"> </h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;"><span style="box-sizing: border-box; text-decoration-line: underline; background-color: rgb(255, 255, 153); color: rgb(0, 0, 255);"><span style="box-sizing: border-box; font-size: 18pt;"><span style="box-sizing: border-box; font-weight: 700;">First Step</span></span></span></h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Extend partition<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">First you need find out what partition name with<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"># fdisk -l<br style="box-sizing: border-box;">after that system command line will output like something<br style="box-sizing: border-box;"> /dev/xvda</h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">First you need to find number of disk</h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">eg. /dev/xvda2 </h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">( or /dev/xvda3 )</h2><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;"><span style="box-sizing: border-box; font-weight: 700;">2 = your number of disk.</span></p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">then go next step</h2><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># parted --version</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;">if return value with "parted (GNU parted) 3" OR Upper</p><p style="box-sizing: border-box; margin-bottom: 10px;"># echo '-1' | parted ---pretend-input-tty /dev/xvda resizepart {Your number of disk}</p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">eg. </h2><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># echo 'Fix' | parted ---pretend-input-tty /dev/xvda resizepart 2# echo -1 | parted ---pretend-input-tty /dev/xvda resizepart 2</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">then go Second step</h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;"> </h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">If below 3 OR your version 2.X</h2><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># parted /dev/xvda resize {You number of disk} -1</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;"><span style="box-sizing: border-box; text-decoration-line: underline; background-color: rgb(255, 255, 153); color: rgb(0, 0, 255);"><span style="box-sizing: border-box; font-size: 18pt;"><span style="box-sizing: border-box; font-weight: 700;">Second Step</span></span></span></p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Update kernel in-memory partition table</h2><p style="box-sizing: border-box; margin-bottom: 10px;">After changing your partition table, run the following command to update the kernel in-memory partition table:</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># partx -u /dev/xvda<br style="box-sizing: border-box;">if have error something please use<br style="box-sizing: border-box;"># partprobe /dev/xvda</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Resize physical volume</h2><p style="box-sizing: border-box; margin-bottom: 10px;">Resize the PV to recognize the extra space</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># pvresize /dev/xvda2</code><br style="box-sizing: border-box;"><br style="box-sizing: border-box;"></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Find your Disk Logic Name</h2><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># lvdisplay -C -o "lv_path,lv_dm_path,lv_kernel_minor"</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;">It should display something like this</p><p style="box-sizing: border-box; margin-bottom: 10px;">some partition has "Swap Space"</p><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">Path DMPath KMin
/dev/cl_host115/root /dev/mapper/cl_host115-root 0</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;"><br style="box-sizing: border-box;">Select DMPath that not contain "Swap"<br style="box-sizing: border-box;">Then<br style="box-sizing: border-box;">DMPath = /dev/mapper/cl_host115-root<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"># lvextend -r {DMPath} /dev/xvda2<br style="box-sizing: border-box;">eg.</p><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># lvextend -r /dev/mapper/cl_host115-root /dev/xvda2</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;">Finish extended your partition.<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"></p><p style="box-sizing: border-box; margin-bottom: 10px;"><span style="box-sizing: border-box; font-size: 24pt; font-family: "arial black", sans-serif; color: rgb(255, 0, 0); background-color: rgb(204, 255, 204);"><span style="box-sizing: border-box; font-weight: 700;">Old Solution</span></span></p><div class="post-text" style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-bottom: 10px;">You can do this without rebooting in CentOS 7. Assuming your disk is /dev/xvda and standard RHEL/CentOS partitioning:</p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Extend partition<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">First you need find out what partition name with<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"># fdisk -l<br style="box-sizing: border-box;">after that system command line will output like something<br style="box-sizing: border-box;"> /dev/xvda<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">then go next step<br style="box-sizing: border-box;"> <br style="box-sizing: border-box;"><br style="box-sizing: border-box;"></h2><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">insert your partition name in first step like this<br style="box-sizing: border-box;"># fdisk /dev/xvda
</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">p</code> to print your initial partition table.</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">d</code> (delete) followed by <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">2</code> to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition).</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">n</code> (new) followed by <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">p</code> (primary) followed by <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">2</code> to re-create partition number 2 and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">enter</code> to accept the start block and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">enter</code> again to accept the end block which is defaulted to the end of the disk.</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">t</code> (type) then <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">2</code> then <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">8e</code> to change the new partition type to "Linux LVM".</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">p</code> to print your new partition table and make sure the start block matches what was in the initial partition table printed above.</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">w</code> to write the partition table to disk. You will see an error about <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">Device or resource busy</code> which you can ignore.</p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Update kernel in-memory partition table</h2><p style="box-sizing: border-box; margin-bottom: 10px;">After changing your partition table, run the following command to update the kernel in-memory partition table:</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># partx -u /dev/xvda<br style="box-sizing: border-box;">if have error something please use<br style="box-sizing: border-box;"># partprobe /dev/xvda</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Resize physical volume</h2><p style="box-sizing: border-box; margin-bottom: 10px;">Resize the PV to recognize the extra space</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># pvresize /dev/xvda2
</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Resize LV and filesystem</h2><p style="box-sizing: border-box; margin-bottom: 10px;">in this step before start please send command : pvs<br style="box-sizing: border-box;">you will see disk name like : centos_thankcloud<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">then use this name in next step.</p><p style="box-sizing: border-box; margin-bottom: 10px;"><br style="box-sizing: border-box;"><br style="box-sizing: border-box;">In this command <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">centos</code> is the PV, <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">root</code> is the LV and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/dev/xvda2</code> is the partition that was extended. Use <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">pvs</code> and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">lvs</code> commands to see your physical and logical volume names if you don't know them. The <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">-r</code> option in this command resizes the filesystem appropriately so you don't have to call <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">resize2fs</code> or <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">xfs_growfs</code> separately.</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># lvextend -r centos_thankcloud/root /dev/xvda2
</code></pre></div></div><div class="kb-article-content" style="box-sizing: border-box; margin-bottom: 30px; font-size: 1.2em; line-height: 1.2em; color: rgb(51, 51, 51); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;"><p style="box-sizing: border-box; margin-bottom: 10px;">สิ่งที่ท่านจะได้เรียนรู้ต่อไปนี่คือจะเป็นของ Centos 7 สำหรับ Linux ตัวอื่น ใช้เป็นแหล่งอ้างอิงได้ครับ<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"><span style="box-sizing: border-box; font-size: 24pt; font-family: "arial black", sans-serif; color: rgb(255, 0, 0); background-color: rgb(204, 255, 204);"><span style="box-sizing: border-box; font-weight: 700;">New Solution</span></span></p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;"> </h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;"><span style="box-sizing: border-box; text-decoration-line: underline; background-color: rgb(255, 255, 153); color: rgb(0, 0, 255);"><span style="box-sizing: border-box; font-size: 18pt;"><span style="box-sizing: border-box; font-weight: 700;">First Step</span></span></span></h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Extend partition<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">First you need find out what partition name with<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"># fdisk -l<br style="box-sizing: border-box;">after that system command line will output like something<br style="box-sizing: border-box;"> /dev/xvda</h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">First you need to find number of disk</h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">eg. /dev/xvda2 </h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">( or /dev/xvda3 )</h2><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;"><span style="box-sizing: border-box; font-weight: 700;">2 = your number of disk.</span></p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">then go next step</h2><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># parted --version</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;">if return value with "parted (GNU parted) 3" OR Upper</p><p style="box-sizing: border-box; margin-bottom: 10px;"># echo '-1' | parted ---pretend-input-tty /dev/xvda resizepart {Your number of disk}</p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">eg. </h2><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># echo 'Fix' | parted ---pretend-input-tty /dev/xvda resizepart 2
# echo -1 | parted ---pretend-input-tty /dev/xvda resizepart 2</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">then go Second step</h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;"> </h2><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">If below 3 OR your version 2.X</h2><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># parted /dev/xvda resize {You number of disk} -1</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;"><span style="box-sizing: border-box; text-decoration-line: underline; background-color: rgb(255, 255, 153); color: rgb(0, 0, 255);"><span style="box-sizing: border-box; font-size: 18pt;"><span style="box-sizing: border-box; font-weight: 700;">Second Step</span></span></span></p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Update kernel in-memory partition table</h2><p style="box-sizing: border-box; margin-bottom: 10px;">After changing your partition table, run the following command to update the kernel in-memory partition table:</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># partx -u /dev/xvda<br style="box-sizing: border-box;">if have error something please use<br style="box-sizing: border-box;"># partprobe /dev/xvda</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Resize physical volume</h2><p style="box-sizing: border-box; margin-bottom: 10px;">Resize the PV to recognize the extra space</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># pvresize /dev/xvda2</code><br style="box-sizing: border-box;"><br style="box-sizing: border-box;"></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Find your Disk Logic Name</h2><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># lvdisplay -C -o "lv_path,lv_dm_path,lv_kernel_minor"</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;"> </p><p style="box-sizing: border-box; margin-bottom: 10px;">It should display something like this</p><p style="box-sizing: border-box; margin-bottom: 10px;">some partition has "Swap Space"</p><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">Path DMPath KMin
/dev/cl_host115/root /dev/mapper/cl_host115-root 0</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;"><br style="box-sizing: border-box;">Select DMPath that not contain "Swap"<br style="box-sizing: border-box;">Then<br style="box-sizing: border-box;">DMPath = /dev/mapper/cl_host115-root<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"># lvextend -r {DMPath} /dev/xvda2<br style="box-sizing: border-box;">eg.</p><pre class="language-markup" style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># lvextend -r /dev/mapper/cl_host115-root /dev/xvda2</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;">Finish extended your partition.<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"></p><p style="box-sizing: border-box; margin-bottom: 10px;"><span style="box-sizing: border-box; font-size: 24pt; font-family: "arial black", sans-serif; color: rgb(255, 0, 0); background-color: rgb(204, 255, 204);"><span style="box-sizing: border-box; font-weight: 700;">Old Solution</span></span></p><div class="post-text" style="box-sizing: border-box;"><p style="box-sizing: border-box; margin-bottom: 10px;">You can do this without rebooting in CentOS 7. Assuming your disk is /dev/xvda and standard RHEL/CentOS partitioning:</p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Extend partition<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">First you need find out what partition name with<br style="box-sizing: border-box;"><br style="box-sizing: border-box;"># fdisk -l<br style="box-sizing: border-box;">after that system command line will output like something<br style="box-sizing: border-box;"> /dev/xvda<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">then go next step<br style="box-sizing: border-box;"> <br style="box-sizing: border-box;"><br style="box-sizing: border-box;"></h2><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;">insert your partition name in first step like this<br style="box-sizing: border-box;"># fdisk /dev/xvda
</code></pre><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">p</code> to print your initial partition table.</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">d</code> (delete) followed by <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">2</code> to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition).</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">n</code> (new) followed by <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">p</code> (primary) followed by <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">2</code> to re-create partition number 2 and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">enter</code> to accept the start block and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">enter</code> again to accept the end block which is defaulted to the end of the disk.</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">t</code> (type) then <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">2</code> then <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">8e</code> to change the new partition type to "Linux LVM".</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">p</code> to print your new partition table and make sure the start block matches what was in the initial partition table printed above.</p><p style="box-sizing: border-box; margin-bottom: 10px;">Enter <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">w</code> to write the partition table to disk. You will see an error about <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">Device or resource busy</code> which you can ignore.</p><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Update kernel in-memory partition table</h2><p style="box-sizing: border-box; margin-bottom: 10px;">After changing your partition table, run the following command to update the kernel in-memory partition table:</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># partx -u /dev/xvda<br style="box-sizing: border-box;">if have error something please use<br style="box-sizing: border-box;"># partprobe /dev/xvda</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Resize physical volume</h2><p style="box-sizing: border-box; margin-bottom: 10px;">Resize the PV to recognize the extra space</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># pvresize /dev/xvda2
</code></pre><h2 style="box-sizing: border-box; font-family: inherit; font-weight: 500; line-height: 1.1; color: inherit; margin-top: 20px; margin-bottom: 10px; font-size: 20px;">Resize LV and filesystem</h2><p style="box-sizing: border-box; margin-bottom: 10px;">in this step before start please send command : pvs<br style="box-sizing: border-box;">you will see disk name like : centos_thankcloud<br style="box-sizing: border-box;"><br style="box-sizing: border-box;">then use this name in next step.</p><p style="box-sizing: border-box; margin-bottom: 10px;"><br style="box-sizing: border-box;"><br style="box-sizing: border-box;">In this command <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">centos</code> is the PV, <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">root</code> is the LV and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">/dev/xvda2</code> is the partition that was extended. Use <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">pvs</code> and <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">lvs</code> commands to see your physical and logical volume names if you don't know them. The <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">-r</code> option in this command resizes the filesystem appropriately so you don't have to call <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">resize2fs</code> or <code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px; color: rgb(199, 37, 78); background-color: rgb(249, 242, 244); border-radius: 4px;">xfs_growfs</code> separately.</p><pre style="box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13px; padding: 9.5px; margin-bottom: 10px; line-height: 1.42857; word-break: break-all; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px;"><code style="box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; color: inherit; background-color: transparent; border-radius: 0px; white-space: pre-wrap;"># lvextend -r centos_thankcloud/root /dev/xvda2</code></pre></div></div>
หน้า:
[1]