美文网首页
vagrant磁盘扩展

vagrant磁盘扩展

作者: 于殿国 | 来源:发表于2019-05-10 11:41 被阅读0次
FinWhale_ZH-CN9010064973_1920x1080.jpg
背景:由于公司升级gitlab自己使用vagrant管理的virtualbox来升级系统,发现磁盘空间不足。记录解决过程。
说明:有问题大家可以加微信(yudianguo)或者发邮箱(yu_dianguo@163.com)共同交流
准备:建议把vagrant和virtualbox升级为最新版本
1、检查你的磁盘扩展出来的磁盘文件是否是vdi如果是vdi可跳过当前步骤直接去看第3步
# 查看当前系统类型及磁盘大小
# 启动虚拟机
vagrant up
# 连接进入虚拟机
vagrant ssh
# 查看磁盘大小
sudo pvdisplay

2、定位挂载磁盘位置(也可以去virtialbox控制面板中查看)

VBoxManage list vms
# 挂载出来的文件存储在  ~/VirtualBox VMs  目录下 并进入目录
# 复制并克隆系统存储文件
VBoxManage clonehd packer-centos-6.6-x86_64-virtualbox-vagrant-puppet-1437997185-disk1.vmdk clone-disk1.vdi --format vdi
# 查看复制后文件系统信息
VBoxManage showhdinfo clone-disk1.vdi
# 格式化系统为40G
VBoxManage modifyhd clone-disk1.vdi --resize 40960
# 挂载磁盘文件
VBoxManage storageattach centos_default_1441182442099_63483 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium clone-disk1.vdi

3、进入虚拟机扩展根目录大小

# 切换root权限
sudo su -
# 查看当前系统信息
df
# 新建磁盘主分区
fdisk /dev/sda
# 接下来的步骤
# Follow these steps:
# Press p to print the partition table to identify the number of partitions. By default there are two - sda1 and sda2.
# Press n to create a new primary partition
# Press p for primary
# Press 3 for the partition number, depending the output of the partition table print
# Press Enter two times to accept the default First and Last cylinder
# Press t to change the system's partition ID
# Press 3 to select the newly creation partition
# Type 8e to change the Hex Code of the partition for Linux LVM
# Press w to write the changes to the partition table
# A new partition was created.
# 重启虚拟机后进入虚拟机
pvcreate /dev/sda3
vgdisplay
vgextend VolGroup /dev/sda3
# 扩展磁盘
lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
resize2fs /dev/mapper/VolGroup-lv_root
# 查看扩展后效果
df -h

http://www.thinkcode.se/blog/2015/09/10/increase-the-available-disk-on-a-centos-host-maintained-by-vagrant-and-virtualbox
https://blog.csdn.net/qq_22083251/article/details/80417097

相关文章

  • vagrant磁盘扩展

    2、定位挂载磁盘位置(也可以去virtialbox控制面板中查看) 3、进入虚拟机扩展根目录大小 http://w...

  • 扩容虚拟机磁盘

    vagrant virtualvox 磁盘扩容实践 将vagrant的centos镜像扩容到800G 参考文档 h...

  • 1 搭建虚拟机环境

    Vagrantfile 假如空间不够用vagrant virtualvox 磁盘扩容实践[https://blog...

  • vagrant升级磁盘大小

    https://www.madcoder.cn/vagrant-box-resize.html我的是ubuntu,...

  • Kvm之七:vm磁盘扩容

    Centos7 Kvm vm 磁盘扩容 1、磁盘扩容方式 2、直接扩展raw格式磁盘 3、直接扩展qcow2格式的...

  • LVM扩展磁盘

    1. 查看硬盘情况 # fdisk -l 2.编辑指定的硬盘(进入到编辑界面) # fdisk /dev/sda ...

  • VMware虚拟机扩展磁盘-GParted

    安装好虚拟机后,有时候磁盘会不够用了,这时候需要进行磁盘扩展。虚拟机本身提供了扩展磁盘容量的功能。对于VMware...

  • VMware Linux(Centos)虚拟机扩容根目录磁盘空间

    1:编辑虚拟机设置,点击[硬盘],选择[扩展] 填写大小: 点击扩展后VMware提示磁盘已经成功扩展。 完成扩展...

  • VMware Linux(Centos)虚拟机扩容根目录磁盘空间

    1:编辑虚拟机设置,点击[硬盘],选择[扩展] 填写大小: 点击扩展后VMware提示磁盘已经成功扩展。 完成扩展...

  • fdisk

    一、磁盘分区原理与规则 磁盘分区类型:主分区,扩展分区,逻辑分区 分区规则: 1、主分区+扩展分区的数量不能超过4...

网友评论

      本文标题:vagrant磁盘扩展

      本文链接:https://www.haomeiwen.com/subject/fcpinqtx.html