本篇內(nèi)容主要講解“如何給centos系統(tǒng)擴(kuò)展磁盤分區(qū)”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“如何給centos系統(tǒng)擴(kuò)展磁盤分區(qū)”吧!
成都創(chuàng)新互聯(lián)成都網(wǎng)站建設(shè)按需搭建網(wǎng)站,是成都網(wǎng)站建設(shè)公司,為成都花箱提供網(wǎng)站建設(shè)服務(wù),有成熟的網(wǎng)站定制合作流程,提供網(wǎng)站定制設(shè)計(jì)服務(wù):原型圖制作、網(wǎng)站創(chuàng)意設(shè)計(jì)、前端HTML5制作、后臺(tái)程序開發(fā)等。成都網(wǎng)站改版熱線:13518219792
問題/故障/場(chǎng)景/需求
eve-ng的虛擬機(jī)ova的硬盤只有38g,需要增加空間,在vmware直接擴(kuò)展硬盤后,重啟系統(tǒng),使用fdisk -l可以看到硬盤擴(kuò)大了,但文件系統(tǒng)并沒有擴(kuò)大,還需要將這些新增的空間擴(kuò)展分配到某個(gè)文件系統(tǒng)才行。下面記錄了整個(gè)擴(kuò)展過程
解決方法/步驟
在vm里擴(kuò)大磁盤到250g重啟系統(tǒng)后,查看當(dāng)前的文件系統(tǒng)的情況
root@eve-ng:~# df -h filesystem size used avail use% mounted on udev 7.9g 0 7.9g 0% /dev tmpfs 1.6g 19m 1.6g 2% /run /dev/mapper/eve--ng--vg-root 38g 13g 23g 36% / tmpfs 7.9g 0 7.9g 0% /dev/shm tmpfs 5.0m 0 5.0m 0% /run/lock tmpfs 7.9g 0 7.9g 0% /sys/fs/cgroup /dev/sda1 472m 83m 365m 19% /boot root@eve-ng:~# fdisk -l ...省略部分內(nèi)容 disk /dev/sda: 250 gib, 268435456000 bytes, 524288000 sectors //可以看到已經(jīng)有250g了 units: sectors of 1 * 512 = 512 bytes sector size (logical/physical): 512 bytes / 512 bytes i/o size (minimum/optimal): 512 bytes / 512 bytes disklabel type: dos disk identifier: 0x3e3ca055 device 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 1001472 83884031 82882560 39.5g 8e linux lvm disk /dev/mapper/eve--ng--vg-root: 38.6 gib, 41406169088 bytes, 80871424 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 /dev/mapper/eve--ng--vg-swap_1: 980 mib, 1027604480 bytes, 2007040 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 //下面執(zhí)行分區(qū) root@eve-ng:~# fdisk /dev/sda welcome 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): n partition type p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) select (default p): p partition number (3,4, default 3): 3 first sector (999424-524287999, default 999424): 83884032 //注意,這里是之前分配的最后一塊(sda5 end)加一(83884031+1) last sector, +sectors or +size{k,m,g,t,p} (83884032-524287999, default 524287999): //注意看這是不是最后一塊 created a new partition 3 of type 'linux' and of size 210 gib. command (m for help): t partition number (1-3,5, default 5): 3 3 partition type (type l to list all types): 8e changed type of partition 'linux' to 'linux lvm'. command (m for help): w the partition table has been altered. calling ioctl() to re-read partition table. re-reading the partition table failed.: 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). root@eve-ng:~# reboot root@eve-ng:~# pvcreate /dev/sda3 physical volume "/dev/sda3" successfully created root@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-q8zxki root@eve-ng:~# vgextend eve-ng-vg /dev/sda3 volume group "eve-ng-vg" successfully extended root@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-q8zxki root@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:0 //擴(kuò)展邏輯卷 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 -h filesystem size used avail use% mounted on udev 7.9g 0 7.9g 0% /dev tmpfs 1.6g 19m 1.6g 2% /run /dev/mapper/eve--ng--vg-root 38g 13g 23g 36% / tmpfs 7.9g 0 7.9g 0% /dev/shm tmpfs 5.0m 0 5.0m 0% /run/lock tmpfs 7.9g 0 7.9g 0% /sys/fs/cgroup /dev/sda1 472m 83m 365m 19% /boot //在線擴(kuò)容,要先查看當(dāng)前的文件系統(tǒng)的類型,可以通過cat /etc/fstab來查看 root@eve-ng:~# resize2fs /dev/eve-ng-vg/root resize2fs 1.42.13 (17-may-2015) filesystem at /dev/eve-ng-vg/root is mounted on /; on-line resizing required old_desc_blocks = 3, new_desc_blocks = 16 the filesystem on /dev/eve-ng-vg/root is now 65159168 (4k) blocks long. root@eve-ng:~# df -h filesystem size used avail use% mounted on udev 7.9g 0 7.9g 0% /dev tmpfs 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/shm tmpfs 5.0m 0 5.0m 0% /run/lock tmpfs 7.9g 0 7.9g 0% /sys/fs/cgroup /dev/sda1 472m 83m 365m 19% /boot
到此,相信大家對(duì)“如何給centos系統(tǒng)擴(kuò)展磁盤分區(qū)”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!