Renombrar Volume Group on-line

El Blog de Dragonfly
Fuentes:

ubuntuforums.org/showthread.php?t=2290548

www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/VG_rename.html

www.golinuxhub.com/2014/03/how-to-rename-logical-volume-and-volume.html

oraganism.wordpress.com/2013/03/09/rename-lvm-vg-for-root-fs-lv/

Script:

#!/bin/bash
#vgrename

echo “changing LVM names”

# Must be run with root permissions
# sudo will be sufficient

if [ "$(id -u)" != «0» ]; then
echo «This script must be run as root» 1>&2
exit 1
fi

#Ask for new hostname $newhost
read -p «Enter new hostname: „
newhostname=$REPLY
oldhostname=$(cat /etc/hostname)

# ${var//-} syntax removes all dashes from the name simplifying the
# requirement to use a double-dash in some places to escape the dash
newvg=${newhostname//-}

# Find the volume group that root is in
vg='lvdisplay -C|awk '$1==“root» {print $2}''
if [[ ${vg} == *"-"* ]]; then
#has dashes in current name
vgrename ${vg} ${newhostname//-}
vg='echo $vg|sed «s/-/--/g»'
sed -i «s/${vg}/${newvg}/g» /etc/fstab
sed -i «s/${vg}/${newvg}/g» /boot/grub/grub.cfg
else
#no dashes in current name
vgrename ${vg} ${newvg}
sed -i «s/${vg}/${newvg}/g» /etc/fstab
sed -i «s/${vg}/${newvg}/g» /boot/grub/grub.cfg
fi

update-initramfs -c -k all

#sed -i “s/$oldhostname/$newhostname/g” /etc/fstab
#sed -i “s/\/$oldhostname/\/$newhostname/g” /boot/grub/grub.cfg
#update-initramfs -c -k al

  • 0
  • 0
  • Compartir en Facebook

0 comentarios

Para escribir comentarios debes registrarte.