Resizing a LVM install of Ubuntu 13.10 for Windows 7 Dual-Bootsystems
Resizing a LVM install of Ubuntu 13.10 for Windows 7 Dual-Boot
I have Ubuntu 13.10 installed on my computer. I had done a fresh install and used the LVM filesystem. I now want to install Windows 7 on the same drive. Apparently this isn’t so simple as one might think.
Here are 2 good resources on LVM:
Get Ubuntu Live CD / USB to boot from (this information can be found elsewhere online (via Windows or via Ubuntu)
Boot up Live OS
This should show you the layout of your logical volumes, with my install this displayed as:
--- Logical volume --- LV Path /dev/ubuntu-vg/root LV Name root VG Name ubuntu-vg ... --- Logical volume --- LV Path /dev/ubuntu-vg/swap_1 LV Name swap_1 VG Name ubuntu-vg ...
Here we can see that
/dev/ubuntu-vg/swap_1are what I will need to resize/move first.
sudo lvreduce --resizefs --size -250G /dev/ubuntu-vg/root
lvreducewill shrink the root (
/) logical volume by the size specified by
Xis the number of gigabytes. The size of the logical volume before was ~450 GB, so this shrinks it down to ~200 GB.
Now we need to move the swap volume (
/dev/ubuntu-vg/swap_1) so that is is no longer all the way at the opposite end of the physical volume. Here is a good explanation of how this (slightly) complicated process works. We run this command
lvdisplay --mapwhich will display the range that the logical volumes take up and it will display something like:
--- Segments --- Logical extent 0 to 639: Type linear Physical volume /dev/sda5 Physical extents 0 to 639 --- Segments --- Logical extent 0 to 31: Type linear Physical volume /dev/sda5 Physical extents 1544 to 1575
Now run the command
pvmove --alloc anywhere /dev/sda5:1544-1575 /dev/sda5:640-671which will move the logical volume of
/dev/ubuntu-vg/swap_1(the second segment listed) to be positioned exactly next to
/dev/ubuntu-vg/root(the first segment listed). You will want to replace the values here with the ones that
These are not my values, these are pulled from the explanation linked above.
Now that you have all your logical volumes moved to be contiguous in the physical volume, you can go into GParted and resize the physical volume.
Open GParted and when it loads right click
/dev/sda5and select “Deactivate”.
/dev/sda5and select Resize/Move. Move the right hand slider all the way to the left edge of the used space of the physical volume. Apply the changes.
/dev/sda2and select Resize/Move. Move the right hand slider all the way to the left edge of the used space of the physical volume. Apply the changes.
You should now have unallocated space following
/dev/sda2. You can now create a new NTFS partition with that space to install windows on.
You will now need to follow the steps indicated in Install Windows after Ubuntu to handle Windows overwriting the MBR/Grub.