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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

esxi01磁盘扩容_给EXSI虚拟机中linux硬盘扩容

發布時間:2023/12/18 linux 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 esxi01磁盘扩容_给EXSI虚拟机中linux硬盘扩容 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

給EXSI虛擬機中linux硬盤擴容

將硬盤1從6G擴充到10G

查看目前磁盤狀態

[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大小已經變成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? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ???(修改分區類型為 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.

再次查看磁盤狀態,可見新的sda3,表示為可用狀態

[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重新讀取分區信息

ps:使用fdisk工具只是將分區信息寫到磁盤,如果需要mkfs磁盤分區則需要重啟系統,而使用partprobe則可以使kernel重新讀取分區信息,從而避免重啟系統.

[root@csvn ~]# partprobe /dev/sda3

創建物理卷及加入組

[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

同步文件系統

[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~]#

檢查后得知,之前按照常規流程創建過LVM:/dev/centos/sda3,而沒有卸載掉。

解決方法:

方法一:

按順序先后卸載邏輯卷、卷組(必要時還要卸載物理卷):

lvremove /dev/...邏輯卷

vgremove?卷組

成功卸載后再重新執行sudo pvcreate /dev/cciss/c0d1p1,不再有錯誤發生。

接著執行后續動作來創建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是你的光驅(CD Drive),因為你運行partprobe時沒有指定設備,所以它會檢查所有的塊設備(block devices),由于光驅是read-only,所以報上述告警信息,其實避免這個錯誤也很簡單,你只需要使用partprobe檢查、掃描指定設備即可。

[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

調整ext2\ext3\ext4文件系統的大小,它可以放大或者縮小沒有掛載的文件系統的大小。如果文件系統已經掛載,它可以擴大文件系統的大小,前提是內核支持在線調整大小。

擴容/目錄后,df -h查看,卻沒有擴容到。重啟也不行,百度說umout目錄重新擴容試試,但根目錄不可能umout的。

具體再百度發現,(由于CentOS6和CentOS7在默認根文件系統的文件系統格式存在差異,需要判斷是否為xfs,如果是xfs則應該使用xfs_growfs而不是一味的使用resize2fs。)

Linux7文件系統格式是xfs,resize2fs命令是讀取不了的。

所以要用xfs_growfs來同步文件系統。

[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: 調整 xfs 文件系統的各種參數

xfs_copy: 拷貝 xfs 文件系統的內容到一個或多個目標系統(并行方式)

xfs_db: 調試或檢測 xfs 文件系統(查看文件系統碎片等)

xfs_check: 檢測 xfs 文件系統的完整性

xfs_bmap: 查看一個文件的塊映射

xfs_repair: 嘗試修復受損的 xfs 文件系統

xfs_fsr: 碎片整理

xfs_quota: 管理 xfs 文件系統的磁盤配額

xfs_metadump: 將 xfs 文件系統的元數據 (metadata) 拷貝到一個文件中

xfs_mdrestore: 從一個文件中將元數據 (metadata) 恢復到 xfs 文件系統

xfs_growfs: 調整一個 xfs 文件系統大小(只能擴展)

xfs_freeze? ? 暫停(-f)和恢復(-u)xfs 文件系統

xfs_logprint: 打印xfs文件系統的日志

xfs_mkfile: 創建xfs文件系統

xfs_info: 查詢文件系統詳細信息

xfs_ncheck: generate pathnames from i-numbers for XFS

xfs_rtcp: XFS實時拷貝命令

xfs_io: 調試xfs I/O路徑

總結

以上是生活随笔為你收集整理的esxi01磁盘扩容_给EXSI虚拟机中linux硬盘扩容的全部內容,希望文章能夠幫你解決所遇到的問題。

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