Cyb*_*oid 76 partitioning lvm 18.04
我使用 LVM 选项安装了 Ubuntu Server 18.04,并保留了默认分区设置。现在我的主驱动器在 1TB 硬盘中只有 4GB。如何在不从头开始的情况下解决此问题?
结果df -h:
Filesystem Size Used Available Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 32G 1.7M 32G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 3.9G 3.6G 92M 98% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/loop0 87M 87M 0 100% /snap/core/4917
/dev/loop1 3.2M 3.2M 0 100% /snap/stress-ng/471
/dev/loop2 90M 90M 0 100% /snap/core/6130
/dev/sda2 976M 143M 766M 16% /boot
tmpfs 3.2G 0 3.2G 0% /run/user/1000
Run Code Online (Sandbox Code Playgroud)
yor*_*rch 174
全新安装 Ubuntu Server 18.04.1 时遇到完全相同的问题。
我必须做的是:
# We need to resize the logical volume to use all the existing and free space of the volume group
$ lvm
lvm> lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
lvm> exit
# And then, we need to resize the file system to use the new available space in the logical volume
$ resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 58
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 120784896 (4k) blocks long.
# Finally, you can check that you now have available space:
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 786M 1.2M 785M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 454G 3.8G 432G 1% /
Run Code Online (Sandbox Code Playgroud)
如果您没有自定义 LVM 设置,则卷组和逻辑卷的名称应与我的(ubuntu-vg和ubuntu-lv分别)相同。
如果您的分区已满,则no space left在尝试调整逻辑卷大小时可能会出现错误,例如:
lvm> lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
/etc/lvm/archive/.lvm_computer: write error failed: No space left on device
Run Code Online (Sandbox Code Playgroud)
解决此问题的最简单方法是删除apt缓存(下次执行时它会重新生成apt update),这将为您提供足够的空间来完成操作:
$ rm -rf /var/cache/apt/*
Run Code Online (Sandbox Code Playgroud)
LVM 安装的预期行为确实是较小的分区。系统在创建物理分区时产生的空间浪费极小,希望您根据需要自定义和扩展 LVM,因为添加的分区对于操作系统功能来说不是必需的,并且用户拥有额外的存储空间、配额和扩展才是重点具有即时可扩展 LV 和 VG
然而,它应该做的是更好地解释安装
这在今天仍然具有现实意义。乌班图22.04。
修复示例:
这不是默认行为,这绝对是荒谬的。我当然想要我的 2TB 硬盘
ssh user@ipaddress
cd ~
df
Run Code Online (Sandbox Code Playgroud)
(注意驱动器: /dev/mapper/ubuntu--vg-ubuntu--lv)
将权限升级到lvm:
sudo lvm
Run Code Online (Sandbox Code Playgroud)
运行 LV 扩展:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Run Code Online (Sandbox Code Playgroud)
现在退出:
exit
Run Code Online (Sandbox Code Playgroud)
然后调整大小:
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Run Code Online (Sandbox Code Playgroud)
新发现的可用空间可视化:
df -h
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
70294 次 |
| 最近记录: |