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 /
相关推荐
江南风月6 小时前
WGCLOUD如果使用SQL Server数据库推荐哪个版本
运维·网络·zabbix·运维开发·prometheus
JiaWen技术圈3 天前
内核子系统 nf_tables 深度解析
linux·服务器·安全·运维开发
JiaWen技术圈3 天前
conntrack-tools 用法
linux·运维·服务器·安全·运维开发
JiaWen技术圈3 天前
nf_tables 架构深度详解(内核级完整架构)
linux·服务器·安全·运维开发
IMPYLH5 天前
Linux 的 sync 命令
linux·运维·服务器·python·bash·运维开发
何中应6 天前
Ansible安装&使用
运维·自动化·ansible·运维开发·自动化运维
IMPYLH7 天前
Linux 的 split 命令
linux·运维·python·bash·运维开发·unix
小夏子_riotous7 天前
Docker学习路径——8、Dockerfile
linux·运维·docker·容器·系统架构·centos·运维开发
.柒宇.10 天前
CICD基础概述
ci/cd·运维开发·devops
A-刘晨阳11 天前
k8s之镜像拉取策略
运维·docker·容器·kubernetes·运维开发·harbor