Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have installed Ubuntu 12.10 as the only OS on my system.

I told Ubuntu to overwrite everything as I was in a hurry, hence I only have the two partitions Ubuntu creates, the Boot Partition of a couple a hundred MB, and then everything else.

The main partition is about 600GB,

I wish to resize this to 450GB, so I can install Windows 8 as a dual boot.

The issue is that I cannot work out how to shrink the partition, normally it's fine from the Gparted (gparted-live-0.14.1-6-i486.iso) live iso, Simply resize and you are good to go.

But this time Ubuntu has been installed with LVM.

So, the Ubuntu partition has a lock icon next to it. This prevents me from doing anything, I can select the partition, and there is an option for "deactivate" which If I am correct I believe is deactivating swap? If I do that I can manipulate the partition.

I am asking here if this is the correct thing to do before I bust my system.

  1. Boot from the live gparted iso.
  2. Select the Ubuntu partition.
  3. "Deactivate" the partition.
  4. Resize the partition.
  5. "Activate" the partition.
  6. Apply.
  7. Profit???

Is my thinking correct?

Edit #1

So, after some extended chat I came down to this command

sudo lvresize --verbose --resizefs -L -150G /dev/ubuntu/root

Which successfully shrunk the logical partition.

Gparted New Shot

But Now I have the hard part.

Now I need to shrink the Physical Partition down so I can create a new Physical partition with the space to install Windows 8.

So I thought I could run

pvresize --setphysicalvolumesize {any size here} /dev/sda5

But I get back:

/dev/sda5: cannot resize to xxxxx extents as later ones are allocated.

Which I believe is due to the swap due to this image:

Darn Swap!, so what's my next step?

$: lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu/root
  LV Name                root
  VG Name                ubuntu
  LV UUID                G7Z3dA-xska-8QpO-Y5oD-aIVO-D8l1-22s6dO
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2013-01-29 22:06:02 +1300
  LV Status              available
  # open                 1
  LV Size                540.42 GiB
  Current LE             138348
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

  --- Logical volume ---
  LV Path                /dev/ubuntu/swap_1
  LV Name                swap_1
  VG Name                ubuntu
  LV UUID                14qpRy-H5jl-dTAq-CVle-k7Bz-95Rm-Y46zOs
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2013-01-29 22:06:04 +1300
  LV Status              available
  # open                 2
  LV Size                7.97 GiB
  Current LE             2041
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:1

Additional Information Before Edit #1

Gparted Screenshot
Note that the above shot is taken from the Gparted version in the Ubuntu Repositories, not the latest version

matthew@play:~$ sudo fdisk -l

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 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: 0x000c5bec

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758  1465147391   732322817    5  Extended
/dev/sda5          501760  1465147391   732322816   8e  Linux LVM

Disk /dev/mapper/ubuntu-root: 741.3 GB, 741334843392 bytes
255 heads, 63 sectors/track, 90128 cylinders, total 1447919616 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-root doesn't contain a valid partition table

Disk /dev/mapper/ubuntu-swap_1: 8560 MB, 8560574464 bytes
255 heads, 63 sectors/track, 1040 cylinders, total 16719872 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-swap_1 doesn't contain a valid partition table

matthew@play:~$ sudo lvs

  LV     VG     Attr     LSize   Pool Origin Data%  Move Log Copy%  Convert
  root   ubuntu -wi-ao-- 690.42g                                           
  swap_1 ubuntu -wi-ao--   7.97g  

matthew@play:~$ sudo vgs

  VG     #PV #LV #SN Attr   VSize   VFree
  ubuntu   1   2   0 wz--n- 698.39g    0 

matthew@play:~$ sudo pvs

  PV         VG     Fmt  Attr PSize   PFree
  /dev/sda5  ubuntu lvm2 a--  698.39g    0 
share|improve this question
Make sure you run a recent GParted version (only recently gained LVM support - you are, so merely a note for other readers). And deactivating is, I think, deactivating the volume group (vgchange -an myvgname) which may be needed if you are going to change the physical volume. :) Oh, it's almost an answer. –  gertvdijk Feb 7 '13 at 1:04
More details provided. –  Hailwood Feb 7 '13 at 1:26
@gertvdijk Ping me in chat if you need any quick info. –  Hailwood Feb 7 '13 at 1:34
Was this resolved ? I am looking for reducing the physical partition to install another version of OS side by side. –  Jamess Apr 29 '13 at 11:07

2 Answers 2

I'd, now that you've got the smaller root LV, lvremove the swap LV and recreate it. This should force it to be directly appended to the root LV in terms of position. Once that is done you should be able to pvresize the physical volume. Then it's the scary part in editing the partition table (fdisk) to downsize the partition to the PV's new size, thereby freeing up space for the Windows installer to use.

For the downsizing of the partition I'd recommend to go slightly larger, by a few MB, than the PV reports it's size as and upsize the PV and root LV to fill the free extents. That way you can be sure you're A) using all of the partition's size for LVM and not losing space by making it inaccessible, and B) not cutting off vital data from the PV by misinterpreting binary KiB/MiB/GiB for decimal KB/MB/GB or vice versa during the fdisk operation.

The new swap, if you create a new one to ensure it's appended to the root LV as I suggest above, will have a different UUID and therefore your /etc/fstab will not match. Once the resizing is all finished, you will need to mount /dev/ubuntu/root /mnt edit /mnt**/etc/fstab**.

In the fstab file you need to find the swap entry similar to below and update the hexidecimal after UUID= with the value reported by blkid.

Steps for blkid on my system are as follows:

  1. run

    blkid /dev/ubuntu/swap_1

    which outputs

    /dev/ubuntu/swap_1: UUID="9e99b37a-38af-4987-85eb-92048abd9825" TYPE="swap"
  2. copy the UUID value


  3. edit /etc/fstab from your root LV and insert the UUID value in place of the old UUID.


    UUID=**old-uuid** none swap sw 0 0

    replace your new UUID in place of the old-uuid

    UUID=9e99b37a-38af-4987-85eb-92048abd9825 none swap sw 0 0

    alternatively, you could replace the UUID mechanism and use /dev/ubuntu/swap_1, e.g.

    /dev/ubuntu/swap_1 none swap sw 0 0
share|improve this answer
This procedure along with edit's in question helped me to resize the partition. I could not find lvdelete command (12.04) and used lvremove to remove the swap partition. The pvresize worked like a charm. Then I used gparted live CD to resize the the partion to lower size. completed the operation and unallocated size got created. I would suggest the asker should create a complete answer. –  Jamess Apr 29 '13 at 11:39
I incidently was not using UUID (did I change it, I dont remember), may systyem never used UUID for swap. So I could skip UUID editing steps. –  Jamess Apr 29 '13 at 11:40
How to recreate a swap lv 1. lvcreate -L 5G -n /dev/vg0/swap_1 2. mkswap /dev/vg0/swap_1, swapon -s /dev/vg0/swap_1, then validate the /etc/fstab entries and if needed change UUID. –  Jamess Apr 29 '13 at 12:07
Thanks for the mention of lvdelete being incorrect in my answer. I've now fixed the text to cite the proper lvremove name. –  Daniel Llewellyn Jan 13 at 19:17

Use KVPM from Software Center. I installed Ubuntu 14.10 LTS using entire disk one huge LVM (I know what's the point of one huge LVM) but wanted to add another two LVM's for another OS and a data drive. I used KVPM, it says KDE partition manager in description but it works great on 14.04. Here are the steps.

  1. Download 14.04LTS and make a bootable USB.
  2. Boot from USB, using TRY UBUNTU option so you are running on USB stick.
  3. Install KVPM from Software Center.
  4. Run KVPM from the terminal of your choice,

    sudo kvpm - if you just run kvpm, the live CD will give you an error and hang.

  5. Once, kvpm has opened the GUI, go to the tab labelled some_drive-vg

  6. Highlight the volume to be resized and right click for options, choose reduce volume.
  7. You can relabel the LVM at the same time you enter the new size.
  8. Follow the prompts to OK the change and voila, you will have unallocated free space.
  9. You can make as many new LVMs as you need with the available space. My display showed bight green unallocated space, simply right click the green space, you only option will be "Create new logical volume".

It took me longer to write this than it did to execute the whole process.

By the way, the /root partition I resized functions perfectly after all the changes. Just reboot to your HDD in your chosen OS and enjoy your new found volumes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.