virtualbox扩展磁盘

使用virtualbox搭建虚拟机,如果磁盘不够用了,可以通过以下方式扩展。

扩容磁盘

分区扩展

查看磁盘情况

fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x000a391a

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 2099199 1048576 83 Linux

/dev/sda2 2099200 83886079 40893440 8e Linux LVM

Disk /dev/mapper/centos-root: 37.6 GB, 37576769536 bytes, 73392128 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

扩展分区

bash 复制代码
fdisk /dev/sda
# 删除分区
d
2
# 新建分区
n
p
# 修改分区类型为 Linux LVM
t
2
8e
# 保存分区
w

扩展LVM

bash 复制代码
# 扩展物理卷到整个磁盘大小
sudo pvresize /dev/sda2
# 确认物理卷现在显示新的大小
pvdisplay

# 查看卷组
vgdisplay
# 查看当前逻辑卷
lvdisplay
# 扩展根逻辑卷
lvextend -l +100%FREE /dev/centos/root

# 扩展文件系统,ext4用resize2fs, xfs用xfs_growfs,可以用df -T查看
sudo resize2fs /dev/centos/root
sudo xfs_growfs /
相关推荐
C澒5 天前
前端监控系统的最佳实践
前端·安全·运维开发
C澒5 天前
SGW 接入层运维实战:配置查看 + 监控分析 + 日志排查
前端·安全·运维开发
_叶小格_5 天前
cp、scp、rsync命令详解
linux·运维·服务器·ubuntu·centos·运维开发
C澒5 天前
系统初始化成功率下降排查实践
前端·安全·运维开发
C澒5 天前
面单打印服务的监控检查事项
前端·后端·安全·运维开发·交通物流
不许哈哈哈5 天前
HTTP协议基础(运维开发面试版)
http·面试·运维开发
小白不想白a6 天前
pod调度--预选阶段(重点说容忍)
k8s·运维开发
_运维那些事儿6 天前
GitLabCI/CD语法
linux·服务器·git·ci/cd·gitlab·运维开发·devops
_运维那些事儿8 天前
GitLabCI-CD入门
运维·ci/cd·容器·云计算·k8s·运维开发
eWidget8 天前
Shell通配符与正则:*?[]{} 通配,基础正则匹配(grep 入门)
运维·数据库·运维开发·kingbase·kingbasees·金仓数据库