doc-exports/docs/evs/umn/evs_01_0072.html
zhangyue d05287d5d6 EVS UMN DOC
Reviewed-by: Miskanin, Jan <jan.miskanin@t-systems.com>
Co-authored-by: zhangyue <zhangyue164@huawei.com>
Co-committed-by: zhangyue <zhangyue164@huawei.com>
2024-05-09 07:19:17 +00:00

328 lines
42 KiB
HTML

<a name="evs_01_0072"></a><a name="evs_01_0072"></a>
<h1 class="topictitle1">Extending Partitions and File Systems for System Disks (Linux)</h1>
<div id="body1550664062625"><div class="section" id="evs_01_0072__section4385650719406"><h4 class="sectiontitle">Scenarios</h4><p id="evs_01_0072__p2029473616495">After a disk is expanded on the management console, the disk size is enlarged, but the additional space cannot be used directly.</p>
<p id="evs_01_0072__p1423705031512">In Linux, you must allocate the additional space to an existing partition or a new partition.</p>
<p id="evs_01_0072__p1729113471496">If the disk capacity is expanded when its <span id="evs_01_0072__text75013262066">server</span> is stopped, the additional space of a Linux system disk will be automatically added to the partition at the disk end upon the server startup. In this case, the additional space can be used directly.</p>
<p id="evs_01_0072__p1249241911546">This section uses CentOS 7.4 64bit and CentOS 6.5 64bit as the sample OSs to describe how to extend the disk partition using growpart and fdisk. The method for allocating the additional space varies with the server OS. This section is used for reference only. For detailed operations and differences, see the corresponding OS documents.</p>
<p id="evs_01_0072__p24596192205637">For how to query the Linux kernel version, see <a href="#evs_01_0072__section13591111918215">Querying the Linux Kernel Version</a>.</p>
<ul id="evs_01_0072__ul119641430210"><li id="evs_01_0072__li896411392112"><a href="#evs_01_0072__section143412109355">Extending an Existing MBR Partition (Kernel Version Later Than 3.6.0)</a></li><li id="evs_01_0072__li16846191613414"><a href="#evs_01_0072__section158762021831">Extending an Existing MBR Partition (Kernel Version Earlier Than 3.6.0)</a></li><li id="evs_01_0072__li178101443740"><a href="#evs_01_0072__section9194153012119">Creating a New MBR Partition</a></li></ul>
<div class="notice" id="evs_01_0072__note206209142082"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="evs_01_0072__en-us_topic_0017616396_p1185312105267">Performing the expansion operations with caution. Incorrect operations may lead to data loss or exceptions. So you are advised to back up the disk data using CBR or snapshots before expansion. For details about using CBR, see <a href="evs_01_0110.html">Managing EVS Backups</a>. For details about using snapshots, see <a href="en-us_topic_0066615262.html">Creating a Snapshot</a>.</p>
</div></div>
<p id="evs_01_0072__p318525615597"></p>
</div>
<div class="section" id="evs_01_0072__section51503350171737"><h4 class="sectiontitle">Prerequisites</h4><ul id="evs_01_0072__ul28913191171813"><li id="evs_01_0072__li1233185612427">You have expanded the disk capacity and attached the disk to a <span id="evs_01_0072__text1615511293514">server</span> on the management console. For details, see <a href="evs_01_0007.html">Expanding Capacity for an In-use EVS Disk</a> or <a href="evs_01_0008.html">Expanding Capacity for an Available EVS Disk</a>.</li><li id="evs_01_0072__en-us_topic_0000001855168897_en-us_topic_0044524740_li36962755115557">You have logged in to the <span id="evs_01_0072__text1689703784510">server</span>.<ul id="evs_01_0072__en-us_topic_0000001855168897_en-us_topic_0044524740_ul6229092211568"><li id="evs_01_0072__en-us_topic_0000001855168897_en-us_topic_0044524740_li197989548398">For how to log in to an ECS, see the <em id="evs_01_0072__i418924714426">Elastic Cloud Server User Guide</em>.</li><li id="evs_01_0072__en-us_topic_0000001855168897_en-us_topic_0044524740_li7220898115452">For how to log in to a BMS, see the <em id="evs_01_0072__i62114310438">Bare Metal Server User Guide</em>.</li></ul>
</li></ul>
</div>
<div class="section" id="evs_01_0072__section16358338113719"><h4 class="sectiontitle">Constraints</h4><p id="evs_01_0072__p892014612373">The additional space can only be added to the last partition of the disk.</p>
</div>
<div class="section" id="evs_01_0072__section13591111918215"><a name="evs_01_0072__section13591111918215"></a><a name="section13591111918215"></a><h4 class="sectiontitle">Querying the Linux Kernel Version</h4><p id="evs_01_0072__p199765904520">Run the following command to query the Linux kernel version:</p>
<p id="evs_01_0072__p96781856184510"><strong id="evs_01_0072__b867845604517">uname -a</strong></p>
<div class="p" id="evs_01_0072__p168116562455">Then, perform corresponding operations depending on whether the Linux kernel version is later than 3.6.0.<ul id="evs_01_0072__ul6681195614513"><li id="evs_01_0072__li12680135610458">For CentOS 7.4 64bit, information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen36806564458">Linux ecs-test-0001 3.10.0-957.5.1.el7.x86_64 #1 SMP Fri Feb 1 14:54:57 UTC 2019 x86_64 x86_64 </pre>
<p id="evs_01_0072__p26801256144512">The kernel version is 3.10.0, which is later than 3.6.0. For subsequent operations, see <a href="#evs_01_0072__section143412109355">Extending an Existing MBR Partition (Kernel Version Later Than 3.6.0)</a>.</p>
</li><li id="evs_01_0072__li2681156124518">For CentOS 6.5 64bit, information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen14680256194512">Linux ecs-test-0002 2.6.32-754.10.1.el6.x86_64 #1 SMP Tue Jan 15 17:07:28 UTC 2019 x86_64</pre>
<p id="evs_01_0072__p668185615458">The kernel version is 2.6.32, which is earlier than 3.6.0. In this case, the disk partition and file system extension take effect only after a server reboot. For subsequent operations, see <a href="#evs_01_0072__section158762021831">Extending an Existing MBR Partition (Kernel Version Earlier Than 3.6.0)</a>.</p>
</li></ul>
</div>
</div>
<div class="section" id="evs_01_0072__section143412109355"><a name="evs_01_0072__section143412109355"></a><a name="section143412109355"></a><h4 class="sectiontitle">Extending an Existing MBR Partition (Kernel Version Later Than 3.6.0)</h4><p id="evs_01_0072__p156861738135916">CentOS 7.4 64bit is used as the sample OS. Originally, system disk <strong id="evs_01_0072__b17255758152017">/dev/vda</strong> has 40 GiB and one partition (<strong id="evs_01_0072__b6256758102014">/dev/vda1</strong>), and then 60 GiB is added to the disk. The following procedure shows you how to allocate the additional 60 GiB to the existing MBR partition <strong id="evs_01_0072__b06065215216">/dev/vda1</strong>.</p>
<ol id="evs_01_0072__ol12801161194210"><li id="evs_01_0072__li19362674421"><span>(Optional) Run the following command to install the growpart tool:</span><p><p id="evs_01_0072__p13629724214"><strong id="evs_01_0072__b5362137164213">yum install cloud-utils-growpart</strong></p>
<div class="note" id="evs_01_0072__note23390197311"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__p1333918191310">You can run <strong id="evs_01_0072__b4441153803210">growpart</strong> to check whether the growpart tool has been installed. If the command output displays the tool usage instructions, the tool has been installed and you do not need to install it again.</p>
</div></div>
</p></li><li id="evs_01_0072__li63521231113"><span>Run the following command to view the total capacity of the <strong id="evs_01_0072__b57453128">/dev/vda</strong> system disk:</span><p><p id="evs_01_0072__p123521723171114"><strong id="evs_01_0072__b143524230119">fdisk -l</strong></p>
<div class="p" id="evs_01_0072__p113521323191115">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen335262311118">[root@ecs-test-0001 ~]# fdisk -l
Disk /dev/vda: 107.4 GiB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000bcb4e
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886079 41942016 83 Linux</pre>
</div>
<p id="evs_01_0072__p6274348257"></p>
</p></li><li id="evs_01_0072__li42731481557"><span>Run the following command to view the capacity of the <strong id="evs_01_0072__b940494032">/dev/vda1</strong> partition:</span><p><p id="evs_01_0072__p1527318481514"><strong id="evs_01_0072__b227314485517">df -TH</strong></p>
<div class="p" id="evs_01_0072__p92736482051">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen13273194811518">[root@ecs-test-0001 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 43G 2.0G 39G 5% /
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 9.0M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs tmpfs 398M 0 398M 0% /run/user/0</pre>
</div>
<p id="evs_01_0072__p19192603613"></p>
</p></li><li id="evs_01_0072__li1119230967"><span>Run the following command to extend the partition using growpart:</span><p><p id="evs_01_0072__p171911007619"><strong id="evs_01_0072__b280446810">growpart</strong> <em id="evs_01_0072__i1827161168">System disk Partition number</em></p>
<p id="evs_01_0072__p1619120463">In this example, run the following command:</p>
<p id="evs_01_0072__p219100768"><strong id="evs_01_0072__b1319160361">growpart /dev/vda 1</strong></p>
<div class="p" id="evs_01_0072__p171921701167">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen6192901169">[root@ecs-test-0001 ~]# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=83884032 end=83886080 new: size=209713119,end=209715167</pre>
</div>
<p id="evs_01_0072__p1291415167"></p>
</p></li><li id="evs_01_0072__li178515663"><span>Run the following command to extend the file system of the partition:</span><p><p id="evs_01_0072__p1788151769"><strong id="evs_01_0072__b1061626754">resize2fs</strong> <em id="evs_01_0072__i13634768">Disk partition</em></p>
<p id="evs_01_0072__p12881512617">In this example, run the following command:</p>
<p id="evs_01_0072__p19811518617"><strong id="evs_01_0072__b9817153613">resize2fs /dev/vda1</strong></p>
<div class="p" id="evs_01_0072__p18871520616">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen98111512619">[root@ecs-test-0001 ~]# resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 13
The filesystem on /dev/vda1 is now 26214139 blocks long.</pre>
</div>
<div class="note" id="evs_01_0072__note49951435192815"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__p440354322914">If the error message "open: No such file or directory while opening /dev/vdb1" is returned, an incorrect partition is specified. Run <strong id="evs_01_0072__b04603825211">df -TH</strong> to view the disk partitions.</p>
</div></div>
</p></li><li id="evs_01_0072__li12664118560"><span>Run the following command to view the new capacity of the <strong id="evs_01_0072__b940069229">/dev/vda1</strong> partition:</span><p><p id="evs_01_0072__p766420181267"><strong id="evs_01_0072__b126641318560">df -TH</strong></p>
<div class="p" id="evs_01_0072__p1664218360">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen8664161816610">[root@ecs-test-0001 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 106G 2.0G 99G 2% /
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 9.0M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs tmpfs 398M 0 398M 0% /run/user/0</pre>
</div>
</p></li></ol>
</div>
<div class="section" id="evs_01_0072__section158762021831"><a name="evs_01_0072__section158762021831"></a><a name="section158762021831"></a><h4 class="sectiontitle">Extending an Existing MBR Partition (Kernel Version Earlier Than 3.6.0)</h4><div class="notice" id="evs_01_0072__note148574113410"><span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span><div class="noticebody"><p id="evs_01_0072__p610916152393">If the OS kernel version is earlier than 3.6.0, the extension of an existing MBR disk partition and file system takes effect only after a server reboot, and services will be interrupted.</p>
</div></div>
<p id="evs_01_0072__p1987019173417">CentOS 6.5 64bit is used as the sample OS. Originally, system disk <strong id="evs_01_0072__b1855118425916">/dev/vda</strong> has 40 GiB and one partition (<strong id="evs_01_0072__b455274145915">/dev/vda1</strong>), and then 60 GiB is added to the disk. The following procedure shows you how to allocate the additional 60 GiB to the existing MBR partition <strong id="evs_01_0072__b14624754102112">/dev/vda1</strong>.</p>
<ol id="evs_01_0072__ol687671173414"><li id="evs_01_0072__li1087312118341"><span>(Optional) Run the following command to install the growpart tool:</span><p><p id="evs_01_0072__p1787210113417"><strong id="evs_01_0072__b28721716340">yum install cloud-utils-growpart</strong></p>
<div class="note" id="evs_01_0072__note138736117347"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__p1387301113413">You can run <strong id="evs_01_0072__b106381713716">growpart</strong> to check whether the growpart tool has been installed. If the command output displays the tool usage instructions, the tool has been installed and you do not need to install it again.</p>
</div></div>
</p></li><li id="evs_01_0072__li10876201113416"><span>Run the following command to install the dracut-modules-growroot tool:</span><p><p id="evs_01_0072__p1787416153415"><strong id="evs_01_0072__b148741193414">yum install cloud-utils-growpart</strong></p>
<div class="p" id="evs_01_0072__p2874215343">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen1787410123418">[root@ecs-test-0002 ~]# yum install cloud-utils-growpart
Loaded plugins: fastestmirror, security
Setting up Install Process
Determining fastest mirrors
...
Package cloud-utils-growpart-0.27-10.el6.x86_64 already installed and latest version
Nothing to do</pre>
</div>
</p></li><li id="evs_01_0072__li14874116345"><span>Run the following command to regenerate the initramfs file:</span><p><p id="evs_01_0072__p1787417143411"><strong id="evs_01_0072__b387416103416">dracut -f</strong></p>
</p></li><li id="evs_01_0072__li1646914522401"><span>Run the following command to view the total capacity of the <strong id="evs_01_0072__b558112182274">/dev/vda</strong> system disk:</span><p><p id="evs_01_0072__p1846965204015"><strong id="evs_01_0072__b1846895224013">fdisk -l</strong></p>
<div class="p" id="evs_01_0072__p84691652154012">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen1346945224019">[root@ecs-test-0002 ~]# fdisk -l
Disk /dev/vda: 107.4 GiB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004e0be
Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41942016 83 Linux</pre>
</div>
</p></li><li id="evs_01_0072__li5779185594014"><span>Run the following command to view the capacity of the <strong id="evs_01_0072__b1278522915275">/dev/vda1</strong> partition:</span><p><p id="evs_01_0072__p7779655184011"><strong id="evs_01_0072__b4779855194016">df -TH</strong></p>
<div class="p" id="evs_01_0072__p977955515404">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen2779255134013">[root@ecs-test-0002 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 43G 1.7G 39G 5% /
tmpfs tmpfs 2.1G 0 2.1G 0% /dev/shm</pre>
</div>
</p></li><li id="evs_01_0072__li0374359174016"><span>Run the following command to extend the partition using growpart:</span><p><p id="evs_01_0072__p23741659184014"><strong id="evs_01_0072__b1732130148">growpart</strong> <em id="evs_01_0072__i753329060">System disk Partition number</em></p>
<p id="evs_01_0072__p8374145911402">In this example, run the following command:</p>
<p id="evs_01_0072__p3374105974020"><strong id="evs_01_0072__b33741359174010">growpart /dev/vda 1</strong></p>
<div class="p" id="evs_01_0072__p337411596401">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen0374165964010">[root@ecs-test-0002 ~]# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=83884032 end=83886080 new: size=209710462,end=209712510</pre>
</div>
</p></li><li id="evs_01_0072__li18569193144118"><span>Run the following command to restart the <span id="evs_01_0072__text11547155614231">server</span>:</span><p><p id="evs_01_0072__p13569932419"><strong id="evs_01_0072__b1556923104115">reboot</strong></p>
<p id="evs_01_0072__p155698324115">After the server is restarted, reconnect to the <span id="evs_01_0072__text7493162162512">server</span> and perform the following steps.</p>
</p></li><li id="evs_01_0072__li76571584410"><span>Run the following command to extend the file system of the partition:</span><p><p id="evs_01_0072__p365798144117"><strong id="evs_01_0072__b59117951">resize2fs</strong> <em id="evs_01_0072__i401817722">Disk partition</em></p>
<p id="evs_01_0072__p76577818416">In this example, run the following command:</p>
<p id="evs_01_0072__p5657885411"><strong id="evs_01_0072__b116576811419">resize2fs</strong> <strong id="evs_01_0072__b1565710820415">/dev/vda1</strong></p>
<div class="p" id="evs_01_0072__p26572811419">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen165717813412">[root@ecs-test-0002 ~]# resize2fs /dev/vda1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 26213807 blocks long. Nothing to do!</pre>
</div>
<div class="note" id="evs_01_0072__note13764308303"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__evs_01_0072_p440354322914">If the error message "open: No such file or directory while opening /dev/vdb1" is returned, an incorrect partition is specified. Run <strong id="evs_01_0072__evs_01_0072_b04603825211">df -TH</strong> to view the disk partitions.</p>
</div></div>
</p></li><li id="evs_01_0072__li124321112144120"><span>Run the following command to view the new capacity of the <strong id="evs_01_0072__b1954416215316">/dev/vda1</strong> partition:</span><p><p id="evs_01_0072__p114321712194120"><strong id="evs_01_0072__b9432161214418">df -TH</strong></p>
<div class="p" id="evs_01_0072__p6432141244119">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen74321812104112">[root@ecs-test-0002 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 106G 1.7G 99G 2% /
tmpfs tmpfs 2.1G 0 2.1G 0% /dev/shm</pre>
</div>
</p></li></ol>
</div>
<div class="section" id="evs_01_0072__section9194153012119"><a name="evs_01_0072__section9194153012119"></a><a name="section9194153012119"></a><h4 class="sectiontitle">Creating a New MBR Partition</h4><p id="evs_01_0072__p18307331210">Originally, system disk <strong id="evs_01_0072__b5470155853219">/dev/vda</strong> has 40 GiB and one partition (<strong id="evs_01_0072__b1372410222339">/dev/vda1</strong>), and then 40 GiB is added to the disk. The following procedure shows you how to create a new MBR partition <strong id="evs_01_0072__b6204332153616">/dev/vda2</strong> with this 40 GiB.</p>
<ol id="evs_01_0072__ol1293195319479"><li id="evs_01_0072__li6396237219479"><span>Run the following command to view the disk partition information:</span><p><p id="evs_01_0072__p1385482419479"><strong id="evs_01_0072__b153942419479">fdisk -l</strong></p>
<div class="p" id="evs_01_0072__p3609954819479">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen19333124991418">[root@ecs-2220 ~]# fdisk -l
Disk /dev/vda: 85.9 GiB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008d18f
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886079 41942016 83 Linux</pre>
</div>
<p id="evs_01_0072__p2789579016756">In the command output, the capacity of the <strong id="evs_01_0072__b842352706204246">dev/vda</strong> system disk is 80 GiB, in which the in-use <strong id="evs_01_0072__b842352706204331">dev/vda1</strong> partition takes 40 GiB and the additional 40 GiB has not been allocated.</p>
</p></li><li id="evs_01_0072__li11513919479"><span>Run the following command to enter fdisk:</span><p><p id="evs_01_0072__p4382752119479"><strong id="evs_01_0072__b58680792162515">fdisk /dev/vda</strong></p>
<div class="p" id="evs_01_0072__p5890337519479">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen124766453179">[root@ecs-2220 ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): </pre>
</div>
</p></li><li id="evs_01_0072__li6345756195025"><span>Enter <strong id="evs_01_0072__b8562368176">n</strong> and press <strong id="evs_01_0072__b1756317616178">Enter</strong> to create a new partition.</span><p><div class="p" id="evs_01_0072__p30880659195025"><span id="evs_01_0072__text55626967195025">Information similar to the following is displayed:</span><pre class="screen" id="evs_01_0072__screen1061273312198">Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended</pre>
</div>
<div class="p" id="evs_01_0072__p44635586111440">There are two types of disk partitions:<ul id="evs_01_0072__evs_01_0109_evs_01_0109_ul5364496116158"><li id="evs_01_0072__evs_01_0109_evs_01_0109_li1304260716158">Choosing <span class="parmvalue" id="evs_01_0072__evs_01_0109_parmvalue5027460516158"><b>p</b></span> creates a primary partition.</li><li id="evs_01_0072__evs_01_0109_evs_01_0109_li4981826916158">Choosing <span class="parmvalue" id="evs_01_0072__evs_01_0109_parmvalue4571123816158"><b>e</b></span> creates an extended partition.</li></ul>
<div class="note" id="evs_01_0072__evs_01_0109_evs_01_0109_note13373129016"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__evs_01_0109_evs_01_0109_p4376112918117">If MBR is used, a maximum of four primary partitions, or three primary partitions plus one extended partition can be created. The extended partition must be divided into logical partitions before use.</p>
<p id="evs_01_0072__evs_01_0109_evs_01_0109_p20170151213510">Disk partitions created using GPT are not categorized.</p>
</div></div>
</div>
</p></li><li id="evs_01_0072__li110812372314"><span>In this example, a primary partition is created. Therefore, enter <strong id="evs_01_0072__b8423527061987">p</strong> and press <strong id="evs_01_0072__b84235270619811">Enter</strong> to create a primary partition.</span><p><div class="p" id="evs_01_0072__p9822210132312">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen149621181236">Select (default p): p
Partition number (2-4, default 2): </pre>
</div>
</p></li><li id="evs_01_0072__li18585144310247"><span>Enter the serial number of the primary partition and press <strong id="evs_01_0072__b107031552235">Enter</strong>. Partition number <span class="parmvalue" id="evs_01_0072__parmvalue203175347321528"><b>2</b></span> is used in this example. Therefore, enter <strong id="evs_01_0072__b119621518294">2</strong> and press <strong id="evs_01_0072__b59771185293">Enter.</strong></span><p><div class="p" id="evs_01_0072__p88155515240">Information similar to the following is displayed:<pre class="screen" id="evs_01_0072__screen1838241110256">Partition number (2-4, default 2): 2
First sector (83886080-167772159, default 83886080):</pre>
</div>
</p></li><li id="evs_01_0072__li41769519195025"><span>Enter the new partition's start sector and press <strong id="evs_01_0072__b316518546373">Enter</strong>. In this example, the default start sector is used.</span><p><p id="evs_01_0072__p3623215214">The system displays the start and end sectors of the partition's available space. You can customize the value within this range or use the default value. The start sector must be smaller than the partition's end sector.</p>
<div class="p" id="evs_01_0072__p62653510195025"><span id="evs_01_0072__text44244203195025">Information similar to the following is displayed:</span><pre class="screen" id="evs_01_0072__screen103491442619">First sector (83886080-167772159, default 83886080):
Using default value 83886080
Last sector, +sectors or +size{K,M,G} (83886080-167772159,default 167772159):</pre>
</div>
</p></li><li id="evs_01_0072__li63358740195025"><span>Enter the new partition's end sector and press <strong id="evs_01_0072__b63241836153812">Enter</strong>. In this example, the default end sector is used.</span><p><p id="evs_01_0072__p182641417161210">The system displays the start and end sectors of the partition's available space. You can customize the value within this range or use the default value. The start sector must be smaller than the partition's end sector.</p>
<div class="p" id="evs_01_0072__p49663971195025"><span id="evs_01_0072__text27887840195025">Information similar to the following is displayed:</span><pre class="screen" id="evs_01_0072__screen1774715611267">Last sector, +sectors or +size{K,M,G} (83886080-167772159,
default 167772159):
Using default value 167772159
Partition 2 of type Linux and of size 40 GiB is set
Command (m for help): </pre>
</div>
</p></li><li id="evs_01_0072__li33357756195025"><span>Enter <strong id="evs_01_0072__b43545514131720">p</strong> and press <strong id="evs_01_0072__b56365313131720">Enter</strong> to view the new partition.</span><p><div class="p" id="evs_01_0072__p775454195221"><span id="evs_01_0072__text31784354195025">Information similar to the following is displayed:</span><pre class="screen" id="evs_01_0072__screen184103528271">Command (m for help): p
Disk /dev/vda: 85.9 GiB, 85899345920 bytes, 167772160 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0008d18f
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886079 41942016 83 Linux
/dev/vda2 83886080 167772159 41943040 83 Linux
Command (m for help): </pre>
</div>
</p></li><li id="evs_01_0072__li66935752195025"><span>Enter <strong id="evs_01_0072__b842352706192329">w</strong> and press <strong id="evs_01_0072__b842352706192333">Enter</strong> to write the changes to the partition table.</span><p><div class="p" id="evs_01_0072__p756878195025"><span id="evs_01_0072__text29910259195025">Information similar to the following is displayed:</span><pre class="screen" id="evs_01_0072__screen1037551062813">Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.</pre>
</div>
<p id="evs_01_0072__p25877576155757">The partition is created.</p>
<div class="note" id="evs_01_0072__note4366792011219"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__p1060395711212">In case that you want to discard the changes made before, you can exit fdisk by entering <strong id="evs_01_0072__b842352706161749">q</strong>.</p>
</div></div>
</p></li><li id="evs_01_0072__li65550858195025"><span>Run the following command to synchronize the new partition table to the OS:</span><p><p class="litext" id="evs_01_0072__p2882928101423"><strong id="evs_01_0072__b53086813195025">partprobe</strong></p>
</p></li><li id="evs_01_0072__li58324522195025"><span>Run the following command to set the file system format for the new partition:</span><p><p id="evs_01_0072__p1653216213278"><strong id="evs_01_0072__b379813277416">mkfs</strong> <strong id="evs_01_0072__b1079852713418">-t</strong> <em id="evs_01_0072__i77988271411">File system</em> <em id="evs_01_0072__i197991227048">Disk partition</em></p>
<ul id="evs_01_0072__ul62235216279"><li id="evs_01_0072__li1522392142720">Sample command of the ext* file system:<p id="evs_01_0072__p1287695272613"><a name="evs_01_0072__li1522392142720"></a><a name="li1522392142720"></a>(The ext4 file system is used in this example.)</p>
<p id="evs_01_0072__p17876125210266"><strong id="evs_01_0072__b987615232614">mkfs -t ext4 /dev/vda2</strong></p>
<div class="p" id="evs_01_0072__p1687735252618"><span id="evs_01_0072__text287619523263">Information similar to the following is displayed:</span><pre class="screen" id="evs_01_0072__screen58774522269">[root@ecs-2220 ~]# mkfs -t ext4 /dev/vda2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10485760 blocks
524288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done</pre>
</div>
</li></ul>
<ul id="evs_01_0072__ul862520022817"><li id="evs_01_0072__li19751339185117">Sample command of the xfs file system:<p id="evs_01_0072__p176142612534"><a name="evs_01_0072__li19751339185117"></a><a name="li19751339185117"></a><strong id="evs_01_0072__b131231440538">mkfs</strong> <strong id="evs_01_0072__b19123194185316">-t</strong> <strong id="evs_01_0072__b201235465316">xfs</strong> <strong id="evs_01_0072__b1412317495314">/dev/vda2</strong></p>
<p id="evs_01_0072__p8420438122815"><span id="evs_01_0072__text1436219452284">Information similar to the following is displayed:</span></p>
<pre class="screen" id="evs_01_0072__screen1299284952817">[root@ecs-2220 ~]# mkfs -t xfs /dev/vda2
meta-data=/dev/vda2 isize=512 agcount=4, agsize=2621440 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=10485760, imaxpct=25
= sunit=0 swidth=0 blks
naming =version2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=5120, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0</pre>
</li></ul>
<p id="evs_01_0072__p5877155232614">The formatting takes a while, and you need to observe the system running status. Once <strong id="evs_01_0072__b48179132212">done</strong> is displayed in the command output, the formatting is complete.</p>
</p></li><li id="evs_01_0072__li1718305792316"><span>(Optional) Run the following command to create a mount point:</span><p><p id="evs_01_0072__p13941413123210">Perform this step if you want to mount the partition on a new mount point.</p>
<p id="evs_01_0072__p10395911133214"><strong id="evs_01_0072__b17708835124017">mkdir</strong> <em id="evs_01_0072__i57091635154017">Mount point</em></p>
<p id="evs_01_0072__p1839561117321">In this example, run the following command to create the <strong id="evs_01_0072__b14833104094018">/opt</strong> mount point:</p>
<p id="evs_01_0072__p1139514117326"><strong id="evs_01_0072__b93952110321">mkdir /opt</strong></p>
</p></li><li id="evs_01_0072__li53941554195913"><span>Run the following command to mount the new partition:</span><p><p id="evs_01_0072__p176844133313"><strong id="evs_01_0072__b8576102414112">mount</strong> <em id="evs_01_0072__i135771924194110">Disk partition</em> <em id="evs_01_0072__i1657822484115">Mount point</em></p>
<p id="evs_01_0072__p376916453319">In this example, run the following command to mount the new partition <strong id="evs_01_0072__b98831028184120">/dev/vda2</strong> on <strong id="evs_01_0072__b9758356204118">/opt</strong>:</p>
<p id="evs_01_0072__p11769194183313"><strong id="evs_01_0072__b11919158118">mount /dev/vda2 /opt</strong></p>
<div class="note" id="evs_01_0072__note18395115411594"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__p1639555411592">If the new partition is mounted on a directory that is not empty, the subdirectories and files in the directory will be hidden. Therefore, you are advised to mount the new partition on an empty directory or a new directory. If the new partition must be mounted on a directory that is not empty, move the subdirectories and files in this directory to another directory temporarily. After the partition is successfully mounted, move the subdirectories and files back.</p>
</div></div>
</p></li><li id="evs_01_0072__li14641591151132"><span>Run the following command to view the mount result:</span><p><p id="evs_01_0072__p64665463151132"><strong id="evs_01_0072__b45118260151132">df -TH</strong></p>
<p id="evs_01_0072__p3411159151132"><span id="evs_01_0072__text30700433151132">Information similar to the following is displayed:</span></p>
<pre class="screen" id="evs_01_0072__screen31841804151132">[root@ecs-2220 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 43G 2.0G 39G 5% /
devtmpfs devtmpfs 509M 0 509M 0% /dev
tmpfs tmpfs 520M 0 520M 0% /dev/shm
tmpfs tmpfs 520M 7.2M 513M 2% /run
tmpfs tmpfs 520M 0 520M 0% /sys/fs/cgroup
tmpfs tmpfs 104M 0 104M 0% /run/user/0
/dev/vda2 ext4 43G 51M 40G 1% /opt</pre>
<div class="note" id="evs_01_0072__note151217575408"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__p13141357194019">If the <span id="evs_01_0072__text18797917173516">server</span> is restarted, the mounting will become invalid. You can modify the <strong id="evs_01_0072__b946144124813">/etc/fstab</strong> file to configure automount at startup. See the following part for details.</p>
</div></div>
</p></li></ol>
</div>
<div class="section" id="evs_01_0072__section1122546162318"><h4 class="sectiontitle">Configuring Automatic Mounting at System Start</h4><p id="evs_01_0072__en-us_topic_0044524669_p10888449418">The <strong id="evs_01_0072__b113731194817">fstab</strong> file controls what disks are automatically mounted at <span id="evs_01_0072__en-us_topic_0044524669_text288818413414">server</span> startup. You can configure the <strong id="evs_01_0072__b1888013169494">fstab</strong> file of a <span id="evs_01_0072__en-us_topic_0044524669_text615861019358">server</span> that has data. This operation will not affect the existing data.</p>
<p id="evs_01_0072__en-us_topic_0044524669_p3301097119558">The following example uses UUIDs to identify disks in the <strong id="evs_01_0072__b052832165015">fstab</strong> file. You are advised not to use device names (like <strong id="evs_01_0072__b18387201210586">/dev/vdb1</strong>) to identify disks in the file because device names are assigned dynamically and may change (for example, from <strong id="evs_01_0072__b1844841645810">/dev/vdb1</strong> to <strong id="evs_01_0072__b2249111965816">/dev/vdb2</strong>) after a <span id="evs_01_0072__en-us_topic_0044524669_text60279752174534">server</span> stop or start. This can even prevent your <span id="evs_01_0072__en-us_topic_0044524669_text33232815911">server</span> from booting up.</p>
<div class="note" id="evs_01_0072__en-us_topic_0044524669_note6058396910219"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0072__en-us_topic_0044524669_p838481110219">UUIDs are the unique character strings for identifying partitions in Linux.</p>
</div></div>
<ol id="evs_01_0072__en-us_topic_0044524669_ol7409641133211"><li id="evs_01_0072__en-us_topic_0044524669_li840964143216"><span>Query the partition UUID.</span><p><p id="evs_01_0072__en-us_topic_0044524669_p32760575102436"><strong id="evs_01_0072__b14524341165217">blkid</strong> <em id="evs_01_0072__i452424112524">Disk partition</em></p>
<p id="evs_01_0072__en-us_topic_0044524669_p54606997105845">In this example, the UUID of the <span class="parmname" id="evs_01_0072__parmname77581449165211"><b>/dev/vdb1</b></span> partition is queried.</p>
<p id="evs_01_0072__en-us_topic_0044524669_p204811453103215"><strong id="evs_01_0072__en-us_topic_0044524669_b11565159153817">blkid /dev/vdb1</strong></p>
<p id="evs_01_0072__en-us_topic_0044524669_p13610514113319">Information similar to the following is displayed:</p>
<pre class="screen" id="evs_01_0072__en-us_topic_0044524669_screen361091453315">[root@ecs-test-0001 ~]# blkid /dev/vdb1
/dev/vdb1: UUID="0b3040e2-1367-4abb-841d-ddb0b92693df" TYPE="ext4"</pre>
<p id="evs_01_0072__en-us_topic_0044524669_p275684701890">Carefully record the UUID, as you will need it for the following step.</p>
</p></li><li id="evs_01_0072__en-us_topic_0044524669_li199421823183318"><span>Open the <strong id="evs_01_0072__b173611450539">fstab</strong> file using the vi editor.</span><p><p id="evs_01_0072__en-us_topic_0044524669_p9610114153320"><strong id="evs_01_0072__en-us_topic_0044524669_b1361031419337">vi /etc/fstab</strong></p>
</p></li><li id="evs_01_0072__en-us_topic_0044524669_li941511389331"><span>Press <strong id="evs_01_0072__b138621310205316">i</strong> to enter editing mode.</span></li><li id="evs_01_0072__en-us_topic_0044524669_li8415123893310"><span>Move the cursor to the end of the file and press <strong id="evs_01_0072__b16102161513531">Enter</strong>. Then, add the following information:</span><p><pre class="screen" id="evs_01_0072__en-us_topic_0044524669_screen8133145031318">UUID=0b3040e2-1367-4abb-841d-ddb0b92693df /mnt/sdc ext4 defaults 0 2</pre>
</p></li><li id="evs_01_0072__en-us_topic_0044524669_li841512388338"><span>Press <strong id="evs_01_0072__b1940892811568">Esc</strong>, enter <strong id="evs_01_0072__b13409122817561">:wq</strong>, and press <strong id="evs_01_0072__b14409192816561">Enter</strong>.</span><p><p id="evs_01_0072__en-us_topic_0044524669_p1141543813310">The system saves the configurations and exits the vi editor.</p>
</p></li><li id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_li17720613102410"><span>Verify that the disk is auto-mounted at startup.</span><p><ol type="a" id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_ol199891910256"><li id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_li1620791415268">Unmount the partition.<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p18208131462618"><a name="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_li1620791415268"></a><a name="en-us_topic_0044524669_en-us_topic_0142861223_li1620791415268"></a><strong id="evs_01_0072__b208731402564">umount</strong> <em id="evs_01_0072__i78741940165615">Disk partition</em></p>
<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p621161413262">In this example, run the following command:</p>
<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p1521115148260"><strong id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_b0213614192618">umount /dev/vdb1</strong></p>
</li><li id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_li2397162792610">Reload all the content in the <strong id="evs_01_0072__b1457010482568">/etc/fstab</strong> file.<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p1739714278269"><strong id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_b63981278267">mount -a</strong></p>
</li><li id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_li9280203710269">Query the file system mounting information.<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p3282133715264"><a name="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_li9280203710269"></a><a name="en-us_topic_0044524669_en-us_topic_0142861223_li9280203710269"></a><strong id="evs_01_0072__b131131459105615">mount</strong> <strong id="evs_01_0072__b61137597565">|</strong> <strong id="evs_01_0072__b131133593568">grep</strong> <em id="evs_01_0072__i311465915568">Mount point</em></p>
<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p3286437112619">In this example, run the following command:</p>
<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p18286123782619"><strong id="evs_01_0072__en-us_topic_0044524669_b925094342911">mount</strong> <strong id="evs_01_0072__en-us_topic_0044524669_b1725119437291">|</strong> <strong id="evs_01_0072__en-us_topic_0044524669_b15324154395212">grep</strong> <strong id="evs_01_0072__en-us_topic_0044524669_b1831387417">/mnt/sdc</strong></p>
<p id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_p429163752616">If information similar to the following is displayed, automatic mounting has been configured:</p>
<pre class="screen" id="evs_01_0072__en-us_topic_0044524669_en-us_topic_0142861223_screen429312370265">root@ecs-test-0001 ~]# mount | grep /mnt/sdc
/dev/vdb1 on /mnt/sdc type ext4 (rw,relatime,data=ordered)</pre>
</li></ol>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="evs_01_0094.html">Extending Disk Partitions and File Systems (Linux)</a></div>
</div>
</div>