3

My root partition is running out of space, so I'm trying to extend/resize it.

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/u64-root   19G   18G  823M  96% /
none                  4.0K     0  4.0K   0% /sys/fs/cgroup
udev                  235M   12K  235M   1% /dev
tmpfs                  50M  464K   49M   1% /run
none                  5.0M     0  5.0M   0% /run/lock
none                  246M     0  246M   0% /run/shm
none                  100M     0  100M   0% /run/user
/dev/sda1             228M   88M  129M  41% /boot

I've created more than 20G in virtual box to the guest Ubuntu.

$ sudo fdisk -l

Disk /dev/sda: 48.3 GB, 48318382080 bytes
255 heads, 63 sectors/track, 5874 cylinders, total 94371840 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: 0x00001433

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758    41940991    20719617    5  Extended
/dev/sda3        41940992    94371839    26215424   83  Linux
/dev/sda5          501760    41940991    20719616   8e  Linux LVM

Disk /dev/mapper/u64-root: 20.7 GB, 20661141504 bytes
255 heads, 63 sectors/track, 2511 cylinders, total 40353792 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/u64-root doesn't contain a valid partition table

Disk /dev/mapper/u64-swap_1: 532 MB, 532676608 bytes
255 heads, 63 sectors/track, 64 cylinders, total 1040384 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

$ sudo vgs 
  VG   #PV #LV #SN Attr   VSize  VFree
  u64    1   2   0 wz--n- 19.76g 20.00m

$ sudo vgdisplay -v u64
    Using volume group(s) on command line
    Finding volume group "u64"
  --- Volume group ---
  VG Name               u64
  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               19.76 GiB
  PE Size               4.00 MiB
  Total PE              5058
  Alloc PE / Size       5053 / 19.74 GiB
  Free  PE / Size       5 / 20.00 MiB
  VG UUID               0ceVdc-pZwk-gIfx-h1Wi-aJu2-9P9m-BdyB1s

  --- Logical volume ---
  LV Path                /dev/u64/root
  LV Name                root
  VG Name                u64
  LV UUID                oBFvFd-EWm3-yCzy-uP3b-GJ33-qeNS-LN9VJx
  LV Write Access        read/write
  LV Creation host, time u64, 2013-03-05 15:44:40 +0800
  LV Status              available
  # open                 1
  LV Size                19.24 GiB
  Current LE             4926
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/u64/swap_1
  LV Name                swap_1
  VG Name                u64
  LV UUID                Inr5EC-q90t-05Jj-0p9L-2Nb3-UWjo-2T2dsr
  LV Write Access        read/write
  LV Creation host, time u64, 2013-03-05 15:44:41 +0800
  LV Status              available
  # open                 2
  LV Size                508.00 MiB
  Current LE             127
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

  --- Physical volumes ---
  PV Name               /dev/sda5
  PV UUID               HbjvW7-SEit-o5LE-jnne-fgAI-C3lB-oyzgVC
  PV Status             allocatable
  Total PE / Free PE    5058 / 5

However, I am blocked by this error.

$ sudo lvextend -L+10G /dev/mapper/u64-root

  Extending logical volume root to 29.24 GiB
  Insufficient free space: 2560 extents needed, but only 5 available

I do have space, but it says it is insufficient. I want to extend both root volume and the temp partition. Any idea how to fix that?

1
  • You are missing two steps, at least; /dev/sda3 should be turn to a physical volume. then added to a volume group, then you can extends lv root. can you provide vgdisplay -v u64 and vgs (or vgscan) ?
    – Archemar
    Commented Sep 28, 2014 at 19:02

2 Answers 2

2

resize root volume with lvextend insufficent space error because of you have not enough space in u64(Volume Group). When you give command:

$ sudo vgs 

  VG   #PV #LV #SN Attr   VSize  VFree

  u64    1   2   0 wz--n- 19.76g 20.00m

it shows remain free space in volume group is 20 MB. You only extend this space only.

If you actually extend the extend space in lv(logical Volume). Please follow the bellow step

Step 1: First add disk on your virtual Box: Setting>Storage>Add new disk(+)

Step 2: After add new disk execute bellow command what it is.

   $ sudo fdisk -l

It will show ( as example: /dev/sdb ) new disk with no partition table.

Step 3: Now make a partition on /dev/sdb as /dev/sdb1 with system id 8e for LVM.

Step 4: If give error or warring as kernel still uses old partition table then reboot your virtual machine or execute partprobe command

  $ sudo partprobe

Step 5: Now create a physical volume(pv). By following command

  $ sudo pvcreate /dev/sdb1

Step 6: Extend your volume group by executing bellow command

  $ sudo vgextend u64 /dev/sdb1

Step 7: For check If you execute vgs or vgdisplay you will see the space in VFree. Or Free PE / Size .

Step 8: Now extend your logical volume

  $ sudo lvextend -L +10G /dev/u64/root

  $ sudo resize2fs /dev/u64/root

If it is xfs filesystem replace resize2fs instead of xfs_growfs

Step 9: Now finally check it

 $ df -hT
1

First, I create a partition type 8e(LVM) on /dev/sda3, and extend current volume group size by adding physical volume into volume group u64 vgextend u64 /dev/sda3.

Second, extend logical volume root lvextend -L+22g u64/root.

Third, resize the ext4 filesystem resize2fs /dev/mapper/u64-root.

Similarly, extend the swap logical volume lvextend -L+3g u64/swap_1 and swapoff /dev/u64/swap_1; mkswap /dev/u64/swap_1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .