Re: [EXTERNAL] Reinstall and keep data LV

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We use pre/post script to backup / restore certain data on LVM and SW Raid systems...

Obviously, you'll need to modify which LVM names to mount, etc, but this should get you started....

#!/bin/bash
mkdir -p /mnt/oldroot
## mdadm scan for raid to save drive
mkdir -p /etc/mdadm
mdadm --examine --scan >>/etc/mdadm/mdadm.conf
mdadm --assemble --scan
#
# Look for old LVM root
# In RHEL6, we deprecate mounting non-lvm file systems
#
mounted=""
lvm=""
# Check for lvm disk existence
if lvm lvmdiskscan -l 2>1 /dev/null|grep -q '[1-9] LVM physical'; then
   # root volume group scan
   VGNAME=$(lvm vgdisplay -C --noheadings|grep -i root|awk '{print $1}')
   # enable rootvg
   lvm vgchange -a y \$VGNAME
   # root and var logvols we care about
   LVROOT=$(lvm lvdisplay -C --noheadings $VGNAME|grep -i volroot|awk '{print $1}')    LVVAR=$(lvm lvdisplay -C --noheadings $VGNAME|grep -i volvar|awk 'NR==1{print $1}')
   mount /dev/$VGNAME/$LVROOT /mnt/oldroot
   mount /dev/$VGNAME/$LVVAR /mnt/oldroot/var
   mounted="true"
   lvm="true"
   (cd /mnt/oldroot; tar cvpf /tmp/oldfiles.tar etc/krb5.keytab etc/ssh/ssh_host_* etc/exports var/spool/cron/ var/cfengine/ppkeys/ )
   if [ -n $mounted ] ; then
      cd /;
      umount /mnt/oldroot/var
      umount /mnt/oldroot
   fi
   if [ -n $lvm ]; then
      lvm vgchange -a n $VGNAME
   fi
else
   echo "Warning! Unable to mount old filesystem for backup/restore for system files..."
fi
##stop sw raid if any
mdadm --stop --scan


Markus Falb wrote:
Hi,
I am struggling!
I want to reinstall LVM based installs. I want to keep some LVs (data)
but want to overwrite the other LVs(system)

First I did a kickstart of RHEL 7, here the storage related lines

...snip
zerombr
clearpart --all --initlabel
part pv.0 --fstype=lvmpv --grow --asprimary
part /boot --fstype=xfs --size 1000 --asprimary --label BOOT
volgroup rhel_rhellv01 pv.0
logvol / --vgname=rhel_rhellv01 --name=root --size 5000 --fstype=xfs
logvol /home --vgname=rhel_rhellv01 --name=home --fstype=xfs --size \
   1000 --fsoptions="defaults,nodev,nosuid,noexec"
logvol swap --fstype="swap" --name=swap --vgname=rhel_rhellv01 --size 1000
snap...

Next I tried a reinstall with a modified kickstart

...snip
bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
part /boot --fstype=xfs --size 1000 --asprimary --label BOOT \
   --onpart=/dev/disk/by-id/ata-QEMU_HARDDISK_QM00003-part1
part pv.0 --fstype=lvmpv --grow --asprimary \
   --onpart=/dev/disk/by-id/ata-QEMU_HARDDISK_QM00003-part2 --noformat
volgroup rhel_rhellv01 --noformat
logvol / --vgname=rhel_rhellv01 --name=root --size 5000 --fstype=xfs \
   --useexisting
logvol /home --vgname=rhel_rhellv01 --name=home --fstype=xfs --size \
   1000 --fsoptions="defaults,nodev,nosuid,noexec" --noformat
logvol swap --fstype="swap" --name=swap --vgname=rhel_rhellv01 --size \
   1000 --useexisting
snap...

this is working with RHEL 7 (so my kickstart is not totally wrong)!

but with RHEL 8

error: logical volume "root" given in logvol command does not exist

What is wrong with my kickstart? What should I change that it works
with RHEL 8 too?

Best Regards, Markus

_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/kickstart-list



_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/kickstart-list




[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux