Process Expanded EBS Disk Capacity in Linux
<p class="shortdesc">This chapter mainly describes how to expand partition capacity after an EBS disk of Linux OS has been expanded. </p>
<section class="section context"><div class="tasklabel"><h2 class="doc-tairway">About this task</h2></div>
<p class="p">The Linux OS is CentOS7.2_64 bit, and a data disk has been mounted to it. </p>
<p class="p">Before expansion, the data disk has only one primary partition (/dev/vdb1), and the file system is ext3. The mount point is /mnt, and the size is 20 G. After expansion, the size of the data disk is 30 G, but it still has only one primary partition. </p>
</section>
<section><div class="tasklabel"><h2 class="doc-tairway">Procedure</h2></div><ol class="ol steps"><li class="li step stepexpand">
<span class="ph cmd">Connect to the ECS instance remotely.</span>
</li><li class="li step stepexpand">
<span class="ph cmd">View the current mounting information of the disk. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>df -TH</code></pre>
<img class="image" id="expansionlinux__image_dpk_nwl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-180cae44993a.png" width="800">
<p class="p">In the
output,
we can see that the current capacity of /dev/vdb1 is 20 G,
the
type of the file system is ext3, and the mount path is /mnt. </p>
</div>
</li><li class="li step stepexpand">
<span class="ph cmd">Unmount the disk partition. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>umount /dev /vdb1</code></pre>
</div>
</li><li class="li step stepexpand">
<span class="ph cmd">Create a new partition. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>fdisk /dev/vdb</code></pre>
<img class="image" id="expansionlinux__image_pd2_pwl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-18bbafd698b5.png" width="800">
<ol class="ol" type="a" id="expansionlinux__ol_q5m_jkr_rlb">
<li class="li">Enter <code class="ph codeph"><strong class="ph b">d</strong></code> to delete the original partition /dev/vdb1. <img class="image" id="expansionlinux__image_k4m_qwl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-1d0f9a96936d.png"><div class="note important note_important"><span class="note__title">Important:</span> Deleting the partition may result in data loss on this disk. If the disk has multiple partitions, we recommend that you not delete it. </div></li>
<li class="li">Type in <code class="ph codeph"><strong class="ph b">n</strong></code> and press Enter to create a new partition.<img class="image" id="expansionlinux__image_x2l_swl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-194e15529578.png"><p class="p" id="expansionlinux__p_wd3_slr_rlb">In the information displayed, <code class="ph codeph"><strong class="ph b">p</strong></code> represents a primary partition, and <code class="ph codeph"><strong class="ph b">e</strong></code> represents an extended partition. In this example, a primary partition will be created.</p></li><li class="li">
<p class="p" id="expansionlinux__d9e119">Type in <code class="ph codeph"><strong class="ph b">p</strong></code> and press Enter to create a primary partition. </p>
<img class="image" id="expansionlinux__d9e126" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171845-1f0cc00c925b.png">
<p class="p" id="expansionlinux__d9e128">In the information displayed, <code class="ph codeph"><strong class="ph b">Partition number</strong></code> represents the serial number of the primary partition. The value range is from 1 to 4. The default value is 1. </p>
</li><li class="li"><p class="p">Type in the number and press Enter. Or press Enter directly and the system will use the default value 1. </p><img class="image" id="expansionlinux__image_r5l_5wl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-1cc902fd97bb.png"><p class="p">In the information displayed, <code class="ph codeph"><strong class="ph b">First sector</strong></code> represents the serial number of the first sector. The value range is from 2048 to 20971519, and the default value is 2048.</p></li>
<li class="li"><p class="p">Type in the number and press Enter. Or press Enter directly and the system will use the default value 2048.</p><img class="image" id="expansionlinux__image_l2m_bxl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-1b414b949e71.png">
<p class="p">In the information displayed, <code class="ph codeph"><strong class="ph b">Last sector</strong></code> represents the serial number of the last sector. The value range is from 2048 to 62914559, and the default value is 62914559.</p>
</li>
<li class="li">Type in the number and press Enter. Or press Enter directly and the system will use the default value 62914559.<img class="image" id="expansionlinux__image_qq5_cxl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-17a7d0af9fa4.png"><p class="p">A primary partition has been created for a data disk of 30 GB.</p></li>
<li class="li">Type in <code class="ph codeph"><strong class="ph b">w</strong></code> and press Enter to write the result to the partition table.<img class="image" id="expansionlinux__image_w3f_fvj_rlb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171845-149b91469556.png"><p class="p">The above information indicates that the partition is successfully created.</p><div class="note note note_note"><span class="note__title">Note:</span> In case that you make a mistake in the process, you can exit by entering <code class="ph codeph"><strong class="ph b">q</strong></code>, and the partition created before will be discarded.</div></li>
<li class="li"><p class="p">Run the command <code class="ph codeph"><strong class="ph b">fdisk -l</strong></code> to view the new partition. </p></li>
</ol>
</div>
</li><li class="li step stepexpand">
<span class="ph cmd">Check the file system. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>e2fsck -f /dev/vdb1</code></pre>
<img class="image" id="expansionlinux__image_nkt_gxl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-1ba393b799dc.png">
</div>
</li><li class="li step stepexpand">
<span class="ph cmd">Refresh the size of the file system. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>resize2fs /dev/vdb1</code></pre>
<img class="image" id="expansionlinux__image_k53_lxl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-11e3c1da9945.png">
</div>
</li><li class="li step stepexpand">
<span class="ph cmd">Mount the new partition to the directory /mnt. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>mount /dev/vdb1 /mnt</code></pre>
</div>
</li><li class="li step stepexpand">
<span class="ph cmd">View the mounting result. </span>
<div class="itemgroup info">
<pre class="pre codeblock"><code>df -TH</code></pre>
<img class="image" id="expansionlinux__image_wdn_qxl_slb" src="https://obs-cn-shanghai.yun.pingan.com/pcp-portal/20200707171847-116332b29c10.png">
<p class="p">In the information displayed, we can see that the size of the partition mounted currently is 30 G, and the mount directory is /mnt. </p>
</div>
</li></ol></section>
Did the above content solve your problem?
Yes
No
Submitted successfully! Thank you for your feedback, we will try our best to do better and better!