设为首页 收藏本站
查看: 810|回复: 0

[经验分享] VMware ESXi 中的 CentOS 硬盘扩容

[复制链接]

尚未签到

发表于 2018-4-22 12:35:09 | 显示全部楼层 |阅读模式
  1. 在 vSphere Client 上直接扩大虚拟机的硬盘空间或者挂载一块新硬盘。
  2. 查看当前硬盘空间情况:
[root@ucslab admin]# df -h

  文件系统           容量  已用  可用 已用%% 挂载点
  /dev/mapper/vg_ucslab-lv_root
  50G  8.8G   38G  19% /
  tmpfs                 7.8G   88K  7.8G   1% /dev/shm
  /dev/sda1             485M   30M  430M   7% /boot
  /dev/mapper/vg_ucslab-lv_home
  26G  616M   24G   3% /home
  3. 创建新分区并调整分区类型:
[root@ucslab admin]# fdisk /dev/sda

  WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
  switch off the mode (command 'c') and change display units to
  sectors (command 'u').
  Command (m for help): p (显示当前分区情况)
  Disk /dev/sda: 536.9 GB, 536870912000 bytes
  255 heads, 63 sectors/track, 65270 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector>
  I/O>
  Disk>
  Device Boot      Start         End      Blocks  >  /dev/sda1   *           1          64      512000   83  Linux
  Partition 1 does not end on cylinder boundary.
  /dev/sda2              64       10444    83373056   8e  Linux LVM
  Command (m for help): n (创建新的主分区)
  Command action
  e   extended
  p   primary partition (1-4)
  p
  Partition number (1-4): 3
  First cylinder (10444-65270, default 10444):
  Using default value 10444
  Last cylinder, +cylinders or +size{K,M,G} (10444-65270, default 65270):
  Using default value 65270
  Command (m for help): p (显示当前分区情况)
  Disk /dev/sda: 536.9 GB, 536870912000 bytes
  255 heads, 63 sectors/track, 65270 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector>
  I/O>
  Disk>
  Device Boot      Start         End      Blocks  >  /dev/sda1   *           1          64      512000   83  Linux
  Partition 1 does not end on cylinder boundary.
  /dev/sda2              64       10444    83373056   8e  Linux LVM
  /dev/sda3           10444       65270   440395195   83  Linux
  Command (m for help): t  (修改分区类型为 Linux LVM, 8e)
  Partition number (1-4): 3
  Hex code (type L to list codes): 8e
  Changed system type of partition 3 to 8e (Linux LVM)
  Command (m for help): w

  The partition table has been>  Calling ioctl() to re-read partition table.
  WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
  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.
  建议重启,或使用partprobe刷新硬盘情况。
  4. 查看修改后的分区情况:
[root@ucslab admin]# fdisk -l

  Disk /dev/sda: 536.9 GB, 536870912000 bytes
  255 heads, 63 sectors/track, 65270 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector>
  I/O>
  Disk>
  Device Boot      Start         End      Blocks  >  /dev/sda1   *           1          64      512000   83  Linux
  Partition 1 does not end on cylinder boundary.
  /dev/sda2              64       10444    83373056   8e  Linux LVM
  /dev/sda3           10444       65270   440395195   8e  Linux LVM
  Disk /dev/dm-0: 53.7 GB, 53687091200 bytes
  255 heads, 63 sectors/track, 6527 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector>
  I/O>
  Disk>  Disk /dev/dm-0 doesn't contain a valid partition table
  Disk /dev/dm-1: 4227 MB, 4227858432 bytes
  255 heads, 63 sectors/track, 514 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector>
  I/O>
  Disk>  Disk /dev/dm-1 doesn't contain a valid partition table
  Disk /dev/dm-2: 27.5 GB, 27455913984 bytes
  255 heads, 63 sectors/track, 3337 cylinders
  Units = cylinders of 16065 * 512 = 8225280 bytes

  Sector>
  I/O>
  Disk>  Disk /dev/dm-2 doesn't contain a valid partition table
  5. 初始化物理卷:
[root@ucslab admin]# pvcreate /dev/sda3

  Physical volume "/dev/sda3" successfully created
  6. 添加到卷组:
[root@ucslab admin]# lvm

  lvm> vgdisplay
  --- Volume group ---
  VG Name               vg_ucslab (卷组名称)

  System>  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1

  VG>
  PE>  Total PE              20354

  Alloc PE />
  Free  PE />  VG UUID               1xZKPs-dWqe-Y8Ca-x885-Czo7-wCA8-gMd5u2
  lvm> vgextend /dev/vg_ucslab /dev/sda3
  Volume group "vg_ucslab" successfully extended
  lvm> vgdisplay
  --- Volume group ---
  VG Name               vg_ucslab

  System>  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2

  VG>
  PE>  Total PE              127872

  Alloc PE />
  Free  PE />  VG UUID               1xZKPs-dWqe-Y8Ca-x885-Czo7-wCA8-gMd5u2
  7. 显示逻辑卷情况,并扩展逻辑卷大小,每个逻辑卷扩展200G:
  lvm> lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_ucslab/lv_root
  VG Name                vg_ucslab
  LV UUID                ekSWAJ-Yv5j-E9br-nmyF-jNtV-PXGb-LpxdDt
  LV Write Access        read/write
  LV Status              available
  # open                 1

  LV>  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  --- Logical volume ---
  LV Name                /dev/vg_ucslab/lv_home
  VG Name                vg_ucslab
  LV UUID                cNeSMR-eddd-noQx-nMpq-pf1i-g3Qu-DEEt2M
  LV Write Access        read/write
  LV Status              available
  # open                 1

  LV>  Current LE             6546
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
  --- Logical volume ---
  LV Name                /dev/vg_ucslab/lv_swap
  VG Name                vg_ucslab
  LV UUID                DxN0XW-2g7D-ffle-zYme-yH4O-Ntbv-llAxPY
  LV Write Access        read/write
  LV Status              available
  # open                 1

  LV>  Current LE             1008
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
  lvm> lvextend -L +200G /dev/vg_ucslab/lv_root
  Extending logical volume lv_root to 250.00 GiB
  Logical volume lv_root successfully resized
  lvm> lvextend -L +200G /dev/vg_ucslab/lv_home
  Extending logical volume lv_home to 225.57 GiB
  Logical volume lv_home successfully resized
  lvm> quit
  Exiting.
xfs_growfs /dev/centos/root  
df -h

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-450425-1-1.html 上篇帖子: CentOS7.3yum安装zabbix3.2 下篇帖子: Centos 7.3 PXE全自动安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表