Skip to content

Get expert_recipe, mdraid, LVM, GPT and grub2 Playing Together on Ubuntu Lucid and Debian Squeeze

July 20, 2012

Hard drives are growing and growing. You can now get 3 TB hard drives and have a ton of storage in each server. But then you notice that your current preseed files are crashing when attempting to install grub2. You hit “alt-f4″ to check for any errors in the logs and all you see are errors about grub2 not being able to embed in a GPT disk.

When a disk size gets up around 2 TB the Debian installer and partman will default to using the GPT partitioning scheme. Unfortunately older versions of partman do not properly setup a disk with GPT when the disks are part of a software RAID. Luckily the fix is not that difficult as it only requires a few additions (or possible alterations if you already use some of these options in your preseed file).

What we need to add is the partition that older versions of partman do not properly create. These partitions are of the type bios_grub and only need to be 1MB in size. This partition gives grub2 a location to place it’s entire loader and allows the BIOS to properly find the grub boot information to load the boot loader. More information about the BIOS boot partition can be found on Wikipedia – BIOS Book Partition.

To add the bios_grub partition in a preseed with partman we add the following to our expert_recipe:

             1 1 1 free                          \
                $iflabel{ gpt }                  \
                method{ biosgrub }               \
             .                                   \

This adds a 1MB partition as the top priority partition and if the disk label is set to “GPT” then the partition is flagged as biosgrub.

Since we’re creating another partition on the disk you will also need to increase the partition numbers used in your RAID array by 1. For example, if we originally were using this RAID setup in the preseed:

d-i     partman-auto-raid/recipe string          \
        1 2 0 ext3 /boot /dev/sda1#/dev/sdb1     \
        .                                        \
        1 2 0 lvm - /dev/sda2#/dev/sdb2          \
        .

We would now need to edit the entry and increase the partitions by 1.

d-i     partman-auto-raid/recipe string          \
        1 2 0 ext3 /boot /dev/sda2#/dev/sdb2     \
        .                                        \
        1 2 0 lvm - /dev/sda3#/dev/sdb3          \
        .

Completed the disk setup in our preseed file looks like this:

d-i     partman-auto/disk string /dev/sda /dev/sdb
d-i     partman-auto/method string raid
d-i     partman-lvm/device_remove_lvm boolean true
d-i     partman-auto/purge_lvm_from_device boolean true
d-i     partman-md/device_remove_md boolean true
d-i     partman-md/confirm_nochanges boolean true
d-i     partman-lvm/confirm boolean true
d-i     partman-auto/choose_recipe select boot-root
d-i     partman-auto-lvm/new_vg_name string vg01
d-i     partman-auto-lvm/guided_size string 100%
d-i     partman-auto-raid/recipe string          \
        1 2 0 ext3 /boot /dev/sda2#/dev/sdb2     \
        .                                        \
        1 2 0 lvm - /dev/sda3#/dev/sdb3          \
        .
d-i     partman-auto/expert_recipe string        \
           boot-root ::                          \
             1 1 1 free                          \
                $iflabel{ gpt }                  \
                method{ biosgrub }               \
             .                                   \
             256 10 256 raid                     \
                $lvmignore{ }                    \
                $primary{ }                      \
                method{ raid }                   \
             .                                   \
             1000 20 1000000 raid                \
                $lvmignore{ }                    \
                $primary{ }                      \
                method{ raid }                   \
             .                                   \
             150% 30 150% swap                   \
                $defaultignore{ }                \
                $lvmok{ }                        \
                lv_name{ lv_swap }               \
                method{ swap }                   \
                format{ }                        \
             .                                   \
             20480 40 20480 ext4                 \
                $defaultignore{ }                \
                $lvmok{ }                        \
                lv_name{ lv_root }               \
                method{ format }                 \
                format{ }                        \
                use_filesystem{ }                \
                filesystem{ ext4 }               \
                mountpoint{ / }                  \
             .                                   \
             1 50 -1 ext4                        \
                $defaultignore{ }                \
                $lvmok{ }                        \
                lv_name{ lv_dummy }              \
             .                                    
d-i     mdadm/boot_degraded boolean true
d-i     partman-md/confirm boolean true
d-i     partman-partitioning/confirm_write_new_label boolean true
d-i     partman/choose_partition select Finish partitioning and write changes to disk
d-i     partman/confirm boolean true
d-i     partman-md/confirm_nooverwrite  boolean true
d-i     partman/confirm_nooverwrite boolean true

Looking for more info on using expert_recipe with preseed? Check out my other blog that goes more in depth, Notes on using expert_recipe in Debian/Ubuntu Preseed Files

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 53 other followers

%d bloggers like this: