View Full Version : New 12.04 install using Advance Format Drive and LVM

January 24th, 2013, 09:49 PM
I cannot seem to find a way through to successfully installing 12.04 onto a 2TB Western Digital Advance Format drive. Using LVM. From the Alternate Install DVD.

This is to set up a home server. I am going to be adding more drives after completing the basic build.

There are various threads on the topic but those I found generally end up discussing the merits of either LVM or WD.

Going through a Normal Install (choosing LVM and allocate 30GB) I end up with a misaligned extended partition and a warning to this effect showing up on the DiskUtility (palimset).

I have tried realigning using fdisk but this always results in a broken system and a complete rebuild.

How do I either a) avoid this situation during the install or b) correct the alignment, whilst retaining my WD drive and LVM?

January 25th, 2013, 11:17 AM
Tried again using a default install and no LVM. Using entire disk. In this case the boot partition was aligned correctly, started at 2048, but the extended partition containing swap was misaligned.

January 25th, 2013, 11:33 AM
You can try simply creating the partitions in advance with parted. parted is very precise when creating partitions and can work with many different units like sectors, MiB, GiB, etc. I usually start of with MiB to align the first partitions starting at 2048 sectors (1MiB). But note that some 4k disks might have different sector size. parted can also show you the logical and physical sector size.

Separate /boot partition is no longer needed for LVM but I think it might help having it. So, to create a /boot partition of 500MiB with parted you would do something like (also starting with new blank gpt table if you don't use dual boot).

sudo parted /dev/sda
mklabel gpt
unit MiB
mkpart GRUB 1 2
set 1 bios_grub on
mkpart BOOT 2 502

That will create 1MiB bios_grub partition which you need for grub2 if you use gpt table, and 500MiB partition that you will use as ext4 /boot during the install. If you want you can continue creating partitions while the unit is still MiB, so to create a 100GiB partition marked as lvm you would do like:

mkpart LVM1 502 102902
set 3 lvm on

The above assumes the partition is #3 and it will set the lvm flag on it so that it can be used as physical device for LVM later easily.

EDIT NOTE: If you decide to go with gpt and bios_grub partition, DO NOT format it as any filesystem. it should have NO filesystem. Just create it with parted, set the bios_grub flag and that's it. The installer will use it while installing grub2 to the MBR.

EDIT PPS: Most 4k disks have logical sector size of 512B for compatibility reason, but 4096B physical sector size so that more capacity can fit on the plates. The disk electronics usually handles the logic of the difference between the logical and physical sector size, so to the machine the hdd looks exactly like the older 512B disks. But in some cases the logical sector size can be 4096B too, so be careful if working with sectors. That's why I prefer MiB in parted because MiB is a MiB regardless of sector size.

If you have any questions, ask. You can see details about the disk and the sector size and total number of sectors with:
sudo parted /dev/sda print

January 25th, 2013, 01:03 PM
darkod. Thanks for the reply. After doing the normal install wihout LVM and still finding the partitions mis-aligned I managed succesfully to use Parted to realign and the system even rebooted afterwards. However I want to use LVM so your approach is better for me. However I am more a user than a system expert and there is material in your reply regarding gpt I need to understand better before jumping in. So I am going to review for a couple of hours and then will let you know how I get on.

January 25th, 2013, 01:37 PM
GPT is a type of partition table that is used with larger disks, because the older more common type of MSDOS (MBR) table has a 2.2TB limitation. In your case, for a 2TB disk msdos table would still do the job, but if using only linux on the machine you might as well use gpt because it has some benefits (I haven't gone into details exactly which ones).

When using the parted mkpart command, depending if the table is msdos or gpt, the syntax is different. For msdos partition you specify the type as primary or logical, and for gpt partition you only specify a label (it has to have it). With gpt there is no 4 primary partition limit (all partitions are considered as primary and you have many of them), so when you create it with mkpart you specify a label instead of primary/logical. So, the syntax for msdos or gpt partition is:

mkpart <primary/logical> <start> <end>
mkpart <label> <start> <end>

January 25th, 2013, 01:57 PM
Thanks. Your GPT info answered a question I was just about to ask re the format of the mkpart command.

In your example you set /boot to just 500Mb. I guess it can be made larger later but am interested in why not the 10-20Gb I would have expected. Presumbably you have /home on another partition? The reason for asking is that the partition selection options during the install really are not intuitive.

black veils
January 25th, 2013, 02:29 PM
about LVM:

when i setup LVM, i think it was an alternate installer, and choose options then expert mode or something like that.

you get lots of questions etc this can be lessened by choosing from a setting in the expert mode menu.

if it is to be the only system on that hard drive, then you can choose the guided with LVM and encryption option instead of the tedious manual partitioning. if doing it the manual way, this is what helped me: http://www.linuxbsdos.com/2011/05/10/how-to-install-ubuntu-11-04-on-an-encrypted-lvm-file-system/

January 25th, 2013, 02:53 PM
Thanks. Your GPT info answered a question I was just about to ask re the format of the mkpart command.

In your example you set /boot to just 500Mb. I guess it can be made larger later but am interested in why not the 10-20Gb I would have expected. Presumbably you have /home on another partition? The reason for asking is that the partition selection options during the install really are not intuitive.

Don't confuse /boot with the main system partition / (root).

If you have separate /boot partition it holds only few small boot files. Often even 100MiB is enough, but make it 500MiB for safety, not to run out of space. The kernels are also kept there.

You will still have / partition, in this case with LVM you will have a root LV. If you want separate /home, that will be another LV with mount point /home.

Yes, the / should be at least 10-15GiB, even more if you have large programs. If you have space to spare on the hdd (LVM), about 25GiB for / should be plenty. Linux is not as demanding with space about programs as windows is.

Also note in the above posts that you need the bios_grub partition only if you use gpt table. This is because grub2 can fit on the MBR of msdos disks, but not on the MBR of gpt disks (the MBR itself is smaller). That's why it looks where is the bios_grub flag and uses that partition. The space needed is very small, literary the 1MiB is enough.

January 25th, 2013, 04:13 PM
Thanks for the help. Just walked away from trying to setup the install. Even as a reasonably experienced Ubuntu user it is beyond being just difficult to work through the partitioning options.

I cannot use the guided with LVM options because it appears to want to over write the partitions I have already set from your notes. I have no confidence in setting the additional partitions it want (/root, swap .. toot, hoot whatever :) because I don't trust it to align onto 4096 byte boundaries and I don't know whether or not it is going to use LVM. Also I don't have a calculator with enough digits to guarantee the accuracy needed when calculating.

Just going out into the snow to chop some wood in order to calm down a bit. Hopefully I will have enough fingers on return to either try again or ...

I might just do the base LVM system install onto a 20MB (old format) drive I have, then add the new drive onto that later. Not what I wanted.

January 25th, 2013, 05:07 PM
If you also created the large partition with the lvm flag with parted, when installing with the alternate cd is very easy. At the partitioning stage select Manual. It will show the partition list.

Lets assume you took my example with gpt table and you have:
sda1 1MB bios_grub flag
sda2 500MB
sda3 ...GB lvm flag

Leave sda1 alone.

Using the up/down arrows select sda2, hit Enter. New menu will open. In the Use As select ext4, mount point /boot. That's it, select Finished with the partition. It will take you back to the list.

Then look above the partition list, you will see option Configure LVM. Open it and it will start the process for you. Don't take my word literary because I don't remember the exact syntax of every field, but it goes like this in general:
It will ask you which device to use a physical device for the LVM. select sda3 (note, in the text menus you select with Space bar, not Enter).
Then it should ask you about creating Volume Group, just create a single one and name it as you wish, taking the maximum space.
Then in that VG you will need to create Logical Volumes, one or more as you wish.
One can be LV for root for example, another for /home. Assign them limited space, not all of the VG. You can grow them later. For example, assign 10GB for LV root, and 20GB for LV /home.
You are done with the LVM configuration, it should return you to the main partition list. You will see the new LVs there.

Select the one for root, in Use As put ext4, mount point /.
For the one for /home, also ext4, mount point /home.
You might also make a LV for swap, I forgot. That is used as swap area, it doesn't have mount point.

And that's it. You finish the partitioning changes and go on with the install.

January 25th, 2013, 08:52 PM
Excellent I now have an installed baseline system using LVM on an Advance Format drive - and no alignment warnings. It would have taken me a week of trying alone to work through the installation partition selection sequences - probably I would have given up and used an old style drive for the system install instead.

For the record I used Lubuntu 11.04 Live to prepare the disk for the install.

My thanks to darkod.