首页 > 系统相关 >VMware Linux虚拟机在线增加磁盘/磁盘扩容

VMware Linux虚拟机在线增加磁盘/磁盘扩容

时间:2022-12-29 11:37:18浏览次数:38  
标签:虚拟机 bytes dev logical sdb Linux 磁盘 512 size

扩容前状态

只有一块60GB的磁盘

[root@RHEL6 ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002d5e5

Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 51200 51915776 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_rhel6-lv_root: 49.0 GB, 48997859328 bytes
255 heads, 63 sectors/track, 5956 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_rhel6-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

增加磁盘

vSphere web client为虚拟机增加一个16G磁盘

VMware Linux虚拟机在线增加磁盘/磁盘扩容 _在线扩容

Linux自动扫描到新增磁盘

[root@RHEL6 ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002d5e5

Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 51200 51915776 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_rhel6-lv_root: 49.0 GB, 48997859328 bytes
255 heads, 63 sectors/track, 5956 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_rhel6-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdb: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

到虚拟机内部可以看到新增的磁盘,本初示例是“/dev/sdb”,你的环境命名编号可能会有不一样。

dmesg
#日志最后可以看到新增的磁盘sdb
vmw_pvscsi: msg type: 0x0 - MSG RING: 1/0 (5)
vmw_pvscsi: msg: device added at scsi0:1:0
scsi 2:0:1:0: Direct-Access VMware Virtual disk 2.0 PQ: 0 ANSI: 6
sd 2:0:1:0: Attached scsi generic sg2 type 0
sd 2:0:1:0: [sdb] 33554432 512-byte logical blocks: (17.1 GB/16.0 GiB)
sd 2:0:1:0: [sdb] Write Protect is off
sd 2:0:1:0: [sdb] Mode Sense: 3b 00 00 00
sd 2:0:1:0: [sdb] Write cache: disabled, read cache: disabled, doesn't support DPO or FUA
sdb: unknown partition table
sd 2:0:1:0: [sdb] Attached SCSI disk

将虚拟机磁盘扩容

16GB——>20GB

VMware Linux虚拟机在线增加磁盘/磁盘扩容 _在线扩容_02

扩容后,linux没有识别到新增容量

扫描驱动器

echo 1>/sys/class/block/sdd/device/rescan
dmesg
# 重新扫描磁盘后,dgesg日志显示sdb容量增长
sd 2:0:1:0: [sdb] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB)
sdb: detected capacity change from 17179869184 to 21474836480
[root@RHEL6 device]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes
64 heads, 32 sectors/track, 51200 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002d5e5

Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 51200 51915776 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/mapper/vg_rhel6-lv_root: 49.0 GB, 48997859328 bytes
255 heads, 63 sectors/track, 5956 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_rhel6-lv_swap: 4160 MB, 4160749568 bytes
255 heads, 63 sectors/track, 505 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdb: 21.5 GB, 21474836480 bytes
64 heads, 32 sectors/track, 20480 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

注意:网上还有方法是

echo "- - -" > /sys/class/scsi_host/hostX/scan

X:0,1,2,...

这个主要是对scsi控制器的扫描,主要用于扫描新增加的驱动器,如果新增了磁盘,但是OS层面没有发现,那么用这种方法适用。


标签:虚拟机,bytes,dev,logical,sdb,Linux,磁盘,512,size
From: https://blog.51cto.com/tech4fei/5976521

相关文章

  • Linux小白入门经验
    雄关漫道真如铁,而今迈步从头越。我们在单位工作的人都有一个梦想,那就是搞定所有的计算机难题,帮助公司完成更多的电脑维修、软件开发以及系统监测。随着互联网的深入发展,我们......
  • 随笔(十一)『虚拟机安装docker』
    1、进入虚拟机:vagrantssh2、docker安装文档:https://docs.docker.com/engine/install/centos/3、安装步骤3.1)卸载系统之前的dockersudoyumremovedocker\......
  • 虚拟机(centos7)启动后没有ens33 ip地址的解决办法
    虚拟机(centos7)启动后,执行ipaddr命令,显示ens33没有ip地址,无法使用远程连接,这是由于网卡未加入托管所致;临时解决方案:执行命令:dhclientens33执行后查看ipaddr,ens33......
  • 服务器CentOS7/Linux中文提示
    locale-a|grep"zh_CN"#如果没有任何提示需要下载语言包vim/etc/locale.conf添加LANG=zh_CN.gbk在最前面reroot#重启服务器生效......
  • Linux(2):用户(2)
    Linuxben-u5.13.0-35-generic#40~20.04.1-UbuntuSMP-- 序章前文提到,用户关心信息位于以下文件中:/etc/passwd/etc/shadow/etc/group/etc/gshadow接下来对用......
  • Linux安装Apache
    yumyuminstallhttpd#中间y就可以了#如果执行上面提示Nopackagehttpdavailable.那就试试下面的yum--disableexcludes=allinstallhttpd#会告诉你Install1......
  • Linux安装jdk
    yumyum-ylistjava*#查询jdk版本...java-1.7.0-openjdk-headless.x86_641:1.7.0.261-2.6.22.2......
  • Linux安装MySQL 8.0.27
    cd/usr/localmkdirmysqlcdmysqlwgethttps://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.27-linux-glibc2.12-x86_64.tar.xz#下载可能需要几分钟tar......
  • Linux环境下奥比中光摄像头开发环境搭建(基于Orbbec SDK)
    驱动安装奥比中光相机,可以Linux平台下设备作为普通CMOS相机加载,目前流行Linux平台都已经内置相应驱动,不需要额外安装驱动,只需要安装一个依赖软件freeglut3即可。sudoapt......
  • linux源码安装redis步骤
    1yuminstallwget2cd~3mkdirsoft4cdsoft5wgethttp://download.redis.io/releases/redis-5.0.5.tar.gz6tarxfredis-5.0.5.tar.gz7cdredis-5.0.58看README.......