Finding and using unused disk space?

9,751

Solution 1

screenShot of GParted display

you can extend the current partition to use unused space.

I had SAME scenario as above, with /dev/sda5 having 3.92Gig UNUSED.

sudo vgdisplay

  --- Volume group ---
  VG Name               ub-14-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               9.81 GiB
  PE Size               4.00 MiB
  Total PE              2512
  Alloc PE / Size       1506 / 5.88 GiB
  Free  PE / Size       1006 / 3.93 GiB   <<=== FREE space here...
  VG UUID               Qm1M5I-0TcK-Uoep-nxir-8Ldd-dufJ-UsQ65l

sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ub-14-vg/root
  LV Name                root
.....

sudo lvextend -L+3.92G /dev/ub-14-vg/root

Follow the above by resizing.. (NO NEED to reboot).

sudo resize2fs -p /dev/ub-14-vg/root

/dev/ub-14-vg/root is the LVPath(logical volume path), when you do a vgdisplay command it shows up:

========= In LVM, there are several layers, each builds on top of the other:

PV[s] (Physical Volumes) -> VG[s] (Volume Groups) -> LV[s] (Logical Volumes) -> Filesystems.

Solution 2

Have you looked into using gparted to format that partition? From your Ubuntu install, or from a LiveCD you can use gparted to format and resize your partitions, even after using the initial guided setup from installing Ubuntu.

Here is a tutorial for its use.

Share:
9,751

Related videos on Youtube

Manjeet
Author by

Manjeet

Updated on September 18, 2022

Comments

  • Manjeet
    Manjeet over 1 year

    I installed Ubuntu on my 80GB hard disk. I chose "Guided - use entire disk and set up LVM". The system showed 79.7GB and I chose 39.7GB for the OS. The system is up and now I want to use remaining 40GB space as /data. But I'm unable to find that 40GB. Here are some command outputs that I tried:

    $ fdisk -l
    Disk /dev/sda: 80.0 GB, 80000000000 bytes
    255 heads, 63 sectors/track, 9726 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00007eb9
    
    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        1          32      248832   83  Linux Partition 1 does not end on cylinder boundary.
    /dev/sda2           32        9726    77873153    5  Extended
    /dev/sda5           32        9726    77873152   8e  Linux LVM
    
    $ df -h
    Filesystem                Size  Used Avail Use% Mounted on
    /dev/mapper/dekhoji-root  35G  1.4G   32G   5% /
    none                     998M  228K  997M   1% /dev
    none                    1002M     0 1002M   0% /dev/shm
    none                    1002M  324K 1002M   1% /var/run
    none                    1002M     0 1002M   0% /var/lock
    none                    1002M     0 1002M   0% /lib/init/rw
    none                      35G  1.4G   32G   5% /var/lib/ureadahead/debugfs
    /dev/sda1                228M   31M  185M  15% /boot
    
  • Manjeet
    Manjeet over 11 years
    Thanks - gparted is showing lvm is using the whole disk (minus /boot space) but "df -h" is showing / as 35 GB. I will look into how do I extend the space in the filesystem or if I can create a new logical volume.
  • Manjeet
    Manjeet over 11 years
    Did some more digging and found out the missing space! Since rest of the disk was used in LVM, the system had created the 35GB logical volume and mounted that as /. vgdisplay -v <vg_name> command showed me the unused space. I created another logical volume of the remaining capacity, ran "mkfs -t ext4" on that and mounted it as /data. Problem solved! Thanks SometimesRomano!
  • Tim
    Tim about 9 years
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
  • Mostafa Ahangarha
    Mostafa Ahangarha about 8 years
    It is not a good practice to just paste link for reasons including possibility of removal.
  • 29axe
    29axe over 6 years
    Nice! thank you @tk_samy for the great explanation.
  • tk samy
    tk samy over 6 years
    this topic is easy to forget. I cannot believe I wrote this. coming back to read it and practice. thanks a LOT.