詳解Centos7擴展磁盤空間(LVM管理)
本文介紹了Centos7擴展磁盤空間(LVM管理),分享給大家,具體如下:
查看磁盤情況
# fdisk -l /dev/sda Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x00063fa6 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 20971519 9972736 8e Linux LVM /dev/sda3 20971520 41943039 10485760 8e Linux LVM
現(xiàn)在,磁盤大小為 21.5 GB。磁盤占用情況為:
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 19G 8.1G 11G 44% / devtmpfs 482M 0 482M 0% /dev tmpfs 497M 88K 497M 1% /dev/shm tmpfs 497M 7.0M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/sda1 497M 157M 341M 32% /boot Share 103G 36G 67G 35% /media/sf_Share tmpfs 100M 4.0K 100M 1% /run/user/42 tmpfs 100M 12K 100M 1% /run/user/0
試試看用 dd 命令創(chuàng)建一個大小為 1GB 的塊文件:
# dd if=/dev/zero of=1.0G.img bs=1M count=1000 dd: writing `1.0G.img': No space left on device 1+0 records in 0+0 records out 8192 bytes (8.2 kB) copied, 0.00300509 s, 2.7 MB/s
提示磁盤空間不足,說明,雖然已給虛擬機分配了足夠的空間,但是系統(tǒng)并不識別該空間。
下面調(diào)整虛擬機操作系統(tǒng)的文件系統(tǒng),使之識別新增的空間
1.創(chuàng)建新的分區(qū)
# fdisk /dev/sda n {new partition} p {primary partition} 3 {partition number} [這時會提示修改大小,選擇默認直接回車即可] t {change partition id} 3 {partition number} 8e {Linux LVM partition} w
如果中間有設置大小之類的提示,就直接回車。
完成后,如果提示:
PS:經(jīng)實際測試,無此提示,但還是要重啟系統(tǒng),看看是否已識別該磁盤空間。
WARNING: Re-reading the partition table failed with error 16: 設備或資源忙. 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)
就重啟一下系統(tǒng)。
2.查看新增加的sda3是否標記為LVM,如果沒有需要reboot
PS:經(jīng)實際測試,sda3已經(jīng)是LVM了,但系統(tǒng)還是不識別該磁盤空間。
3.調(diào)整LVM大小
查看Volume Group名稱
# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2
4.為新分配的空間創(chuàng)建一個新的物理卷
#pvcreate /dev/sda3
5.使用新的物理卷來擴展 LVM 的 VolGroup
# vgextend centos /dev/sda3 No physical volume label read from /dev/sda3 Writing physical volume data to disk "/dev/sda3" Physical volume "/dev/sda3" successfully created Volume group "vg_aimin" successfully extended
6.擴展 LVM 的邏輯卷 centos-root
先查看邏輯卷:
# lvdisplay --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos
# lvextend /dev/centos/root /dev/sda3
7.調(diào)整邏輯卷的大小
# xfs_growfs /dev/centos/root
PS:不知道是調(diào)整還是同步,經(jīng)實際測試需要用xfs_growfs命令,而非resize2fs命令
8.查看結(jié)果
# lvscan ACTIVE '/dev/centos/root' [18.46 GiB] inherit ACTIVE '/dev/centos/swap' [1.00 GiB] inherit
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
PHP程序員玩轉(zhuǎn)Linux系列 使用supervisor實現(xiàn)守護進程
這篇文章主要為大家詳細介紹了PHP程序員玩轉(zhuǎn)Linux系列文章,使用supervisor實現(xiàn)守護進程,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-04-04詳解如何在Linux中重置MySQL或者MariaDB的root密碼
本篇文章主要介紹了如何在 Linux 中重置 MySQL 或者 MariaDB 的 root 密碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-03-03解決Vmware虛擬機安裝centos8報錯“Section?%Packages?Does?Not?End?W
這篇文章介紹了解決Vmware虛擬機安裝centos8報錯“Section?%Packages?Does?Not?End?With?%End.?Pane?Is?Dead”的方法,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-05-05