Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to expand the capacity of CentOS partition in VMware virtual machine

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to expand the CentOS partition in the VMware virtual machine". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to expand the CentOS partition in the VMware virtual machine".

Due to the insufficient root partition planning of the development and test machine dev-vhost017, it is only 10G, so it needs to be expanded. (based on LVM)

Close dev-vhost017 first, and then adjust the root partition hard disk from 10g to 50g in vSphere Client

Turn on the virtual machine

Original / size 10G

The code is as follows:

[root@dev-vhost017] # df-h

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/vg_centos6-lv_root

8.3G 4.0G 3.9G 51% /

Tmpfs 939m 12K 939m 1% / dev/shm

/ dev/sda1 477M 57M 396M 13% / boot

Check that disk sda has been expanded to 50G

The code is as follows:

[root@dev-vhost017 ~] # 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

Disk / dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0007ef5b

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 1306 9972736 8e Linux LVM

Disk / dev/mapper/vg_centos6-lv_root: 9135 MB, 9135194112 bytes

255 heads, 63 sectors/track, 1110 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk / dev/mapper/vg_centos6-lv_swap: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

View lvm status

The code is as follows:

[root@dev-vhost017 ~] # pvs

PV VG Fmt Attr PSize PFree

/ dev/sda2 vg_centos6 lvm2 a muri-9.51g 0

The code is as follows:

[root@dev-vhost017 ~] # vgs

VG # PV # LV # SN Attr VSize VFree

Vg_centos6 1 2 0 wz--n- 9.51g 0

The code is as follows:

[root@dev-vhost017 ~] # lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

Lv_root vg_centos6-wi-ao---- 8.51g

Lv_swap vg_centos6-wi-ao---- 1.00g

Partition / dev/sda3

The code is as follows:

[root@dev-vhost017 ~] # 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

Disk / dev/sda: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0007ef5b

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 1306 9972736 8e Linux LVM

/ dev/sda3 1306 6527 41942367 + 83 Linux

The code is as follows:

[root@dev-vhost017 ~] # partprobe

Restart virtual machine formatting / dev/sda3

The code is as follows:

[root@dev-vhost017 ~] # mkfs.ext4 / dev/sda3

Lvm capacity expansion

The code is as follows:

[root@dev-vhost017 ~] # pvcreate / dev/sda3

Physical volume "/ dev/sda3" successfully created

The code is as follows:

[root@dev-vhost017 ~] # pvs

PV VG Fmt Attr PSize PFree

/ dev/sda2 vg_centos6 lvm2 a muri-9.51g 0

/ dev/sda3 lvm2-40.00g 40.00g

The code is as follows:

[root@dev-vhost017 ~] # vgextend / dev/mapper/vg_centos6 / dev/sda3 (note the group name)

Volume group "vg_centos6" successfully extended

The code is as follows:

[root@dev-vhost017] # lvextend-L 39.9G / dev/vg_centos6/lv_root / dev/sda3

Rounding size to boundary between physical extents: 39.90 GiB

Size of logical volume vg_centos6/lv_root changed from 8.51 GiB (2178 extents) to 39.90 GiB (10215 extents).

Logical volume lv_root successfully resized

The code is as follows:

[root@dev-vhost017 ~] # resize2fs / dev/vg_centos6/lv_root

Resize2fs 1.41.12 (17-May-2010)

Filesystem at / dev/vg_centos6/lv_root is mounted on /; on-line resizing required

Old desc_blocks = 1, new_desc_blocks = 3

Performing an on-line resize of / dev/vg_centos6/lv_root to 10460160 (4k) blocks.

The filesystem on / dev/vg_centos6/lv_root is now 10460160 blocks long.

The code is as follows:

[root@dev-vhost017 ~] # pvs

PV VG Fmt Attr PSize PFree

/ dev/sda2 vg_centos6 lvm2 a muri-9.51g 0

/ dev/sda3 vg_centos6 lvm2 a muri-40.00g 8.60g

The code is as follows:

[root@dev-vhost017 ~] # vgs

VG # PV # LV # SN Attr VSize VFree

Vg_centos6 2 2 0 wz--n- 49.50g 8.60g

The code is as follows:

[root@dev-vhost017 ~] # lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

Lv_root vg_centos6-wi-ao---- 39.90g

Lv_swap vg_centos6-wi-ao---- 1.00g

The code is as follows:

[root@dev-vhost017] # df-h

Filesystem Size Used Avail Use% Mounted on

/ dev/mapper/vg_centos6-lv_root

40G 4.0G 34G 11% /

Tmpfs 939m 12K 939m 1% / dev/shm

/ dev/sda1 477M 57M 396M 13% / boot

Thank you for reading, the above is the content of "how to expand the CentOS partition in the VMware virtual machine". After the study of this article, I believe you have a deeper understanding of how to expand the capacity of the CentOS partition in the VMware virtual machine, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report