forked from docs/doc-exports
Reviewed-by: Miskanin, Jan <jan.miskanin@t-systems.com> Co-authored-by: zhangyue <zhangyue164@huawei.com> Co-committed-by: zhangyue <zhangyue164@huawei.com>
177 lines
19 KiB
HTML
177 lines
19 KiB
HTML
<a name="evs_01_0035"></a><a name="evs_01_0035"></a>
|
|
|
|
<h1 class="topictitle1">Partition and File System Extension Preparations (Linux)</h1>
|
|
<div id="body1511511858525"><p id="evs_01_0035__p15240520125911">Before extending the disk partition and file system, you must check the disk partition style and file system format, and then select the appropriate operation accordingly.</p>
|
|
<ol id="evs_01_0035__ol3866185616343"><li id="evs_01_0035__li1186610569349">To view the disk partition style, see the following methods:<ul id="evs_01_0035__ul11242201183512"><li id="evs_01_0035__li162438153514"><a href="#evs_01_0035__section45741613172812">Method 1: Check Partition Style and File System Format Using fdisk</a></li><li id="evs_01_0035__li152431415356"><a href="#evs_01_0035__section7627683297">Method 2: Check Partition Style and File System Format Using parted</a></li></ul>
|
|
</li><li id="evs_01_0035__li12866115643415">To select the appropriate operation, see <a href="#evs_01_0035__table45743268308">Table 1</a>.
|
|
<div class="tablenoborder"><a name="evs_01_0035__table45743268308"></a><a name="table45743268308"></a><table cellpadding="4" cellspacing="0" summary="" id="evs_01_0035__table45743268308" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Disk partition and file system extension scenarios</caption><thead align="left"><tr id="evs_01_0035__row1289216429188"><th align="left" class="cellrowborder" valign="top" width="15.98%" id="mcps1.3.2.2.2.2.4.1.1"><p id="evs_01_0035__p19891942161816">Disk</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="43.730000000000004%" id="mcps1.3.2.2.2.2.4.1.2"><p id="evs_01_0035__p188911542151811">Scenario</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="40.29%" id="mcps1.3.2.2.2.2.4.1.3"><p id="evs_01_0035__p1189110425184">Method</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="evs_01_0035__row8897134241819"><td class="cellrowborder" rowspan="2" valign="top" width="15.98%" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p17897154210185">System disk</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="43.730000000000004%" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p989716421188">Create a new MBR partition with the additional space.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="40.29%" headers="mcps1.3.2.2.2.2.4.1.3 "><p id="evs_01_0035__p118973428186"><a href="evs_01_0072.html#evs_01_0072__section9194153012119">Creating a New MBR Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row198975428181"><td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p9897114241815">Allocate the additional space to an existing MBR partition.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.2 "><ul id="evs_01_0035__ul164505212534"><li id="evs_01_0035__li9450132115320"><a href="evs_01_0072.html#evs_01_0072__section143412109355">Extending an Existing MBR Partition (Kernel Version Later Than 3.6.0)</a></li><li id="evs_01_0035__li514008165319"><a href="evs_01_0072.html#evs_01_0072__section158762021831">Extending an Existing MBR Partition (Kernel Version Earlier Than 3.6.0)</a></li></ul>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row7897194220188"><td class="cellrowborder" rowspan="4" valign="top" width="15.98%" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p28971423183">Data disk</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="43.730000000000004%" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p1897542141810">Create a new MBR partition with the additional space.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="40.29%" headers="mcps1.3.2.2.2.2.4.1.3 "><p id="evs_01_0035__p1189713425186"><a href="evs_01_0109.html#evs_01_0109__section20200028194016">Creating a New MBR Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row089713426186"><td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p889714424186">Allocate the additional space to an existing MBR partition.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p49501739155317"><a href="evs_01_0109.html#evs_01_0109__section31113372194023">Extending an Existing MBR Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row1689754218188"><td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p16897174212187">Create a new GPT partition with the additional space.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p1989720421182"><a href="evs_01_0109.html#evs_01_0109__section15940163415487">Creating a New GPT Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row1789834214187"><td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p1689854271810">Allocate the additional space to an existing GPT partition.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p735471745419"><a href="evs_01_0109.html#evs_01_0109__section13346184710300">Extending an Existing GPT Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row18981142161813"><td class="cellrowborder" rowspan="2" valign="top" width="15.98%" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p589824212181">SCSI data disk</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="43.730000000000004%" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p38981242201820">Create a new MBR partition with the additional space.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="40.29%" headers="mcps1.3.2.2.2.2.4.1.3 "><p id="evs_01_0035__p1689874213182"><a href="evs_01_0018.html#evs_01_0018__section12265143819280">Creating a New MBR Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
<tr id="evs_01_0035__row889816422183"><td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.1 "><p id="evs_01_0035__p148981542111812">Allocate the additional space to an existing MBR partition.</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" headers="mcps1.3.2.2.2.2.4.1.2 "><p id="evs_01_0035__p9255147165416"><a href="evs_01_0018.html#evs_01_0018__section31113372194023">Extending an Existing MBR Partition</a></p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="note" id="evs_01_0035__note195015215325"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0035__p193802581228">The maximum disk capacity that MBR supports is 2 TiB, and the disk space exceeding 2 TiB cannot be used.</p>
|
|
<p id="evs_01_0035__p1538018586221">If your disk uses MBR and you need to expand the disk capacity to over 2 TiB, change the partition style from MBR to GPT. Ensure that the disk data has been backed up before changing the partition style because services will be interrupted and data on the disk will be cleared during this change.</p>
|
|
</div></div>
|
|
</li></ol>
|
|
<div class="section" id="evs_01_0035__section45741613172812"><a name="evs_01_0035__section45741613172812"></a><a name="section45741613172812"></a><h4 class="sectiontitle">Method 1: Check Partition Style and File System Format Using fdisk</h4><ol id="evs_01_0035__ol2900319714518"><li id="evs_01_0035__li4640174163019"><a name="evs_01_0035__li4640174163019"></a><a name="li4640174163019"></a><span>Run the following command to view all the disks attached to the <span id="evs_01_0035__text56411141123020">server</span>:</span><p><p id="evs_01_0035__p4641134114308"><strong id="evs_01_0035__b1664118411308">lsblk</strong></p>
|
|
<div class="p" id="evs_01_0035__p106418412309">Information similar to the following is displayed:<pre class="screen" id="evs_01_0035__screen9641104113010">[root@ecs-test-0001 ~]# lsblk
|
|
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
|
vda 253:0 0 40G 0 disk
|
|
└─vda1 253:1 0 40G 0 part /
|
|
vdb 253:16 0 150G 0 disk
|
|
└─vdb1 253:17 0 100G 0 part /mnt/sdc</pre>
|
|
</div>
|
|
<p id="evs_01_0035__p1264117419305">In this example, data disk <strong id="evs_01_0035__b1281718371306">/dev/vdb</strong> already has partition <strong id="evs_01_0035__b04731653113011">/dev/vdb1</strong> before capacity expansion, and the additional 50 GiB added has not been allocated yet. Therefore, <strong id="evs_01_0035__b1085184053413">/dev/vdb</strong> has 150 GiB, and <strong id="evs_01_0035__b3787740143613">/dev/vdb1</strong> has 100 GiB.</p>
|
|
<div class="note" id="evs_01_0035__note177820401835"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0035__p1877914401139">If you run <strong id="evs_01_0035__b10269165412545">lsblk</strong> and find out that disk <strong id="evs_01_0035__b726955417543">/dev/vdb</strong> has no partitions, format the disk by referring to <a href="evs_faq_0073.html">How Do I Extend the File System of an Unpartitioned Data Disk in Linux?</a> and expand the capacity. Otherwise, the additional space cannot be used after expansion.</p>
|
|
</div></div>
|
|
</p></li><li id="evs_01_0035__li5970218814518"><span>Run the following command to view the current disk partition style:</span><p><p id="evs_01_0035__p44878614518"><strong id="evs_01_0035__b403908014518">fdisk -l</strong></p>
|
|
<div class="p" id="evs_01_0035__p3635172814518">Information similar to the following is displayed:<pre class="screen" id="evs_01_0035__screen107608156108">[root@ecs-test-0001 ~]# fdisk -l
|
|
|
|
Disk /dev/vda: 42.9 GiB, 42949672960 bytes, 83886080 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
|
|
|
|
Disk /dev/vdb: 161.1 GiB, 161061273600 bytes, 314572800 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: 0x38717fc1
|
|
|
|
Device Boot Start End Blocks Id System
|
|
/dev/vdb1 2048 209715199 104856576 83 Linux</pre>
|
|
</div>
|
|
<p id="evs_01_0035__p242784819494">The value in the <strong id="evs_01_0035__b1070933413382">System</strong> column indicates the disk partition style. Value <strong id="evs_01_0035__b5851113823815">Linux</strong> indicates the MBR partition style. Value <strong id="evs_01_0035__b1080365743810">GPT</strong> indicates the GPT partition style.</p>
|
|
<ul id="evs_01_0035__ul1426017189542"><li id="evs_01_0035__li102601818165411">If the disk partitions displayed are inconsistent with those obtained in <a href="#evs_01_0035__li4640174163019">1</a>, the possible reason may be that existing partitions uses GPT and there is unallocated disk space. In this case, you cannot query all the partitions using <strong id="evs_01_0035__b1686601434418">fdisk -l</strong>. Go to <a href="#evs_01_0035__section7627683297">Method 2: Check Partition Style and File System Format Using parted</a>.</li><li id="evs_01_0035__li662513369540">If the disk partitions displayed are consistent with those obtained in <a href="#evs_01_0035__li4640174163019">1</a>, continue with the following operations.</li></ul>
|
|
</p></li><li id="evs_01_0035__li28968321150"><span>Run the following command to view the partition's file system format:</span><p><p id="evs_01_0035__p99001247131718"><strong id="evs_01_0035__b1708526520162011">blkid</strong> <em id="evs_01_0035__i1458842329162011">Disk partition</em></p>
|
|
<p id="evs_01_0035__p3765815178">In this example, run the following command:</p>
|
|
<p id="evs_01_0035__p11896113281519"><strong id="evs_01_0035__b9289131013187">blkid /dev/vdb1</strong></p>
|
|
<pre class="screen" id="evs_01_0035__screen142881389248">[root@ecs-test-0001 ~]# blkid /dev/vdb1
|
|
/dev/vdb1: UUID="0b3040e2-1367-4abb-841d-ddb0b92693df" TYPE="ext4"</pre>
|
|
<p id="evs_01_0035__p1889743231517">In the command output, the <strong id="evs_01_0035__b051922918198">TYPE</strong> value is <strong id="evs_01_0035__b9725153118199">ext4</strong>, indicating that <strong id="evs_01_0035__b1870193414198">/dev/vdb1</strong>'s file system format is <strong id="evs_01_0035__b14956113621919">ext4</strong>.</p>
|
|
</p></li><li id="evs_01_0035__li116211321204"><span>Run the following command to view the file system status:</span><p><p id="evs_01_0035__p176219327208">ext*: <strong id="evs_01_0035__b946534714239">e2fsck -n</strong> <em id="evs_01_0035__i4129105002315">Disk partition</em></p>
|
|
<p id="evs_01_0035__p10113154732210">xfs: <strong id="evs_01_0035__b6606115715237">xfs_repair -n</strong> <em id="evs_01_0035__i156915210243">Disk partition</em></p>
|
|
<p id="evs_01_0035__p156212321200">In this example, the ext4 file system is used. Therefore, run the following command:</p>
|
|
<p id="evs_01_0035__p36223292011"><strong id="evs_01_0035__b18280163812314">e2fsck -n /dev/vdb1</strong></p>
|
|
<div class="p" id="evs_01_0035__p1162113202010">Information similar to the following is displayed:<pre class="screen" id="evs_01_0035__screen163052167259">[root@ecs-test-0001 ~]# e2fsck -n /dev/vdb1
|
|
e2fsck 1.42.9 (28-Dec-2013)
|
|
Warning! /dev/vdb1 is mounted.
|
|
Warning: skipping journal recovery because doing a read-only filesystem check.
|
|
/dev/vdb1: clean, 11/6553600 files, 459544/26214144 blocks</pre>
|
|
</div>
|
|
<p id="evs_01_0035__p18631932122018">If the file system status is <strong id="evs_01_0035__b1633615203278">clean</strong>, the file system is normal. Otherwise, rectify the faulty and then perform the capacity expansion.</p>
|
|
</p></li></ol>
|
|
</div>
|
|
<div class="section" id="evs_01_0035__section7627683297"><a name="evs_01_0035__section7627683297"></a><a name="section7627683297"></a><h4 class="sectiontitle">Method 2: Check Partition Style and File System Format Using parted</h4><ol id="evs_01_0035__ol98829579413"><li id="evs_01_0035__li62452961164027"><span>Run the following command to view all the disks attached to the <span id="evs_01_0035__text20805162723010">server</span>:</span><p><p id="evs_01_0035__p3438318916414"><strong id="evs_01_0035__b185408516411">lsblk</strong></p>
|
|
<div class="p" id="evs_01_0035__p5454788116416">Information similar to the following is displayed:<pre class="screen" id="evs_01_0035__screen11513730164145">[root@ecs-test-0001 ~]# lsblk
|
|
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
|
|
vda 253:0 0 40G 0 disk
|
|
└─vda1 253:1 0 40G 0 part /
|
|
vdb 253:16 0 150G 0 disk
|
|
└─vdb1 253:17 0 100G 0 part /mnt/sdc</pre>
|
|
</div>
|
|
<p id="evs_01_0035__p10211121533410">In this example, data disk <strong id="evs_01_0035__b530717142814">/dev/vdb</strong> already has partition <strong id="evs_01_0035__b6308101192814">/dev/vdb1</strong> before capacity expansion, and the additional 50 GiB added has not been allocated yet. Therefore, <strong id="evs_01_0035__b43080172820">/dev/vdb</strong> has 150 GiB, and <strong id="evs_01_0035__b3309516287">/dev/vdb1</strong> has 100 GiB.</p>
|
|
<div class="note" id="evs_01_0035__note655644391219"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="evs_01_0035__evs_01_0035_p1877914401139">If you run <strong id="evs_01_0035__evs_01_0035_b10269165412545">lsblk</strong> and find out that disk <strong id="evs_01_0035__evs_01_0035_b726955417543">/dev/vdb</strong> has no partitions, format the disk by referring to <a href="evs_faq_0073.html">How Do I Extend the File System of an Unpartitioned Data Disk in Linux?</a> and expand the capacity. Otherwise, the additional space cannot be used after expansion.</p>
|
|
</div></div>
|
|
</p></li><li id="evs_01_0035__li1188255724115"><span>Run the following command and enter <strong id="evs_01_0035__b842352706203657">p</strong> to view the disk partition style:</span><p><p id="evs_01_0035__p12882155764115"><strong id="evs_01_0035__b1025693618203712">parted</strong> <em id="evs_01_0035__i1926238006203712">Disk</em></p>
|
|
<p id="evs_01_0035__p53339869164347">For example, run the following command to view <strong id="evs_01_0035__b842352706203733">/dev/vdb</strong>'s partition style:</p>
|
|
<p id="evs_01_0035__p10864018164411"><strong id="evs_01_0035__b44426524164414">parted /dev/vdb</strong></p>
|
|
<div class="p" id="evs_01_0035__p11882057144110">Information similar to the following is displayed:<pre class="screen" id="evs_01_0035__screen135782815193">[root@ecs-test-0001 ~]# parted /dev/vdb
|
|
GNU Parted 3.1
|
|
Using /dev/vdb
|
|
Welcome to GNU Parted! Type 'help' to view a list of commands.
|
|
(parted) p
|
|
Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the
|
|
disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?
|
|
Fix/Ignore/Cancel? Fix
|
|
Warning: Not all of the space available to /dev/vdb appears to be used, you can fix the GPT to use all of the space (an extra 104857600
|
|
blocks) or continue with the current setting?
|
|
Fix/Ignore? Fix
|
|
Model: Virtio Block Device (virtblk)
|
|
Disk /dev/vdb: 161GiB
|
|
Sector size (logical/physical): 512B/512B
|
|
Partition Table: gpt
|
|
Disk Flags:
|
|
|
|
Number Start End Size File system Name Flags
|
|
1 1049kB 107GiB 107GiB ext4 test
|
|
|
|
(parted) </pre>
|
|
</div>
|
|
<div class="p" id="evs_01_0035__p47387560145229"><strong id="evs_01_0035__b7551103235017">Partition Table</strong> indicates the disk partition style. <strong id="evs_01_0035__b531592313580">Partition Table: msdos</strong> means MBR, <strong id="evs_01_0035__b13221941009">Partition Table: gpt</strong> means GPT, and <strong id="evs_01_0035__b97038485011">Partition Table: loop</strong> means that the whole disk is partitioned.<ul id="evs_01_0035__ul576616254336"><li id="evs_01_0035__li77667254332">If the following error information is displayed, enter <strong id="evs_01_0035__b205671610153013">Fix</strong>.<pre class="screen" id="evs_01_0035__screen1044151515313">Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system believes the
|
|
disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?</pre>
|
|
<p id="evs_01_0035__p1219425063112">The GPT partition table information is stored at the start of the disk. To reduce the risk of damage, a backup of the information is saved at the end of the disk. When you expand the disk capacity, the end of the disk changes accordingly. In this case, enter <strong id="evs_01_0035__b1912311713612">Fix</strong> to move the backup file of the information to new disk end.</p>
|
|
</li><li id="evs_01_0035__li866116694718">If the following warning information is displayed, enter <strong id="evs_01_0035__b78091630103715">Fix</strong>.<pre class="screen" id="evs_01_0035__screen1450718714591">Warning: Not all of the space available to /dev/vdb appears to be used, you can fix the GPT to use all of the space (an extra 104857600
|
|
blocks) or continue with the current setting?
|
|
Fix/Ignore? Fix</pre>
|
|
<p id="evs_01_0035__p2942122165910">Enter <strong id="evs_01_0035__b9518141113384">Fix</strong> as prompted. The system automatically sets the GPT partition style for the additional space.</p>
|
|
</li></ul>
|
|
</div>
|
|
</p></li><li id="evs_01_0035__li25527458164622"><span>Enter <strong id="evs_01_0035__b84235270620397">q</strong> and press <strong id="evs_01_0035__b842352706203910">Enter</strong> to exit parted.</span></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>
|
|
|