Ubuntu LVM 系统盘剩余容量扩充到 root 分区

1. 问题场景 安装 Ubuntu Server 时,如果安装程序使用了 LVM 默认配置,通常只会分配磁盘的一部分给 root 逻辑卷(Logical Volume),剩余空间留在 Volume Group 中未使用。例如: 磁盘总容量 200GB root 分区仅分配了 98.5GB VG 中还有 98.5GB 空闲 此时需要将剩余空间在线扩充到 / 分区,无需重启、无需卸载。 2. 前置知识 在动手之前,理解 LVM 的三层抽象有助于你排查更复杂的场景: 层 组件 类比 PV (Physical Volume) /dev/sda3 一块硬盘原料 VG (Volume Group) ubuntu-vg 一个"存储池",由若干 PV 组成 LV (Logical Volume) ubuntu-lv 从池中切出的"虚拟分区",格式化后挂载 扩容的本质就是:池(VG)里有空闲空间 → 划给虚拟分区(LV)→ 通知文件系统去用新空间。 PE (Physical Extent) 是 LVM 的最小分配单位,默认 4MiB。lvextend -l +100%FREE 中的 -l 就是以 PE 为单位分配——+100%FREE 表示"把 VG 中所有空闲 PE 全给这个 LV"。 ...

2026年6月14日 · 3 分钟 · 596 字 · AIHugoBlog

Centos7系统盘剩余容量扩充到root分区

1.lsblk来检查磁盘分区挂载点的状态,当然可以看出为分配空间 [root@samba ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 99G 0 part ├─centos-root 253:0 0 85.1G 0 lvm / ├─centos-swap 253:1 0 3.9G 0 lvm [SWAP] └─centos-home 253:2 0 10G 0 lvm /home sdb 8:16 0 300G 0 disk └─sdb1 8:17 0 300G 0 part /disk sr0 11:0 1 1024M 0 rom 以上可以看出sda1 和 sda2 是现有的分区。 sda 总容量为 214.7G,但 sda2 只占用了 103.8G,剩余部分(大约 110.9G)如果未显示,意味着它未被分区。 2.手动分区 启动fdisk工具 sudo fdisk /dev/sda 创建新分区 [root@samba ~]# fdisk /dev/sda 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 命令(输入 m 获取帮助):n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p 分区号 (3,4,默认 3): 起始 扇区 (209715200-419430399,默认为 209715200): 将使用默认值 209715200 Last 扇区, +扇区 or +size{K,M,G} (209715200-419430399,默认为 419430399): 将使用默认值 419430399 分区 3 已设置为 Linux 类型,大小设为 100 GiB 命令(输入 m 获取帮助):t 分区号 (1-3,默认 3): Hex 代码(输入 L 列出所有代码):8e 已将分区“Linux”的类型更改为“Linux LVM” 命令(输入 m 获取帮助):w The partition table has been altered! 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) 正在同步磁盘。 报错解决:尝试通过 partprobe 命令强制内核重新读取分区表。 sudo partprobe /dev/sda 添加新分区到 LVM [root@samba ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created. [root@samba ~]# vgextend centos /dev/sda3 Volume group "centos" successfully extended [root@samba ~]# sudo lvextend -l +100%FREE /dev/mapper/centos-root Size of logical volume centos/root changed from 85.12 GiB (21791 extents) to <185.12 GiB (47390 extents). Logical volume centos/root successfully resized. [root@samba ~]# sudo xfs_growfs / meta-data=/dev/mapper/centos-root isize=512 agcount=7, agsize=3276800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=22313984, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 22313984 to 48527360 3.再次查看,发现硬盘剩余空间已经被扩展到root分区。 [root@samba ~]# df -hl 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 2.0G 0 2.0G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 201M 1.8G 11% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mapper/centos-root 186G 76G 110G 41% / /dev/sdb1 296G 130G 151G 47% /disk /dev/sda1 1014M 136M 879M 14% /boot /dev/mapper/centos-home 10G 33M 10G 1% /home overlay 186G 76G 110G 41% /var/lib/docker/overlay2/d00d0b3eb629332ae9a00776a7f618b09b7445e23d8e25b06930747618a205f9/merged tmpfs 396M 0 396M 0% /run/user/0 [root@samba ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 99G 0 part │ ├─centos-root 253:0 0 185.1G 0 lvm / │ ├─centos-swap 253:1 0 3.9G 0 lvm [SWAP] │ └─centos-home 253:2 0 10G 0 lvm /home └─sda3 8:3 0 100G 0 part └─centos-root 253:0 0 185.1G 0 lvm / sdb 8:16 0 300G 0 disk └─sdb1 8:17 0 300G 0 part /disk sr0 11:0 1 1024M 0 rom

2025年6月23日 · 3 分钟 · 481 字 · AIHugoBlog

Centos7服务器环境安装标准

1.必要软件 yum install -y epel-release yum update -y yum install -y vim net-tools nmon htop rsync iptraf-ng tree lrzsz ntp iftop telnet tcpdump traceroute wget # 按需安装 yum install -y cmake make gcc gcc-c++ 2.设置同步时间 echo "0 8 * * * root ntpdate ntp.aliyun.com" >> /etc/crontab 3.关闭selinux及防火墙(防火墙按需关闭) sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config systemctl stop firewalld systemctl disable firewalld 4.禁用DNS反向解析 sed -i 's@GSSAPIAuthentication yes@GSSAPIAuthentication no@' /etc/ssh/sshd_config sed -i 's@#UseDNS yes@UseDNS no@' /etc/ssh/sshd_config

2025年6月23日 · 1 分钟 · 70 字 · AIHugoBlog

一条命令安装一个云系统sacaos,国内也支持安装

1.sacaos的GitHub地址 https://github.com/IceWhaleTech/CasaOS 2.可访问GitHub用户执行以下命令即可 wget -qO- https://get.casaos.io | sudo bash 3.不能访问GitHub的用户,把get.casaos.io.sh上传到Linux,然后执行 bash get.casaos.io 4.视频

2023年12月19日 · 1 分钟 · 13 字 · AIHugoBlog

最简博客、知识库hexo搭建教程

官网:https://hexo.io/1.环境准备node.js:版本需不低于 10.13,下载地址:https://nodejs.cn/download/git:下载地址:(windows)https://git-scm.com/download/win# Linuxapt-get install

2023年12月19日 · 1 分钟 · 59 字 · AIHugoBlog

群晖docker安装dokuwiki个人知识管理系统

1.官网https://www.dokuwiki.org/dokuwiki2.Docker安装文档https://hub.docker.com/r/linuxserver/dokuwiki3.步骤镜像拉取docker pull linuxserver/dokuwikidocker-composeve

2023年12月19日 · 1 分钟 · 57 字 · AIHugoBlog

群晖DSM7.2系统docker搭建jellyfin影视服务

1.docker compose文件version: '3'services: jellyfin: image: nyanmisaka/jellyfin:latest container_name: jellyfin volumes: - /volume

2023年12月19日 · 1 分钟 · 30 字 · AIHugoBlog

Centos7中Mysql8.0安装过程

1.系统安装 系统更新及常用软件安装 yum update -y yum install wget wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo yum install -y vim net-tools nmon htop rsync iptraf-ng tree lrzsz ntp iftop telnet tcpdump traceroute 环境配置 echo "0 8 * * * root ntpdate ntp.volphi.com" >> /etc/crontab sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config sed -i 's@GSSAPIAuthentication yes@GSSAPIAuthentication no@' /etc/ssh/sshd_config sed -i 's@#UseDNS yes@UseDNS no@' /etc/ssh/sshd_config firewall-cmd --add-port=3306/tcp --permanent firewall-cmd --add-port=3306/tcp firewall-cmd --add-port=33060/tcp --permanent firewall-cmd --add-port=33060/tcp 2.mysql8.0安装 上传mysql80-community-release-el7-7.noarch.rpm到服务器 yum install mysql80-community-release-el7-7.noarch.rpm yum -y install yum-utils yum install mysql-community-server-8.0.28 3.mysql8.0配置 [mysqld] # utf8默认库 character-set-server = utf8mb4 collation-server = utf8mb4_general_ci # 数据最大的连接数 max_connections =1000 binlog_format=mixed # 设定非交互式断开连接的时间30秒 wait_timeout=30 # 设定交互式断开连接的时间30秒 interactive_timeout = 30 # mysql数据的ID server-id=1144301 # master db binlog-ignore-db = mysql,information_schema,performance_schema,sys auto-increment-increment = 2 auto-increment-offset = 1 # slave db replicate-ignore-db = mysql,information_schema,performance_schema,sys log-slave-updates = ON datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid 4.用户创建和密码修改 grep 'temporary password' /var/log/mysqld.log mysql -uroot -p mysql中操作 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; create user 'admin@'%' identified by '123456'; grant all privileges on *.* to 'admin'@'%'; create user 'sync'@'%' identified by '123456'; grant all privileges on *.* to 'sync'@'%'; ALTER USER 'sync'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; FLUSH PRIVILEGES;

2023年12月6日 · 1 分钟 · 180 字 · AIHugoBlog

联想RD350板载RAID110i,安装CentOS 7 不识别RAID设备.md

BIOS设置 1、 确认BIOS中 Boot mode为【UEFI】 2、 确认BIOS中 Storage OpRom Policy 为【UEFI Only】 3、 确认BIOS中SATA mode为【Raid】 4、 确认BIOS中 SSATA mode为【IDE】 把raid卡驱动复制到U盘 联想官网下载megasr-17.01.2016.1107-1-rhel73-x86_64.iso,复制到U盘根目录。 开始安装 进入GRUB界面,选中Install CentOS Linux 7,按下e键。在第一项输入linux inst.dd modprobe.blacklist=ahci quiet,屏蔽ahci,在queit之前。 如图所示,我选择2,自动发现刚才放进去的ISO。以同样的方式选择rpm 然后按c继续。(该过程为自动发现,不需要操作),然后就能找到设备。

2023年12月6日 · 1 分钟 · 31 字 · AIHugoBlog

openvpn服务端证书过期解决方法

1.服务器证书过期 ./easyrsa renew server nopass 2.客户端证书过期 ./easyrsa renew test nopass

2023年12月1日 · 1 分钟 · 10 字 · AIHugoBlog