Ubuntu 20.04 new fresh LVM on 5TiB shows just 4.1 TiB space

On a fresh installed Ubuntu 20.04 I attached second disk with size of 5 TiB. I used following commands to create 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 shows

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

What could be the case of the missing 900GiB?


Solution 1:

What is the size of the sdb partition for your lvm?

You can find it by running:

 fdisk /dev/sdb

Then you can follow this:

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.

And looking for 'THIS IS YOUR SIZE' to see your max LVM partition size.

Now we need resize the physical volume.

pvresize /dev/sdb2

Take a look at the size of the logical volume using the

lvdisplay

Now extend your logical volume with:

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

-l is for disk extents

+100%FREE to add all free extents

Then verify this using the

  lvdisplay

Then resize ext4 file systems

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