Skip to content

Commit

Permalink
Add support for lvm2 and device-mapper
Browse files Browse the repository at this point in the history
Reviewed By: puneet, dustin

This patch adds support for logical volume management, specifically
lvm2.  This cuts across a number of components:

GRUB -- adds support for loading the kernel and initrd from logical
        volumes.

Linux Kernel -- adds device mapper support, which lvm2 is built on top
                of.

user space -- adds lvm2 utilities for creating / managing logical
              volumes.

Testing Done:

1.  Boot into ONIE.
2.  Create a volume group on /dev/sda4
3.  Create a logical volume
4.  Create a ext4 file system on logical volume, with a label
5.  Mount logical volume
6.  copy ONIE kernel and initramfs to logical volume
7.  umount logical volume
8.  Reboot, stopping in grub
9.  From grub 'insmod lvm'
10. grub> ls  -- shows the logical volume
11. grub> search command finds partition by file system label
12. grub> load kernel and initramfs from volume
13. grub> boot -- boots in ONIE from logical volume
  • Loading branch information
Curt Brune committed Mar 18, 2014
1 parent 9595e73 commit 6ccd82c
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 2 deletions.
3 changes: 3 additions & 0 deletions build-config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ ifeq ($(GPT_ENABLE),yes)
include make/popt.make
include make/gptfdisk.make
endif
ifeq ($(LVM2_ENABLE),yes)
include make/lvm2.make
endif
ifeq ($(GRUB_ENABLE),yes)
include make/grub.make
endif
Expand Down
2 changes: 2 additions & 0 deletions build-config/arch/x86_64.make
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ I2CTOOLS_ENABLE ?= yes

DMIDECODE_ENABLE = yes

LVM2_ENABLE = yes

# Update this if the GRUB configuration mechanism changes from one
# release to the next.
ONIE_CONFIG_VERSION = 0
Expand Down
33 changes: 32 additions & 1 deletion build-config/conf/linux.x86_64.config
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,30 @@ CONFIG_PATA_PLATFORM=y
# Generic fallback / legacy drivers
#
# CONFIG_PATA_LEGACY is not set
# CONFIG_MD is not set
CONFIG_MD=y
CONFIG_BLK_DEV_MD=y
CONFIG_MD_AUTODETECT=y
CONFIG_MD_LINEAR=y
CONFIG_MD_RAID0=y
CONFIG_MD_RAID1=y
CONFIG_MD_RAID10=y
CONFIG_MD_RAID456=y
# CONFIG_MULTICORE_RAID456 is not set
# CONFIG_MD_MULTIPATH is not set
# CONFIG_MD_FAULTY is not set
CONFIG_BLK_DEV_DM=y
# CONFIG_DM_DEBUG is not set
CONFIG_DM_CRYPT=y
CONFIG_DM_SNAPSHOT=y
# CONFIG_DM_THIN_PROVISIONING is not set
CONFIG_DM_MIRROR=y
CONFIG_DM_RAID=y
# CONFIG_DM_LOG_USERSPACE is not set
# CONFIG_DM_ZERO is not set
# CONFIG_DM_MULTIPATH is not set
# CONFIG_DM_DELAY is not set
CONFIG_DM_UEVENT=y
# CONFIG_DM_FLAKEY is not set
# CONFIG_TARGET_CORE is not set
# CONFIG_FUSION is not set

Expand Down Expand Up @@ -2152,6 +2175,7 @@ CONFIG_TRACING_SUPPORT=y
# CONFIG_DYNAMIC_DEBUG is not set
# CONFIG_DMA_API_DEBUG is not set
# CONFIG_ATOMIC64_SELFTEST is not set
# CONFIG_ASYNC_RAID6_TEST is not set
# CONFIG_SAMPLES is not set
CONFIG_HAVE_ARCH_KGDB=y
# CONFIG_KGDB is not set
Expand Down Expand Up @@ -2193,6 +2217,12 @@ CONFIG_KEYS=y
# CONFIG_SECURITYFS is not set
CONFIG_DEFAULT_SECURITY_DAC=y
CONFIG_DEFAULT_SECURITY=""
CONFIG_XOR_BLOCKS=y
CONFIG_ASYNC_CORE=y
CONFIG_ASYNC_MEMCPY=y
CONFIG_ASYNC_XOR=y
CONFIG_ASYNC_PQ=y
CONFIG_ASYNC_RAID6_RECOV=y
CONFIG_CRYPTO=y

#
Expand Down Expand Up @@ -2312,6 +2342,7 @@ CONFIG_HAVE_KVM=y
#
# Library routines
#
CONFIG_RAID6_PQ=y
CONFIG_BITREVERSE=y
CONFIG_GENERIC_FIND_FIRST_BIT=y
# CONFIG_CRC_CCITT is not set
Expand Down
4 changes: 3 additions & 1 deletion build-config/make/grub.make
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ $(GRUB_SOURCE_STAMP): $(TREE_STAMP) | $(GRUB_DOWNLOAD_STAMP)
$(Q) touch $@

grub-configure: $(GRUB_CONFIGURE_STAMP)
$(GRUB_CONFIGURE_STAMP): $(GRUB_SOURCE_STAMP) | $(DEV_SYSROOT_INIT_STAMP)
$(GRUB_CONFIGURE_STAMP): $(GRUB_SOURCE_STAMP) $(LVM2_INSTALL_STAMP) | $(DEV_SYSROOT_INIT_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Configure grub-$(GRUB_VERSION) ===="
$(Q) cd $(GRUB_DIR) && PATH='$(CROSSBIN):$(PATH)' \
$(GRUB_DIR)/configure \
--prefix=/usr \
--host=$(TARGET) \
--enable-device-mapper \
--disable-nls \
--disable-efiemu \
CC=$(CROSSPREFIX)gcc \
CPPFLAGS="$(ONIE_CPPFLAGS)" \
CFLAGS="$(ONIE_CFLAGS)" \
LDFLAGS="$(ONIE_LDFLAGS)"
$(Q) touch $@
Expand Down
1 change: 1 addition & 0 deletions build-config/make/images.make
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ PACKAGES_INSTALL_STAMPS = \
$(MTDUTILS_INSTALL_STAMP) \
$(DROPBEAR_INSTALL_STAMP) \
$(I2CTOOLS_INSTALL_STAMP) \
$(LVM2_INSTALL_STAMP) \
$(DMIDECODE_INSTALL_STAMP)

ifeq ($(GPT_ENABLE),yes)
Expand Down
173 changes: 173 additions & 0 deletions build-config/make/lvm2.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#-------------------------------------------------------------------------------
#
#
#-------------------------------------------------------------------------------
#
# This is a makefile fragment that defines the build of lvm2
#

LVM2_VERSION = 2_02_105
LVM2_TARBALL = lvm2-$(LVM2_VERSION).tar.xz
LVM2_TARBALL_URLS += $(ONIE_MIRROR) https://git.fedorahosted.org/cgit/lvm2.git/snapshot/
LVM2_BUILD_DIR = $(MBUILDDIR)/lvm2
LVM2_DIR = $(LVM2_BUILD_DIR)/lvm2-$(LVM2_VERSION)

LVM2_SRCPATCHDIR = $(PATCHDIR)/lvm2
LVM2_DOWNLOAD_STAMP = $(DOWNLOADDIR)/lvm2-download
LVM2_SOURCE_STAMP = $(STAMPDIR)/lvm2-source
LVM2_PATCH_STAMP = $(STAMPDIR)/lvm2-patch
LVM2_CONFIGURE_STAMP = $(STAMPDIR)/lvm2-configure
LVM2_BUILD_STAMP = $(STAMPDIR)/lvm2-build
LVM2_INSTALL_STAMP = $(STAMPDIR)/lvm2-install
LVM2_STAMP = $(LVM2_SOURCE_STAMP) \
$(LVM2_CONFIGURE_STAMP) \
$(LVM2_BUILD_STAMP) \
$(LVM2_INSTALL_STAMP)

PHONY += lvm2 lvm2-download lvm2-source lvm2-patch lvm2-configure \
lvm2-build lvm2-install lvm2-clean lvm2-download-clean

# List of libraries and programs to install in the final sysroot for
# lvm2. All the paths are relative to $(DEV_SYSROOT)/usr.

LVM2_PROGS = \
lib/libdevmapper.so lib/libdevmapper.so.1.02 \
sbin/lvm \
sbin/lvchange \
sbin/lvconvert \
sbin/lvcreate \
sbin/lvdisplay \
sbin/lvextend \
sbin/lvmchange \
sbin/lvmdiskscan \
sbin/lvmsadc \
sbin/lvmsar \
sbin/lvreduce \
sbin/lvremove \
sbin/lvrename \
sbin/lvresize \
sbin/lvs \
sbin/lvscan \
sbin/pvchange \
sbin/pvresize \
sbin/pvck \
sbin/pvcreate \
sbin/pvdisplay \
sbin/pvmove \
sbin/pvremove \
sbin/pvs \
sbin/pvscan \
sbin/vgcfgbackup \
sbin/vgcfgrestore \
sbin/vgchange \
sbin/vgck \
sbin/vgconvert \
sbin/vgcreate \
sbin/vgdisplay \
sbin/vgexport \
sbin/vgextend \
sbin/vgimport \
sbin/vgmerge \
sbin/vgmknodes \
sbin/vgreduce \
sbin/vgremove \
sbin/vgrename \
sbin/vgs \
sbin/vgscan \
sbin/vgsplit \
sbin/dmsetup

lvm2: $(LVM2_STAMP)

DOWNLOAD += $(LVM2_DOWNLOAD_STAMP)
lvm2-download: $(LVM2_DOWNLOAD_STAMP)
$(LVM2_DOWNLOAD_STAMP): $(PROJECT_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Getting upstream lvm2 ===="
$(Q) $(SCRIPTDIR)/fetch-package $(DOWNLOADDIR) $(UPSTREAMDIR) \
$(LVM2_TARBALL) $(LVM2_TARBALL_URLS)
$(Q) touch $@

SOURCE += $(LVM2_SOURCE_STAMP)
lvm2-source: $(LVM2_SOURCE_STAMP)
$(LVM2_SOURCE_STAMP): $(TREE_STAMP) | $(LVM2_DOWNLOAD_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Extracting upstream lvm2 ===="
$(Q) $(SCRIPTDIR)/extract-package $(LVM2_BUILD_DIR) $(DOWNLOADDIR)/$(LVM2_TARBALL)
$(Q) touch $@

lvm2-patch: $(LVM2_PATCH_STAMP)
$(LVM2_PATCH_STAMP): $(LVM2_SRCPATCHDIR)/* $(LVM2_SOURCE_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Patching lvm2 ===="
$(Q) $(SCRIPTDIR)/apply-patch-series $(LVM2_SRCPATCHDIR)/series $(LVM2_DIR)
$(Q) touch $@

ifndef MAKE_CLEAN
LVM2_NEW_FILES = $(shell test -d $(LVM2_DIR) && test -f $(LVM2_BUILD_STAMP) && \
find -L $(LVM2_DIR) -newer $(LVM2_BUILD_STAMP) -type f -print -quit)
endif

# The lvm2 configure script is a bit pessimistic about a few things
# while cross compiling. Let it know things are fine...
LVM2_CONFIGURE_OVERRIDES = \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_memcmp_working=yes \
ac_cv_func_mmap_fixed_mapped=yes \
ac_cv_func_realloc_0_nonnull=yes \
ac_cv_func_strtod=yes \
ac_cv_func_chown_works=yes \


lvm2-configure: $(LVM2_CONFIGURE_STAMP)
$(LVM2_CONFIGURE_STAMP): $(LVM2_PATCH_STAMP) | $(DEV_SYSROOT_INIT_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Configure lvm2-$(LVM2_VERSION) ===="
$(Q) cd $(LVM2_DIR) && PATH='$(CROSSBIN):$(PATH)' \
$(LVM2_CONFIGURE_OVERRIDES) \
$(LVM2_DIR)/configure \
--prefix=$(DEV_SYSROOT)/usr \
--host=$(TARGET) \
--with-clvmd=none \
--disable-nls \
--disable-selinux \
CC=$(CROSSPREFIX)gcc \
CFLAGS="$(ONIE_CFLAGS)" \
LDFLAGS="$(ONIE_LDFLAGS)"
$(Q) touch $@

lvm2-build: $(LVM2_BUILD_STAMP)
$(LVM2_BUILD_STAMP): $(LVM2_CONFIGURE_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Building lvm2-$(LVM2_VERSION) ===="
$(Q) PATH='$(CROSSBIN):$(PATH)' $(MAKE) -C $(LVM2_DIR) \
CROSS_COMPILE=$(CROSSPREFIX) all
$(Q) touch $@

lvm2-install: $(LVM2_INSTALL_STAMP)
$(LVM2_INSTALL_STAMP): $(SYSROOT_INIT_STAMP) $(LVM2_BUILD_STAMP)
$(Q) rm -f $@ && eval $(PROFILE_STAMP)
$(Q) echo "==== Installing lvm2 programs in $(SYSROOTDIR) ===="
$(Q) PATH='$(CROSSBIN):$(PATH)' $(MAKE) -C $(LVM2_DIR) \
CROSS_COMPILE=$(CROSSPREFIX) install
$(Q) for file in $(LVM2_PROGS) ; do \
cp -afv $(DEV_SYSROOT)/usr/$$file $(SYSROOTDIR)/usr/$$file ; \
chmod +w $(SYSROOTDIR)/usr/$$file ; \
done
$(Q) touch $@

USERSPACE_CLEAN += lvm2-clean
lvm2-clean:
$(Q) rm -rf $(LVM2_BUILD_DIR)
$(Q) rm -f $(LVM2_STAMP)
$(Q) echo "=== Finished making $@ for $(PLATFORM)"

DOWNLOAD_CLEAN += lvm2-download-clean
lvm2-download-clean:
$(Q) rm -f $(LVM2_DOWNLOAD_STAMP) $(DOWNLOADDIR)/$(LVM2_TARBALL)

#-------------------------------------------------------------------------------
#
# Local Variables:
# mode: makefile-gmake
# End:
30 changes: 30 additions & 0 deletions patches/lvm2/lvm2-conf-install-directory-fixup.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
lvm2 conf install directory fixup

The lvm2 install target for the conf/ subdirectory is not quite right
for cross compiling. It tries to install files in /etc instead of the
target sysroot directory.

diff --git a/conf/Makefile.in b/conf/Makefile.in
index 3f66621..4193111 100644
--- a/conf/Makefile.in
+++ b/conf/Makefile.in
@@ -24,14 +24,14 @@ PROFILES=$(DEFAULT_PROFILE) $(srcdir)/thin-performance.profile
include $(top_builddir)/make.tmpl

install_conf: $(CONFSRC)
- @if [ ! -e $(confdir)/$(CONFDEST) ]; then \
- echo "$(INSTALL_WDATA) -D $< $(confdir)/$(CONFDEST)"; \
- $(INSTALL_WDATA) -D $< $(confdir)/$(CONFDEST); \
+ @if [ ! -e $(sysconfdir)/$(CONFDEST) ]; then \
+ echo "$(INSTALL_WDATA) -D $< $(sysconfdir)/$(CONFDEST)"; \
+ $(INSTALL_WDATA) -D $< $(sysconfdir)/$(CONFDEST); \
fi

install_profiles: $(PROFILES)
- $(INSTALL_DIR) $(DESTDIR)$(DEFAULT_PROFILE_DIR)
- $(INSTALL_DATA) $(PROFILES) $(DESTDIR)$(DEFAULT_PROFILE_DIR)/
+ $(INSTALL_DIR) $(sysconfdir)/profile
+ $(INSTALL_DATA) $(PROFILES) $(sysconfdir)/profile/

install_lvm2: install_conf install_profiles

2 changes: 2 additions & 0 deletions patches/lvm2/series
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This series applies on GIT commit ad50b40707ea89ec1f8b9d3071df331dc3b289fd
lvm2-conf-install-directory-fixup.patch
1 change: 1 addition & 0 deletions upstream/lvm2-2_02_105.tar.xz.sha1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
89b48344606ab35ecc5d89d6434598a8b1407345 lvm2-2_02_105.tar.xz

0 comments on commit 6ccd82c

Please sign in to comment.