Hypothetically speaking, say I have a system with the following configuration
- One hard drive (
/dev/sda
) partitioned as.../dev/sda1
: 25G unused space/dev/sda2
: 50G Windows partition/dev/sda3
: 25G unused space
Now I want to combine all of the unused space using LVM so that I have the full 50G available to me for my Ubuntu installation. I don't want to use /dev/sda1
and /dev/sda2
as separate 25G partitions. How can I go about configuring LVM and performing the installation so that I can run Windows and Ubuntu post-install?
Installing Ubuntu with LVM on a single volume group that spans multiple physical partitions
Getting ready
Boot into Ubuntu from a live USB or live CD and open a terminal window (ctrl+alt+T). For convenience sake, run
sudo -i
to change toroot
. We'll be working in this terminal window to set up LVM.LVM Setup
Just to demonstrate that my setup matches that in the question, here's what
fdisk -l /dev/sda
shows in my VMIn answer to the question, and using the same partition structure specified, run the following commands:
pvcreate /dev/sda1 /dev/sda3
<-- Specify all partitions you want to pool for install. These need not necessarily be on the same physical disk.vgcreate vg0 /dev/sda1 /dev/sda3
<-- Here,vg0
is an arbitrary name for the volume groupvgs
and see that we have a 50G (reported as 49.99g) to work with. Now we need to create some logical volumes onto which we'll install Ubuntu. I'm only going to create root and swap partitions, but you could create other partitions as well if, for example, you wanted a separate home partition.lvcreate --name swap --size 4G vg0
<-- this creates a 4G parition I'll use for swaplvcreate --name root --extents 100%free vg0
<-- this creates a new partition that uses all of the remaining space in vg0. We'll use this as our/
(root) partition.That's it for setting up LVM. Now it's time to install Ubuntu.
Ubuntu installation
Run the installer from the live OS to begin installation. When you get to the section titled Installation type select the something else option
Then you assign mount points to the logical volumes we created so that Ubuntu can install the system.
Dual booting
As the install is finishing, grub should install, detect Windows and setup a boot menu that will allow you to boot into either OS.