esxi01磁盘扩容_给EXSI虚拟机中linux硬盘扩容
給EXSI虛擬機中l(wèi)inux硬盤擴容
將硬盤1從6G擴充到10G
查看目前磁盤狀態(tài)
[root@csvn ~]# df -h
Filesystem Size Used Avail Use%Mounted on
devtmpfs 484M0 484M 0% /dev
tmpfs 496M0 496M 0% /dev/shm
tmpfs 496M7.1M 489M 2% /run
tmpfs 496M0 496M 0% /sys/fs/cgroup/dev/mapper/centos-root 4.9G 2.9G 2.1G 59% /
/dev/sdb1 4.8G 21M 4.6G 1% /data/dev/sda1 497M 154M 344M 31% /boot
tmpfs 100M0 100M 0% /run/user/1001tmpfs 100M0 100M 0% /run/user/0
[root@csvn ~]# fdisk -l
Disk/dev/sda: 10.7 GB, 10737418240 bytes, 20971520sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier:0x000c208bDevice Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83Linux/dev/sda2 1026048 12582911 57784328e Linux LVM
Disk/dev/sdb: 5368 MB, 5368709120 bytes, 10485760sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier:0xc42fca3dDevice Boot Start End Blocks Id System/dev/sdb1 2048 10485759 5241856 83Linux
Disk/dev/mapper/centos-root: 5226 MB, 5226102784 bytes, 10207232sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk/dev/mapper/centos-swap: 645 MB, 645922816 bytes, 1261568sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
可看到磁盤/dev/sda大小已經(jīng)變成10.7GB
開始擴容
[root@csvn ~]# 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): 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 (12582912-20971519, default 12582912):
Using default value 12582912
Last sector, +sectors or +size{K,M,G} (12582912-20971519, default 20971519):
Using default value 20971519
Partition 3 of type Linux and of size 4 GiB is set
Command (m for help): t? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ???(修改分區(qū)類型為 Linux LVM, 8e)
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): wq
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.
再次查看磁盤狀態(tài),可見新的sda3,表示為可用狀態(tài)
[root@csvn ~]# fdisk -l
Disk/dev/sda: 10.7 GB, 10737418240 bytes, 20971520sectors
Units= sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disk label type: dos
Disk identifier:0x000c208bDevice Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83Linux/dev/sda2 1026048 12582911 57784328e Linux LVM/dev/sda3 12582912 20971519 4194304 8e Linux LVM
用partprobe重新讀取分區(qū)信息
ps:使用fdisk工具只是將分區(qū)信息寫到磁盤,如果需要mkfs磁盤分區(qū)則需要重啟系統(tǒng),而使用partprobe則可以使kernel重新讀取分區(qū)信息,從而避免重啟系統(tǒng).
[root@csvn ~]# partprobe /dev/sda3
創(chuàng)建物理卷及加入組
[root@csvn ~]# pvcreate /dev/sda3
Physical volume"/dev/sda3"successfully created
[root@csvn~]# vgextend centos /dev/sda3
Volume group"centos" successfully extended
查看物理卷情況
[root@csvn ~]# lvextend
No command with matching syntax recognised. Run'lvextend --help' formore information.
[root@csvn~]#
[root@csvn~]# lvextend /dev/mapper/centos-root
No command with matching syntax recognised. Run'lvextend --help' formore information.
[root@csvn~]#
[root@csvn~]# vgdisplay--- Volume group ---VG Name centos
System ID
Format lvm2
Metadata Areas2Metadata Sequence No6VG Access read/write
VG Status resizable
MAX LV0Cur LV2Open LV2Max PV0Cur PV2Act PV2VG Size5.50GiB
PE Size4.00GiB
Total PE2433Alloc PE/ Size 2424 / <9.47GiB
Free PE/ Size 9 / 4.00GiB
VG UUID rQ55Rt-cdp0-Z177-4RaC-e5PN-7dU2-WTRCDO
擴容
[root@csvn ~]# lvresize -L +4G /dev/mapper/centos-root
Extending logical volume LogVol00 to8.9G GB
Logical volume/centos-root successfully resized
同步文件系統(tǒng)
[root@csvn ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=318976blks= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0data= bsize=4096 blocks=1275904, imaxpct=25
= sunit=0 swidth=0blks
naming=version 2 bsize=4096 ascii-ci=0 ftype=0log=internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1realtime=none extsz=4096 blocks=0, rtextents=0data blocks changedfrom 1275904 to 2324480
驗證
[root@csvn ~]# df -h
Filesystem Size Used Avail Use%Mounted on
devtmpfs 484M0 484M 0% /dev
tmpfs 496M0 496M 0% /dev/shm
tmpfs 496M7.1M 489M 2% /run
tmpfs 496M0 496M 0% /sys/fs/cgroup/dev/mapper/centos-root 8.9G 2.9G 6.1G 33% /
/dev/sdb1 4.8G 21M 4.6G 1% /data/dev/sda1 497M 154M 344M 31% /boot
tmpfs 100M0 100M 0% /run/user/0tmpfs 100M0 100M 0% /run/user/1001
成功擴容
報錯
Can't initialize physical volume(無法初始化的物理量)
[root@csvn ~]# pvcreate /dev/sda3
Can't initialize physical volume "/dev/sda3" of volume group "centos" without -ff
/dev/sda3: physical volume not initialized.
[root@csvn~]#
檢查后得知,之前按照常規(guī)流程創(chuàng)建過LVM:/dev/centos/sda3,而沒有卸載掉。
解決方法:
方法一:
按順序先后卸載邏輯卷、卷組(必要時還要卸載物理卷):
lvremove /dev/...邏輯卷
vgremove?卷組
成功卸載后再重新執(zhí)行sudo pvcreate /dev/cciss/c0d1p1,不再有錯誤發(fā)生。
接著執(zhí)行后續(xù)動作來創(chuàng)建LVM。
方法二:
pvcreate -ff -y /dev/sda3
因為我是擴充根目錄的,根目錄卷組無法卸載,所以這個方法不適用。
[root@csvn ~]# partprobe
Warning: Unable to open/dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
/dev/sr0是你的光驅(qū)(CD Drive),因為你運行partprobe時沒有指定設(shè)備,所以它會檢查所有的塊設(shè)備(block devices),由于光驅(qū)是read-only,所以報上述告警信息,其實避免這個錯誤也很簡單,你只需要使用partprobe檢查、掃描指定設(shè)備即可。
[root@csvn ~]# partprobe /dev/sda3
[root@csvn ~]# resize2fs /dev/mapper/centos-root
resize2fs1.42.9 (28-Dec-2013)
resize2fs: Bad magic numberin super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock.
[root@csvn ~]#
resize2fs
調(diào)整ext2\ext3\ext4文件系統(tǒng)的大小,它可以放大或者縮小沒有掛載的文件系統(tǒng)的大小。如果文件系統(tǒng)已經(jīng)掛載,它可以擴大文件系統(tǒng)的大小,前提是內(nèi)核支持在線調(diào)整大小。
擴容/目錄后,df -h查看,卻沒有擴容到。重啟也不行,百度說umout目錄重新擴容試試,但根目錄不可能umout的。
具體再百度發(fā)現(xiàn),(由于CentOS6和CentOS7在默認根文件系統(tǒng)的文件系統(tǒng)格式存在差異,需要判斷是否為xfs,如果是xfs則應(yīng)該使用xfs_growfs而不是一味的使用resize2fs。)
Linux7文件系統(tǒng)格式是xfs,resize2fs命令是讀取不了的。
所以要用xfs_growfs來同步文件系統(tǒng)。
[root@csvn ~]# df -h
Filesystem Size Used Avail Use%Mounted on
devtmpfs 484M0 484M 0% /dev
tmpfs 496M0 496M 0% /dev/shm
tmpfs 496M7.1M 489M 2% /run
tmpfs 496M0 496M 0% /sys/fs/cgroup/dev/mapper/centos-root 4.9G 2.9G 2.1G 59% /
/dev/sdb1 4.8G 21M 4.6G 1% /data/dev/sda1 497M 154M 344M 31% /boot
tmpfs 100M0 100M 0% /run/user/0tmpfs 100M0 100M 0% /run/user/1001[root@csvn~]#
[root@csvn~]#
[root@csvn~]#
[root@csvn~]# xfs_info /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=318976blks= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0data= bsize=4096 blocks=1275904, imaxpct=25
= sunit=0 swidth=0blks
naming=version 2 bsize=4096 ascii-ci=0 ftype=0log=internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1realtime=none extsz=4096 blocks=0, rtextents=0[root@csvn~]#
用xfs_growfs來同步文件系
[root@csvn ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=318976blks= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0data= bsize=4096 blocks=1275904, imaxpct=25
= sunit=0 swidth=0blks
naming=version 2 bsize=4096 ascii-ci=0 ftype=0log=internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1realtime=none extsz=4096 blocks=0, rtextents=0data blocks changedfrom 1275904 to 2324480[root@csvn~]#
[root@csvn~]#
[root@csvn~]#
[root@csvn~]# df -h
Filesystem Size Used Avail Use%Mounted on
devtmpfs 484M0 484M 0% /dev
tmpfs 496M0 496M 0% /dev/shm
tmpfs 496M7.1M 489M 2% /run
tmpfs 496M0 496M 0% /sys/fs/cgroup/dev/mapper/centos-root 8.9G 2.9G 6.1G 33% /
/dev/sdb1 4.8G 21M 4.6G 1% /data/dev/sda1 497M 154M 344M 31% /boot
tmpfs 100M0 100M 0% /run/user/0tmpfs 100M0 100M 0% /run/user/1001[root@csvn~]#
可看到已成功擴容根目錄。
附錄:
xfs_admin: 調(diào)整 xfs 文件系統(tǒng)的各種參數(shù)
xfs_copy: 拷貝 xfs 文件系統(tǒng)的內(nèi)容到一個或多個目標(biāo)系統(tǒng)(并行方式)
xfs_db: 調(diào)試或檢測 xfs 文件系統(tǒng)(查看文件系統(tǒng)碎片等)
xfs_check: 檢測 xfs 文件系統(tǒng)的完整性
xfs_bmap: 查看一個文件的塊映射
xfs_repair: 嘗試修復(fù)受損的 xfs 文件系統(tǒng)
xfs_fsr: 碎片整理
xfs_quota: 管理 xfs 文件系統(tǒng)的磁盤配額
xfs_metadump: 將 xfs 文件系統(tǒng)的元數(shù)據(jù) (metadata) 拷貝到一個文件中
xfs_mdrestore: 從一個文件中將元數(shù)據(jù) (metadata) 恢復(fù)到 xfs 文件系統(tǒng)
xfs_growfs: 調(diào)整一個 xfs 文件系統(tǒng)大小(只能擴展)
xfs_freeze? ? 暫停(-f)和恢復(fù)(-u)xfs 文件系統(tǒng)
xfs_logprint: 打印xfs文件系統(tǒng)的日志
xfs_mkfile: 創(chuàng)建xfs文件系統(tǒng)
xfs_info: 查詢文件系統(tǒng)詳細信息
xfs_ncheck: generate pathnames from i-numbers for XFS
xfs_rtcp: XFS實時拷貝命令
xfs_io: 調(diào)試xfs I/O路徑
總結(jié)
以上是生活随笔為你收集整理的esxi01磁盘扩容_给EXSI虚拟机中linux硬盘扩容的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LUK-Triumphal arch
- 下一篇: pos收银系统 php,POS收银系统