0

I am trying to shrink a ubuntu 16.04 extended partition using gparted. gparted and vgdisplay both show say the partition is fully used. So I can't shrink the partition. df says 5% is used (the correct value). Here's the GParted screenshot.

And here's the relevant command line output:

$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               465.28 GiB
  PE Size               4.00 MiB
  Total PE              119112
  Alloc PE / Size       119112 / 465.28 GiB
  Free  PE / Size       0 / 0   
  VG UUID               wfsaCW-GdMo-5QUg-O1YD-8Xiv-kfPG-v42ICj

$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                         7.8G     0  7.8G   0% /dev
tmpfs                        1.6G  9.4M  1.6G   1% /run
/dev/mapper/ubuntu--vg-root  443G   21G  400G   5% /
tmpfs                        7.9G  256K  7.9G   1% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                        7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/sda1                    472M  374M   75M  84% /boot
tmpfs                        1.6G   48K  1.6G   1% /run/user/1000
/dev/sdb1                    1.4G  1.4G     0 100% /media/admin/Ubuntu 16.04 LTS amd64

$ sudo lvdisplay 
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                6Hr4D4-NBbX-pcbI-iVNR-CcGY-ORbh-Jaoqdm
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-05-09 05:32:18 -0600
  LV Status              available
  # open                 1
  LV Size                449.32 GiB
  Current LE             115026
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                ce21kC-7P1j-GLFs-YaSF-9yQj-fS3H-ZkhS2p
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2016-05-09 05:32:18 -0600
  LV Status              available
  # open                 2
  LV Size                15.96 GiB
  Current LE             4086
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

Note also that this is an ubuntu partition as installed using the default install with LVM. No advanced settings. What am I missing? I was only introduced to logical volume management today. Thanks!

1 Answers1

2

I think it because df -h tells you the percentage of the filesystem you are using and vgdisplay tells you the percentage of the volume group you are using.

  • A volume group is composed of "hard disks" (it's a little bit more complex than that).
  • A logical volume is like a partition on top of a volume group instead of directly a hard disk.
  • A filesystem can be installed in a logical volume (like it would be in a partition)

If you want to shrink the disk space you are using at the moment, you have to:

  1. Shrink the filesystem
  2. Shrink a logical volume

Then you'll have some space in your volume group you can allocate, for example, to another logical volume and create inside it another filesystem.

But before you try anything, backup your data. You never know what could happen.

After that, and before you begin working on your hard disk, I would recommend that you read at least the first few pages of A Beginner's Guide To LVM because what I have explained here is really rudimentary.

Be careful about what you're going to do. And I'm not responsible if you lose some data.

EvensF
  • 156
  • 5