ubuntu 22.04 台式机安装后 根分区小 自动扩容方法 /dev/ubuntu-vg/ubuntu-lv 扩容
  ETWZF7L1nsXD 2023年11月13日 25 0

/dev/ubuntu-vg/ubuntu-lv 扩容


故障显示为:

/dev/sda3 是我的1T

Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 100 GiB,只给了100G

root@server-8-3:~# sudo fdisk -l
Disk /dev/loop0: 61.89 MiB, 64901120 bytes, 126760 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/loop1: 79.95 MiB, 83832832 bytes, 163736 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/loop2: 44.68 MiB, 46845952 bytes, 91496 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/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000DM003-1SB1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 34730401-B09F-451A-8C52-2F7646AAE5EB

Device       Start        End    Sectors   Size Type
/dev/sda1     2048       4095       2048     1M BIOS boot
/dev/sda2     4096    4198399    4194304     2G Linux filesystem
/dev/sda3  4198400 1953521663 1949323264 929.5G 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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
root@server-8-3:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              789M  1.4M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   98G  7.0G   86G   8% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  129M  1.7G   8% /boot
tmpfs                              789M  4.0K  789M   1% /run/user/0

如下

Disk /dev/loop0: 61.89 MiB, 64901120 bytes, 126760 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/loop1: 79.95 MiB, 83832832 bytes, 163736 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/loop2: 44.68 MiB, 46845952 bytes, 91496 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/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000DM003-1SB1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 34730401-B09F-451A-8C52-2F7646AAE5EB

Device       Start        End    Sectors   Size Type
/dev/sda1     2048       4095       2048     1M BIOS boot
/dev/sda2     4096    4198399    4194304     2G Linux filesystem
/dev/sda3  4198400 1953521663 1949323264 929.5G 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 / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
root@server-8-3:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              789M  1.4M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   98G  7.0G   86G   8% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  129M  1.7G   8% /boot
tmpfs                              789M  4.0K  789M   1% /run/user/0

ubuntu 22.04  台式机安装后 根分区小 自动扩容方法 /dev/ubuntu-vg/ubuntu-lv 扩容_逻辑卷

上图说明  :实际是1T硬盘 但是 UBUNTU 22.04 自动默认安装后 根分区只有98G

故障解决:

LVM是Logical Volume Manager(逻辑卷管理)的缩写,是Linux环境下对磁盘分区进行管理的一种机制。 LVM逻辑卷三种状态:

  1. PV: Physical Volume 物理卷
  2. VG: Volume Group 卷组
  3. LV: Logical Volume 逻辑卷

要将包含 sda3 分区的逻辑卷(logical volume) ubuntu--vg-ubuntu--lv 扩展到整个分区的大小,可以按照以下步骤进行操作:


   1.使用 fdisk 命令检查硬盘的分区布局并找到需要扩展的分区号码。在这种情况下,您需要记下sda3的起始扇区和结束扇区。


   使用 pvresize 命令调整物理卷(physical volume)的大小,使其包括扩展的分区。例如,如果 sda3 已经被扩展到 50GB,则运行以下命令:


root@server-8-3:~# pvresize /dev/sda3

  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized
  翻译
  物理卷已调整大小或已更新/0个物理卷未调整大小


   然后使用 lvextend 命令将逻辑卷扩展到物理卷的大小。例如,运行以下命令将 ubuntu--vg-ubuntu--lv 扩展到整个 sda3 分区的大小:


lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv


 这里 -r 标志将自动调整文件系统大小以填充新的逻辑卷空间。

   检查文件系统是否已成功调整大小:

df -h
    
  实例:  
root@server-8-3:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              789M  1.4M  788M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  915G  7.0G  870G   1% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  129M  1.7G   8% /boot
tmpfs                              789M  4.0K  789M   1% /run/user/0

 这应该会显示更大的可用空间。


root@server-8-3:~# pvresize /dev/sda3



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月13日 0

暂无评论

推荐阅读
  jnZtF7Co41Wg   2023年12月06日   27   0   0 sedlinux数据
  uvM09mQNI0hF   2023年11月19日   28   0   0 sedshell字符串
  eHipUjOuzYYH   2023年12月06日   33   0   0 sedbootstrapIPV6
  xIUntf9oR6GI   2023年11月28日   31   0   0 sedvim基础命令
  mjtHZIki74si   2023年12月06日   32   0   0 ubuntubash
  oIa1edJoFmXP   2023年11月24日   31   0   0 AppsedVue
ETWZF7L1nsXD