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-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:
/* 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
#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
/* 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
#include <stdlib.h>
#include <stdint.h>
#include <grub/util/misc.h>
+#include <grub/util/lvm.h>
#include <grub/cryptodisk.h>
#ifdef HAVE_DEVICE_MAPPER
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);
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. */
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/"));
}
#endif
break;
+#endif
+#ifdef __linux__
case GRUB_DEV_ABSTRACTION_RAID:
if (os_dev[7] == '_' && os_dev[8] == 'd')
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;
free (mdadm_name);
}
}
-#endif /* __linux__ */
-
break;
+#endif /* __linux__ */
default: /* GRUB_DEV_ABSTRACTION_NONE */
grub_dev = grub_util_biosdisk_get_grub_dev (os_dev);
/* 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
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] == '/'))
{
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
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
/* 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
* 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>
#include <string.h>
#include <sys/stat.h>
-#define LVM_DEV_MAPPER_STRING "/dev/mapper/"
-
int
grub_util_lvm_isvolume (char *name)
{
return 1;
}
-#endif /* ! __linux__ */
+#endif