日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VMware虚拟机中CentOS根分区的扩展

發布時間:2025/5/22 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VMware虚拟机中CentOS根分区的扩展 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

摘自《VM虛擬機中Linux擴展根分區空間》,百度文庫鏈接,如有侵權,請聯系告知。

必須是基于“卷管理”的才能夠擴展分區。

[root@SQL2 ~]# lvdisplay

如果能看到“物理卷”和“邏輯卷”,說明OK。

1.VMware擴展
在關機狀態下,點擊“硬盤->擴展”,然后輸入大小(從50GB改到80GB),點擊確定。

2.開啟虛擬機

[root@SQL2 ~]# df -h

發現沒有改變

3.用命令查看sda已經擴展

[root@SQL2 ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 sectors

4.查看lvm狀態

[root@SQL2 ~]# pvsPV VG Fmt Attr PSize PFree/dev/sda2 centos lvm2 a-- 49.51g 44.00m [root@SQL2 ~]# vgsVG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz--n- 49.51g 44.00m [root@SQL2 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 45.59gswap centos -wi-ao---- 3.88g

5.生成分區/dev/sda3

[root@SQL2 ~]# fdisk /dev/sdaWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x0006069d Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 104857599 51915776 8e Linux LVM Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 First sector (104857600-167772159, default 104857600): #回車 Using default value 104857600 Last sector, +sectors or +size{K,M,G} (104857600-167772159, default 167772159): #回車 Using default value 167772159 Partition 3 of type Linux and of size 30 GiB is set Command (m for help): w 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.

6.重讀磁盤分區

[root@SQL2 ~]# partprobe

如果不行就重啟reboot

7.格式化/dev/sda3

[root@SQL2 ~]# mkfs.ext4 /dev/sda3 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1966080 inodes, 7864320 blocks 393216 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2155872256 240 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done

8.lvm 擴容

[root@SQL2 ~]# pvcreate /dev/sda3 WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y Wiping ext4 signature on /dev/sda3. Physical volume "/dev/sda3" successfully created [root@SQL2 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- 49.51g 44.00m #標紅為組名,下步會用到 /dev/sda3 lvm2 --- 30.00g 30.00g [root@SQL2 ~]# vgextend centos /dev/sda3 #(注意組名) Volume group "centos" successfully extended #此處+29.9表示大約擴展30G空間,若是此處設置為80G 也是可行,表示擴展后總容量 [root@SQL2 ~]# lvextend -L +29.9G /dev/mapper/centos-root /dev/sda3 Rounding size to boundary between physical extents: 29.90 GiB Size of logical volume centos/root changed from 45.59 GiB (11671 extents) to 75.49 GiB (19326 extents). Logical volume root successfully resized. #若此處報錯,可以不管,執行下個resize2fs命令,若正確,可忽略resize2fs命令 [root@SQL2 ~]# resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock. [root@SQL2 ~]# resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock. [root@SQL2 ~]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=2987776 blks= sectsz=512 attr=2, projid32bit=1 data = bsize=4096 blocks=11951104, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=5835, version=2= sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 11951104 to 19789824 [root@SQL2 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 76G 12G 65G 15% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 84K 1.9G 1% /dev/shm tmpfs 1.9G 9.0M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 159M 339M 32% /boot tmpfs 379M 16K 379M 1% /run/user/42 tmpfs 379M 0 379M 0% /run/user/0

已經成功。

總結

以上是生活随笔為你收集整理的VMware虚拟机中CentOS根分区的扩展的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。