2011-10-09 Robert Millan <rmh@gnu.org>
LVM support for FreeBSD and GNU/kFreeBSD. * util/lvm.c (grub_util_lvm_isvolume): Enable on FreeBSD and GNU/kFreeBSD. (LVM_DEV_MAPPER_STRING): Move from here ... * include/grub/util/lvm.h (LVM_DEV_MAPPER_STRING): ... to here. * util/getroot.c: Include `<grub/util/lvm.h>'. (grub_util_get_dev_abstraction): Enable grub_util_biosdisk_is_present() on FreeBSD and GNU/kFreeBSD. Check for LVM abstraction on FreeBSD and GNU/kFreeBSD. (grub_util_get_grub_dev): Replace "/dev/mapper/" with `LVM_DEV_MAPPER_STRING'. Enable LVM and mdRAID only on platforms that support it. * util/grub-setup.c (main): Check for LVM also on FreeBSD and GNU/kFreeBSD. * util/grub.d/10_kfreebsd.in: Load `geom_linux_lvm' kernel module when LVM abstraction is required for ${GRUB_DEVICE}.
This commit is contained in:
parent
050e8e9080
commit
a98f4a0808
6 changed files with 58 additions and 18 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2011-10-09 Robert Millan <rmh@gnu.org>
|
||||
|
||||
LVM support for FreeBSD and GNU/kFreeBSD.
|
||||
|
||||
* util/lvm.c (grub_util_lvm_isvolume): Enable on FreeBSD and
|
||||
GNU/kFreeBSD.
|
||||
(LVM_DEV_MAPPER_STRING): Move from here ...
|
||||
* include/grub/util/lvm.h (LVM_DEV_MAPPER_STRING): ... to here.
|
||||
* util/getroot.c: Include `<grub/util/lvm.h>'.
|
||||
(grub_util_get_dev_abstraction): Enable
|
||||
grub_util_biosdisk_is_present() on FreeBSD and GNU/kFreeBSD.
|
||||
Check for LVM abstraction on FreeBSD and GNU/kFreeBSD.
|
||||
(grub_util_get_grub_dev): Replace "/dev/mapper/" with
|
||||
`LVM_DEV_MAPPER_STRING'. Enable LVM and mdRAID only on platforms that
|
||||
support it.
|
||||
* util/grub-setup.c (main): Check for LVM also on FreeBSD and
|
||||
GNU/kFreeBSD.
|
||||
* util/grub.d/10_kfreebsd.in: Load `geom_linux_lvm' kernel module
|
||||
when LVM abstraction is required for ${GRUB_DEVICE}.
|
||||
|
||||
2011-10-06 Szymon Janc <szymon@janc.net.pl>
|
||||
|
||||
Add support for LZO compression in GRUB:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* lvm.h - LVM support for GRUB utils. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,7 +20,14 @@
|
|||
#ifndef GRUB_LVM_UTIL_HEADER
|
||||
#define GRUB_LVM_UTIL_HEADER 1
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
|
||||
#ifdef __linux__
|
||||
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
|
||||
#else
|
||||
#define LVM_DEV_MAPPER_STRING "/dev/linux_lvm/"
|
||||
#endif
|
||||
|
||||
int grub_util_lvm_isvolume (char *name);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* getroot.c - Get root device */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -33,6 +33,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/lvm.h>
|
||||
#include <grub/cryptodisk.h>
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
|
@ -856,12 +857,14 @@ grub_util_get_geom_abstraction (const char *dev)
|
|||
int
|
||||
grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused)))
|
||||
{
|
||||
#ifdef __linux__
|
||||
enum grub_dev_abstraction_types ret;
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
/* User explicitly claims that this drive is visible by BIOS. */
|
||||
if (grub_util_biosdisk_is_present (os_dev))
|
||||
return GRUB_DEV_ABSTRACTION_NONE;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
enum grub_dev_abstraction_types ret;
|
||||
|
||||
/* Check for LVM and LUKS. */
|
||||
ret = grub_util_get_dm_abstraction (os_dev);
|
||||
|
@ -880,6 +883,10 @@ grub_util_get_dev_abstraction (const char *os_dev __attribute__((unused)))
|
|||
grub_util_info ("abstraction of %s is %s", os_dev, abs);
|
||||
if (abs && grub_strcasecmp (abs, "eli") == 0)
|
||||
return GRUB_DEV_ABSTRACTION_GELI;
|
||||
|
||||
/* Check for LVM. */
|
||||
if (!strncmp (os_dev, LVM_DEV_MAPPER_STRING, sizeof(LVM_DEV_MAPPER_STRING)-1))
|
||||
return GRUB_DEV_ABSTRACTION_LVM;
|
||||
#endif
|
||||
|
||||
/* No abstraction found. */
|
||||
|
@ -1111,11 +1118,12 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
|
||||
switch (grub_util_get_dev_abstraction (os_dev))
|
||||
{
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
case GRUB_DEV_ABSTRACTION_LVM:
|
||||
|
||||
{
|
||||
unsigned short i, len;
|
||||
grub_size_t offset = sizeof ("/dev/mapper/") - 1;
|
||||
grub_size_t offset = sizeof (LVM_DEV_MAPPER_STRING) - 1;
|
||||
|
||||
len = strlen (os_dev) - offset + 1;
|
||||
grub_dev = xmalloc (len + sizeof ("lvm/"));
|
||||
|
@ -1191,7 +1199,9 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
}
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
case GRUB_DEV_ABSTRACTION_RAID:
|
||||
|
||||
if (os_dev[7] == '_' && os_dev[8] == 'd')
|
||||
|
@ -1267,7 +1277,6 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
else
|
||||
grub_util_error ("unknown kind of RAID device `%s'", os_dev);
|
||||
|
||||
#ifdef __linux__
|
||||
{
|
||||
char *mdadm_name = get_mdadm_uuid (os_dev);
|
||||
struct stat st;
|
||||
|
@ -1292,9 +1301,8 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
free (mdadm_name);
|
||||
}
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
break;
|
||||
#endif /* __linux__ */
|
||||
|
||||
default: /* GRUB_DEV_ABSTRACTION_NONE */
|
||||
grub_dev = grub_util_biosdisk_get_grub_dev (os_dev);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* grub-setup.c - make GRUB usable */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -954,10 +954,12 @@ main (int argc, char *argv[])
|
|||
arguments.dir ? : DEFAULT_DIRECTORY);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
if (grub_util_lvm_isvolume (root_dev))
|
||||
must_embed = 1;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
if (root_dev[0] == 'm' && root_dev[1] == 'd'
|
||||
&& ((root_dev[2] >= '0' && root_dev[2] <= '9') || root_dev[2] == '/'))
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
set -e
|
||||
|
||||
# grub-mkconfig helper script.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# GRUB is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -98,6 +98,12 @@ EOF
|
|||
|
||||
load_kfreebsd_module acpi true
|
||||
|
||||
for abstraction in dummy $(grub-probe -t abstraction --device ${GRUB_DEVICE}) ; do
|
||||
case $abstraction in
|
||||
lvm) load_kfreebsd_module geom_linux_lvm false ;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "${kfreebsd_fs}" in
|
||||
zfs)
|
||||
load_kfreebsd_module opensolaris false
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* lvm.c - LVM support for GRUB utils. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2006,2007,2008 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2006,2007,2008,2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,8 +17,7 @@
|
|||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* We only support LVM on Linux. */
|
||||
#ifdef __linux__
|
||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include <grub/emu/misc.h>
|
||||
#include <grub/util/misc.h>
|
||||
#include <grub/util/lvm.h>
|
||||
|
@ -26,8 +25,6 @@
|
|||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
|
||||
|
||||
int
|
||||
grub_util_lvm_isvolume (char *name)
|
||||
{
|
||||
|
@ -49,4 +46,4 @@ grub_util_lvm_isvolume (char *name)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#endif /* ! __linux__ */
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue