VMware不关机扩容linux磁盘:修订间差异
来自三线的随记
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
=== lvm类型的分区 === | |||
# vm层面完成磁盘扩容 | # vm层面完成磁盘扩容 | ||
# 有时候会碰到vm无法感知到disk容量变化的情况出现,这时候需要手动rescan一下<code> echo 1 > /sys/class/block/sda/device/rescan </code> | # 有时候会碰到vm无法感知到disk容量变化的情况出现,这时候需要手动rescan一下<code> echo 1 > /sys/class/block/sda/device/rescan </code> | ||
第11行: | 第10行: | ||
# 完成。。 | # 完成。。 | ||
=== vm disk as mount point === | |||
# vm层面完成磁盘扩容 | # vm层面完成磁盘扩容 | ||
# 同样手动rescan一下<code> echo 1 > /sys/class/block/sda/device/rescan </code> | # 同样手动rescan一下<code> echo 1 > /sys/class/block/sda/device/rescan</code> | ||
#根据文件系统类型执行fs扩容,如<code>xfs_growfs</code> / <code>resize2fs</code> | |||
#例如⬇️ | |||
[root@192-168-157-39 ~]# lsblk /dev/sdb | |||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |||
sdb 8:16 0 150G 0 disk /var/lib/containers | |||
[root@dce-192-168-157-39 ~]# echo 1 > /sys/class/block/sdb/device/rescan | |||
[root@dce-192-168-157-39 ~]# lsblk /dev/sdb | |||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |||
sdb 8:16 0 155G 0 disk /var/lib/containers | |||
[root@192-168-157-39 ~]# cat /etc/fstab |grep cont | |||
/dev/sdb /var/lib/containers xfs defaults,pquota 0 0 | |||
[root@192-168-157-39 ~]# xfs_growfs /dev/sdb | |||
meta-data=/dev/sdb isize=512 agcount=4, agsize=9830400 blks | |||
= sectsz=512 attr=2, projid32bit=1 | |||
= crc=1 finobt=0 spinodes=0 | |||
data = bsize=4096 blocks=39321600, imaxpct=25 | |||
= sunit=0 swidth=0 blks | |||
naming =version 2 bsize=4096 ascii-ci=0 ftype=1 | |||
log =internal bsize=4096 blocks=19200, version=2 | |||
= sectsz=512 sunit=0 blks, lazy-count=1 | |||
realtime =none extsz=4096 blocks=0, rtextents=0 | |||
data blocks changed from 39321600 to 40632320 | |||
[root@192-168-157-39 ~]# df -h /var/lib/containers | |||
Filesystem Size Used Avail Use% Mounted on | |||
/dev/sdb 155G 19G 137G 12% /var/lib/containers | |||
[root@192-168-157-39 ~]# lsblk | |||
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |||
sda 8:0 0 50G 0 disk | |||
├─sda1 8:1 0 1019M 0 part /boot | |||
└─sda2 8:2 0 49G 0 part | |||
└─centos-root 253:0 0 49G 0 lvm / | |||
sdb 8:16 0 155G 0 disk /var/lib/containers | |||
sr0 11:0 1 9.5G 0 rom | |||
[root@192-168-157-39 ~]#<br /> | |||
额外延伸:[https://www.2daygeek.com/scan-detect-luns-scsi-disks-on-redhat-centos-oracle-linux/ How to scan\detect new LUN’s & SCSI disks in Linux?] | 额外延伸:[https://www.2daygeek.com/scan-detect-luns-scsi-disks-on-redhat-centos-oracle-linux/ How to scan\detect new LUN’s & SCSI disks in Linux?] | ||
[[category: Linux]] | [[category: Linux]] |
2023年3月6日 (一) 19:11的版本
lvm类型的分区
- vm层面完成磁盘扩容
- 有时候会碰到vm无法感知到disk容量变化的情况出现,这时候需要手动rescan一下
echo 1 > /sys/class/block/sda/device/rescan
fdisk -l /dev/sda
- 使用fdisk /dev/sda 删除重建需要扩容的分区(增大分区容量,保留原本的LVM2_member signature, 起始扇区与原本一致)
partprobe /dev/sda
pvresize /dev/sda3
lvextend /dev/cl/root /dev/sda3
xfs_growfs /dev/mapper/cl-root
- 完成。。
vm disk as mount point
- vm层面完成磁盘扩容
- 同样手动rescan一下
echo 1 > /sys/class/block/sda/device/rescan
- 根据文件系统类型执行fs扩容,如
xfs_growfs
/resize2fs
- 例如⬇️
[root@192-168-157-39 ~]# lsblk /dev/sdb NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 150G 0 disk /var/lib/containers [root@dce-192-168-157-39 ~]# echo 1 > /sys/class/block/sdb/device/rescan [root@dce-192-168-157-39 ~]# lsblk /dev/sdb NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sdb 8:16 0 155G 0 disk /var/lib/containers [root@192-168-157-39 ~]# cat /etc/fstab |grep cont /dev/sdb /var/lib/containers xfs defaults,pquota 0 0 [root@192-168-157-39 ~]# xfs_growfs /dev/sdb meta-data=/dev/sdb isize=512 agcount=4, agsize=9830400 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=39321600, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=19200, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 39321600 to 40632320 [root@192-168-157-39 ~]# df -h /var/lib/containers Filesystem Size Used Avail Use% Mounted on /dev/sdb 155G 19G 137G 12% /var/lib/containers [root@192-168-157-39 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 50G 0 disk ├─sda1 8:1 0 1019M 0 part /boot └─sda2 8:2 0 49G 0 part └─centos-root 253:0 0 49G 0 lvm / sdb 8:16 0 155G 0 disk /var/lib/containers sr0 11:0 1 9.5G 0 rom [root@192-168-157-39 ~]#