From 4b4bb31891fcb65b60b165cad567f60e9cc0c1b0 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sat, 12 Apr 2014 16:15:54 +0200 Subject: [PATCH] Add lvm-pvclear script --- Makefile | 4 ++-- lvm/Makefile | 15 +++++++++++++++ lvm/pvclear/Makefile | 19 +++++++++++++++++++ lvm/pvclear/lvm-pvclear | 28 ++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 lvm/Makefile create mode 100644 lvm/pvclear/Makefile create mode 100755 lvm/pvclear/lvm-pvclear diff --git a/Makefile b/Makefile index 89cb177..c367987 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # # ax-linux: Alex' Linux Tools & Scripts -# Copyright (c)2013 Alexander Barton (alex@barton.de) +# Copyright (c)2013-2014 Alexander Barton (alex@barton.de) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -8,7 +8,7 @@ # (at your option) any later version. # -SUBDIRS = btrfs +SUBDIRS = btrfs lvm all: $(SUBDIRS) diff --git a/lvm/Makefile b/lvm/Makefile new file mode 100644 index 0000000..32590b9 --- /dev/null +++ b/lvm/Makefile @@ -0,0 +1,15 @@ +# +# ax-linux: Alex' Linux Tools & Scripts +# Copyright (c)2013 Alexander Barton (alex@barton.de) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + +SUBDIRS = pvclear + +all: $(SUBDIRS) + +include ../Makefile.ax diff --git a/lvm/pvclear/Makefile b/lvm/pvclear/Makefile new file mode 100644 index 0000000..2de7213 --- /dev/null +++ b/lvm/pvclear/Makefile @@ -0,0 +1,19 @@ +# +# ax-linux: Alex' Linux Tools & Scripts +# Copyright (c)2013 Alexander Barton (alex@barton.de) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + +all: lvm-pvclear + +install-local: lvm-pvclear + install -d -o $(USER) -g $(GROUP) -m 755 \ + $(DESTDIR)/usr/local/sbin + install -p -o $(USER) -g $(GROUP) -m 755 lvm-pvclear \ + $(DESTDIR)/usr/local/sbin/lvm-pvclear + +include ../../Makefile.ax diff --git a/lvm/pvclear/lvm-pvclear b/lvm/pvclear/lvm-pvclear new file mode 100755 index 0000000..85137db --- /dev/null +++ b/lvm/pvclear/lvm-pvclear @@ -0,0 +1,28 @@ +#!/bin/bash -e +# +# lvm-pvclear -- Clear LVM physical volume +# Copyright (c)2013 Alexander Barton (alex@barton.de) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + +NAME=`basename "$0"` + +function Usage() +{ + echo "Usage: $NAME " + echo; exit 1 +} + +[ $# -eq 1 ] || Usage + +lvids=`lvs --noheadings -o name` + +for lv in $lvids; do + echo "Moving LV \"$lv\" ..." + nice ionice -c3 pvmove -i300 -n "$lv" "$1" + sync; sleep 2 +done -- 2.39.2