Ubuntu 20.04 上新的 5TiB LVM 仅显示 4.1 TiB 空间

Ubuntu 20.04 上新的 5TiB LVM 仅显示 4.1 TiB 空间

在新安装的 Ubuntu 20.04 上,我连接了第二个大小为 5 TiB 的磁盘。我使用以下命令创建 LVM。

Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

sudo pvcreate /dev/sdb

sudo vgcreate vg_tor /dev/sdb

sudo lvcreate -l 100%FREE -n lvm_tor vg_tor

mkfs.ext4 /dev/vg_tor/lvm_tor

fdisk -l节目

Disk /dev/sdb: 5 TiB, 5497558138880 bytes, 10737418240 sectors
Disk model: Virtual disk
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/mapper/vg_tor-lvm_tor: 4.102 TiB, 5497553944576 bytes, 10737410048 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

丢失的 900GiB 可能是个什么情况?

答案1

你的 lvm 的 sdb 分区的大小是多少?

您可以通过运行以下命令找到它:

 fdisk /dev/sdb

然后你可以按照以下步骤操作:

Command (m for help): d
Partition number (1,2, default 2):
Partition 2 is deleted

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p):
Using default response p
Partition number (2-4, default 2):
First sector ('YOUR FIRST SECTOR'-'TO END', default 'YOUR DEFAULT VALUE'):
Using default value 'YOUR DEFAULT VALUE'
Last sector, +sectors or +size{K,M,G} ('YOUR FIRST SECTOR'-'TO END', default 'YOUR DEFAULT VALUE'):
Using default value 'YOUR DEFAULT VALUE'
Partition 2 of type Linux and of size 'THIS IS YOUR SIZE' is set

Command (m for help): t
Partition number (1,2, default 2): 8e
Partition number (1,2, default 2):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdb: 'YOUR DISK SIZE', 'YOUR DISK bytes', 'YOUR DISK 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: 'YOUR DISK IDENTIFIER'

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        ...         ...       ...      83  Linux
/dev/sdb2            ...         ...       ...      8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
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)
Syncing disks.

并查找“这是您的大小”以查看您的最大 LVM 分区大小。

现在我们需要调整物理卷的大小。

pvresize /dev/sdb2

使用以下命令查看逻辑卷的大小

lvdisplay

现在使用以下命令扩展您的逻辑卷:

lvextend -l +100%FREE /Path/To/Your/LV

-l 表示磁盘扩展

+100%免费添加所有免费范围

然后使用

  lvdisplay

然后调整 ext4 文件系统的大小

resize2fs /dev/'Your VG'/'Your LV'

相关内容