Fdisk-l space is large, df -h space is small.

  html5, question

My system is Ubuntu 14.04 LTS

Enter commanddf -h, displayed as follows:

Filesystem                   Size  Used Avail Use% Mounted on
 /dev/mapper/ubuntu--vg-root   19G   18G     0 100% /
 none                         4.0K     0  4.0K   0% /sys/fs/cgroup
 udev                         3.9G   12K  3.9G   1% /dev
 tmpfs                        799M  2.0M  797M   1% /run
 none                         5.0M     0  5.0M   0% /run/lock
 none                         3.9G  4.9M  3.9G   1% /run/shm
 none                         100M     0  100M   0% /run/user
 /dev/vda1                    236M   37M  188M  17% /boot

All the space adds up to just over 20 g, which is not enough immediately.

And inputfdisk -l, the following is displayed:

Disk /dev/vda: 322.1 GB, 322122547200 bytes
 16 heads, 63 sectors/track, 624152 cylinders, total 629145600 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 identifier: 0x0009d617
 
 Device Boot      Start         End      Blocks   Id  System
 /dev/vda1   *        2048      499711      248832   83  Linux
 /dev/vda2          501758    41940991    20719617    5  Extended
 /dev/vda5          503806    41940991    20718593   8e  Linux LVM
 
 Disk /dev/mapper/ubuntu--vg-root: 20.1 GB, 20124270592 bytes
 255 heads, 63 sectors/track, 2446 cylinders, total 39305216 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 identifier: 0x00000000
 
 Disk /dev/mapper/ubuntu--vg-root doesn't contain a valid partition table
 
 Disk /dev/mapper/ubuntu--vg-swap_1: 1069 MB, 1069547520 bytes
 255 heads, 63 sectors/track, 130 cylinders, total 2088960 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 identifier: 0x00000000
 
 Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table

Ask the Great Spirit to interpret and indicate how I can expand the space I use to the size of 300G shown by fdisk.

Status quo: you have a 300G hard disk with two partitions, one is the main partition/dev/vda1,200 m, when mount arrives /boot, an extended partition /dev/vda2 with a logical partition /dev/vda5 occupying 20G of space, LVM is created on /dev/vda5. LVM allocated 19G of them to/dev/mapper/ubuntu-VG-root and mount to the root directory, while the other 1G was allocated to/dev/mapper/ubuntu-VG-swap _ 1 swap partition.

Question: Only 20G was used for 300G of space, and the other 280G was useless.

Solution: Use fdisk to create a new partition in the remaining space, then add the newly created partition to LVM, and finally expand the size of/dev/mapper/Ubuntu-VG-root. I am not familiar with the specific command, and the general idea should be this.