当前位置: 首页 > article >正文

【原创】Ubuntu 24自动分区后的根目录扩展

安装了一台Ubuntu 24服务器,发现根目录只有不到100G。
再安装了一台,发现还是同样的问题。

查看分区挂载情况

root@DeepSeek:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              772M  1.1M  771M   1% /run
efivarfs                           150K   72K   74K  50% /sys/firmware/efi/efivars
/dev/mapper/ubuntu--vg-ubuntu--lv   98G   44G   50G  47% /
tmpfs                              3.8G   16K  3.8G   1% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p2                     2.0G   97M  1.7G   6% /boot
/dev/nvme0n1p1                     1.1G  6.2M  1.1G   1% /boot/efi
tmpfs                              772M   12K  772M   1% /run/user/1000

/dev/mapper/ubuntu–vg-ubuntu–lv 挂载在根目录,只有98G

检查磁盘空间

root@DeepSeek:~# fdisk -l
Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: SAMSUNG MZVLQ512HALU-000H1              
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 64428F08-2785-4574-A705-2AE6B40F81AD

Device           Start        End   Sectors   Size Type
/dev/nvme0n1p1    2048    2203647   2201600     1G EFI System
/dev/nvme0n1p2 2203648    6397951   4194304     2G Linux filesystem
/dev/nvme0n1p3 6397952 1000212479 993814528 473.9G Linux filesystem


Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 100 GiB, 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 /dev/nvme0n1: 476.94 GiB,磁盘近500G

接下来将剩余部分全部合并到根目录

查看当前的卷组(VG)

root@DeepSeek:~# vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <473.89 GiB
  PE Size               4.00 MiB
  Total PE              121315
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       95715 / <373.89 GiB
  VG UUID               Uc9TNh-gnfD-OC8N-053Q-VCBg-5UQm-jfuNKc

得到信息:Free PE / Size 95715 / <373.89 GiB。

查看当前逻辑卷(LV)

root@DeepSeek:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                2KBkqE-fdaV-rAkI-x1aR-JOIT-X3eZ-DH00pL
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2025-02-26 07:34:44 +0000
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

扩展逻辑卷

root@DeepSeek:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <473.89 GiB (121315 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

扩展文件系统

先检查文件系统

root@DeepSeek:~# df -T
Filesystem                        Type     1K-blocks     Used Available Use% Mounted on
tmpfs                             tmpfs       790120     1112    789008   1% /run
efivarfs                          efivarfs       150       72        74  50% /sys/firmware/efi/efivars
/dev/mapper/ubuntu--vg-ubuntu--lv ext4     102626232 45178732  52188236  47% /
tmpfs                             tmpfs      3950600       16   3950584   1% /dev/shm
tmpfs                             tmpfs         5120        0      5120   0% /run/lock
/dev/nvme0n1p2                    ext4       1992552    98732   1772580   6% /boot
/dev/nvme0n1p1                    vfat       1098632     6288   1092344   1% /boot/efi
tmpfs                             tmpfs       790120       12    790108   1% /run/user/1000

从 /dev/mapper/ubuntu–vg-ubuntu–lv ext4 102626232 45178732 52188236 47% /
得知 文件系统为 ext4

扩展文件系统

root@DeepSeek:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 60
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 124226560 (4k) blocks long.

检查挂载情况

root@DeepSeek:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              772M  1.1M  771M   1% /run
efivarfs                           150K   72K   74K  50% /sys/firmware/efi/efivars
/dev/mapper/ubuntu--vg-ubuntu--lv  466G   44G  403G  10% /
tmpfs                              3.8G   16K  3.8G   1% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p2                     2.0G   97M  1.7G   6% /boot
/dev/nvme0n1p1                     1.1G  6.2M  1.1G   1% /boot/efi
tmpfs                              772M   12K  772M   1% /run/user/1000

可以看到 /dev/mapper/ubuntu–vg-ubuntu–lv 466G 44G 403G 10% /
根目录获得全部剩余空间。


http://www.kler.cn/a/570682.html

相关文章:

  • 配置Spring Boot API接口超时时间(五种)
  • C++学习之C++初识、C++对C语言增强、对C语言扩展
  • 基于vue3 + ts 封装一个自定义的message组件
  • 基于机器学习的智能谣言检测系统
  • java jar包内的jar包如何打补丁
  • 2022 年 12 月青少年软编等考 C 语言五级真题解析
  • 第6篇:面向对象编程重构系统
  • Spring MVC 返回数据
  • 如何实现前端“小手向右指”的效果
  • Zookeeper 的核心引擎:深入解析 ZAB 协议
  • ECharts饼图高级美化技巧:泛光效果实现与间隔布局
  • JavaWeb3、Tomcat
  • Transformer 代码剖析6 - 位置编码 (pytorch实现)
  • 机器学习11-经典网络解析
  • AI语音交互模组方案,设备无线物联网控制,实时语音联动应用
  • 数据结构:二叉搜索树(排序树)
  • Redis高可用部署:3台服务器打造哨兵集群
  • 基于 Rust 与 GBT32960 规范的编解码层
  • 动态表头报表的绘制与导出
  • 基于 Elasticsearch 和 Milvus 的 RAG 运维知识库的架构设计和部署落地实现指南