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 extend disk Partition for centos system

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to extend disk partitions to the centos system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to expand the disk partition of the centos system.

Problem / failure / scenario / requirement

Eve-ng 's virtual machine ova has a hard disk of only 38g, which requires additional space. After vmware expands the hard disk directly, restart the system and use fdisk-l to see that the hard disk has expanded, but the file system has not expanded. You also need to allocate these new space extensions to a file system. The whole expansion process is recorded below.

Solution / step

After expanding the disk to 250g in vm, restart the system and check the current file system.

Root@eve-ng:~# df-hfilesystem size used avail use% mounted onudev 7.9g 0 7.9g 0% / devtmpfs 1.6g 19m 1.6g 2% / run/dev/mapper/eve--ng--vg-root 38g 13g 23g 36% / tmpfs 7.9g 07.9g 0% / dev/shmtmpfs 5.0m 05.0m 0% / Run/locktmpfs 7.9g 07.9g 0% / sys/fs/cgroup/dev/sda1 472m 83m 365m 19% / bootroot@eve-ng:~# fdisk-1. Omit part of the content disk / dev/sda: 250gib, 268435456000 bytes 524288000 sectors / / you can see that there are 250 g units: sectors of 1 * 512 = 512 bytessector size (logical/physical): 512 bytes / 512 bytesi/o size (minimum/optimal): 512 bytes / 512 bytesdisklabel type: dosdisk identifier: 0x3e3ca055device boot start end sectors size id type/dev/sda1 * 2048 999423 997376 487m 83 linux/dev/sda2 1001470 83884031 82882562 39.5g 5 extended/dev/sda5 10014783884031 82882560 39.5g linux lvmdisk / dev/mapper/eve--ng--vg-root: 38.6gib, 41406169088 bytes 80871424 sectorsunits: sectors of 1 * 512 = 512 bytessector size (logical/physical): 512 bytes / 512 bytesi/o size (minimum/optimal): 512 bytes / 512 bytesdisk / dev/mapper/eve--ng--vg-swap_1: 980 mib, 1027604480 bytes 2007040 sectorsunits: sectors of 1 * 512 = 512 bytessector size (logical/physical): 512 bytes/ 512 bytesi/o size (minimum/optimal): 512 bytes/ 512 bytes// execute partition root@eve-ng:~# fdisk / dev/sdawelcome to fdisk (util-linux 2.27.1) .changes will remain in memory only, until you decide to write them.be careful before using the write command.command (m for help): npartition type p primary (1 primary, 1 extended) 2 free) l logical (numbered from 5) select (default p): ppartition number (3Jing 4, default 3): 3first sector (999424-524287999, default 999424): 83884032 / / attention Here is the last piece allocated before (sda5 end) plus one (83884031 / 1) last sector, + sectors or + size {k gib.command (83884032-524287999, default 524287999): / / pay attention to whether this is the last piece created a new partition 3 of type 'linux' and of size 210 gib.command (m for help): tpartition number (1-3 gib.command 5) Default 5): 3 3partition type (type l to list all types): 8echanged type of partition 'linux' to' linux lvm'.command (m for help): wthe partition table has been altered.calling ioctl () to re-read partition table.re-reading the partition table failed.: device or resource busythe 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). Root@eve-ng:~# rebootroot@eve-ng:~# pvcreate / dev/sda3 physical volume "/ dev/sda3" successfully createdroot@eve-ng:~# vgdisplay-volume group-vg name eve-ng-vg system id format lvm2 metadata areas 1 metadata sequence no 3 vg access read/write vg status resizable max lv 0 cur lv 2 open lv 2 max pv 0 cur pv 1 act pv 1 vg size 39.52 gib pe size 4.00 mib total pe 10117 alloc pe / size 10117 / 39.52 gib free pe / size 0 / 0 vg uuid evwubc-nfsg-dhqa-znxb-u3gv-v782-q8zxkiroot@eve-ng:~# vgextend eve-ng-vg / dev/sda3 volume group "eve-ng-vg" successfully extendedroot@eve-ng: ~ # vgdisplay-volume group-vg name eve-ng-vg system id format lvm2 metadata areas 2 metadata sequence no 4 vg access read/write vg status resizable max lv 0 cur lv 2 open lv 2 max pv 0 cur pv 2 act pv 2 vg size 249.52 gib pe size 4.00 mib total pe 63877 alloc pe / size 10117 / 39.52 Gib free pe / size 53760 / 210.00 gib vg uuid evwubc-nfsg-dhqa-znxb-u3gv-v782-q8zxkiroot@eve-ng:~# lvdisplay-logical volume-lv path / dev/eve-ng-vg/root lv name root vg name eve-ng-vg lv uuid ktupr0-vpqs-rjjv-a1fc-u6gd-u8yn-2wyq53 lv write access read/write lv creation host Time eve-ng 2018-03-21 02:25:21 + 0200 lv status available # open 1 lv size 38.56 gib current le 9872 segments 1 allocation inherit read ahead sectors auto-currently set to 256 block device 253 gib / extended logical volume root@eve-ng:~# lvextend-l + 100%free / dev/eve-ng-vg/root size of logical volume eve-ng-vg/root changed from 38.56 gib (9872 extents) to 248.56 gib (63632 extents). Logical volume root successfully resized.root@eve-ng:~# df-hfilesystem size used avail use% mounted onudev 7.9g 0 7.9g 0% / devtmpfs 1.6g 19m 1.6g 2% / run/dev/mapper/eve--ng--vg-root 38g 13g 23g 36% / tmpfs 7.9g 07.9g 0% / dev/shmtmpfs 5.0m 0 5 .0m 0% / run/locktmpfs 7.9g 0 7.9g 0% / sys/fs/cgroup/dev/sda1 472m 83m 365m 19% / boot// online expansion To check the type of the current file system first You can view root@eve-ng:~# resize2fs / dev/eve-ng-vg/rootresize2fs 1.42.13 (17-may-2015) filesystem at / dev/eve-ng-vg/root is mounted on / at cat / etc/fstab. On-line resizing requiredold_desc_blocks = 3 New_desc_blocks = 16the filesystem on / dev/eve-ng-vg/root is now 65159168 (4k) blocks long.root@eve-ng:~# df-hfilesystem size used avail use% mounted onudev 7.9g 0 7.9g 0 / devtmpfs 1.6g 19m 1.6g 2% / run/dev/mapper/eve--ng--vg-root 245g 13g 222g 6% / tmpfs 7.9g 0 7.9g 0% / dev/shmtmpfs 5.0m 0 5.0m 0% / run/locktmpfs 7.9g 0 7.9g 0% / sys/fs/cgroup/dev/sda1 472m 83m 365m 19% / boot so far I believe you have a deeper understanding of "how to extend disk partitions to the centos system", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Internet Technology

Wechat

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

12
Report