Linux VMware Extended Partition Capacity (Hard Disk Space)

I. VMware virtual machine settings

First open the virtual machine settings, then select the hard disk option, select the expansion option (E), set the expansion size (requires a shutdown state, and there can be no virtual machine snapshots), such as my original 80G, through the expansion to 120G. After this step, Linux has 40G free disks. But it’s just that VMware assigned the hard disk to the virtual machine, just like you added a hard disk to the computer, and you need to configure in the Linux system to make the hard disk space mount properly.

II. Create Partition

  1. Enter the following command in the terminal:
    fdisk /dev/sda

    Next, type p to view the partition information. The sample output is as follows:

    Command (m for help): p
    Disk /dev/sda: 128.8 GB, 128849018880 bytes
    255 heads, 63 sectors/track, 15665 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: 0x00044781
    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          64      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              64        2611    20458496   8e  Linux LVM
    /dev/sda3            2611        5221    20966162+  83  Linux
    /dev/sda4            5222       15665    83891430   83  Linux
  2. Create a partition. There are two cases:
    1). One is less than 4 primary partitions, then you can directly create partitions:
    In the fdisk command, enter n (new a partition) to enter the expansion and primary partition selection at this time. Enter p to select the primary partition. If you have 2 partitions before, then select the partition number 3; if there is If there are 3 partitions, the partition number is 4. Finally, you will be prompted to select the start and end addresses of the partition. Generally, you can choose the default direct carriage Enter key. At this time, you can enter p again to see the new partition just created.

    2). The second type has reached 4 partitions, you need to enter d, then enter 4 to delete the 4 partition, then enter n, enter p to select the main partition, and select the partition number Set it to 4 to re-create the 4 partition. At the end, you will be prompted to select the start address and end address of the partition. Select the default direct carriage return. At this time, enter p again to see the just created New partition, the sample output is as follows:
[root@test ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p        #View partition table information

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris
/dev/sda4            1497        2611     8952832   83  Linux

Command (m for help): d           #Delete partition
Partition number (1-4): 4         #Delete the fourth

Command (m for help): p       #Check the partition information again, /dev/sda4 has been deleted

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris

Command (m for help): n      #Create new partition
Command action
   e   extended
   p   primary partition (1-4)
p             #Create primary partition
Selected partition 4
First cylinder (1497-3916, default 1497):          #After comparison, it is exactly the same as the previous disk column.
Using default value 1497
Last cylinder, +cylinders or +size{K,M,G} (1497-3916, default 3916): 
Using default value 3916              #Enter directly by default

Command (m for help): p               #View partition table information

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x0005210c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        1301    10240000   83  Linux
/dev/sda3            1301        1497     1572864   82  Linux swap / Solaris
/dev/sda4            1497        3916    19436582   83  Linux

Command (m for help): wp       #Save and exit, if the creation is wrong, just exit without saving
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.
  1. Create Physical Volume (PV)
    According to the previous operation, it is also divided into two cases:
    1). If the partition is created directly, enter pvcreate /dev/sda3 to create a physical volume, then enter vgdisplay, check the current volume group (volumegroup), the result is VolGroup, and then enter vgextend /dev/mapper/VolGroup/dev/sda3 to add the new pv to the original vg

    [root@test ~]# vgdisplay 
    --- Volume group ---
    VG Name               VolGroup
    System ID             
    Format                lvm2
    Metadata Areas        3
    Metadata Sequence No  10
    VG Access             read/write
    VG Status             resizable
    MAX LV                0
    Cur LV                2
    Open LV               2
    Max PV                0
    Cur PV                3
    Act PV                3
    VG Size               119.50 GiB
    PE Size               4.00 MiB
    Total PE              30591
    Alloc PE / Size       29826 / 116.51 GiB
    Free  PE / Size       765 / 2.99 GiB
    VG UUID               qXs6MO-nsYe-ASBU-FS9f-e9Im-XId7-7iQD45

    2). If it is a re-created partition, enter pvresize /dev/sda4 --setphysicalvolumesize 80G to adjust the size of the physical volume. The size 80G is the adjusted size. You need to obtain the size of the sda4 physical volume according to pvdisplay 40G, and then add 40G, which is the size we increased this time, to 80G. The recreated partition does not need to add the physical volume PV to the VG, because it has been added before.

[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup
  PV Size               19.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              4994
  Free PE               0
  Allocated PE          4994
  PV UUID               8i4eDm-BIXi-2gz7-AROL-zinS-QeYE-2lJviN

  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               VolGroup
  PV Size               19.99 GiB / not usable 2.77 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              5118
  Free PE               0
  Allocated PE          5118
  PV UUID               N5z1G9-Qh6O-UoJo-Hweg-PLRy-Hr5Y-Q0lfPS

  --- Physical volume ---
  PV Name               /dev/sda4
  VG Name               VolGroup
  PV Size               80.00 GiB / not usable 3.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              20479
  Free PE               765
  Allocated PE          19714
  PV UUID               N4G0wG-cKp2-eIwU-hQXw-YKBo-2Wsk-iZLLsM
  1. Enlarge Logical Volume LV
    Expand the currently used (root file system) logical volume LV, take the remaining space from vg here is 40G, but if there is a reserved address, directly taking 40G will be wrong, so here I take 39G, the command is:

    lvextend -L +39G /dev/mapper/VolGroup-lv_root

    Among them, the LV name can be obtained by the df -h command:

    [root@localhost ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                      113G   69G   39G  64% /
    tmpfs                 931M  224K  931M   1% /dev/shm
    /dev/sda1             477M   84M  369M  19% /boot
  2. Update the file system
    Finally, enter the command:

    resize2fs  /dev/mapper/VolGroup-lv_root

    This step refreshed the file system size again, and then df -h again, you can see that the current root file system has increased by nearly 40G!

5 1 vote
Article Rating
赞(0) 打赏
未经允许不得转载:iemblog » Linux VMware Extended Partition Capacity (Hard Disk Space)
Subscribe
Notify of
guest

0 COMMENTS
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
免责声明:本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除,若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,与本站无关。本站发布的内容若侵犯到您的权益,请联系站长删除,我们将及时处理! Disclaimer: Most of the download resources on this site are collected on the Internet, and are only used for learning and communication. The copyright belongs to the original author. Please consciously delete within 24 hours after downloading. If you use it for commercial purposes, please purchase the original version. If the content posted on this site violates your rights, please contact us to delete it, and we will deal with it in time!

联系我们 Contact us

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

0
Would love your thoughts, please comment.x
()
x