Preserve existing volume during Kickstart install

2

So, I've got a server running Scientific Linux 6.9 that I want to install 7 on. Upgrades are apparently not supported, so I need to do a clean install, which is fine.

I installed the SL6 server using Kickstart, with these options:

...
zerombr
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb vga=788"
clearpart --all --drives=sda
part /boot --fstype=ext4 --size=500
part pv.008002 --grow --size=1
volgroup vg_main --pesize=4096 pv.008002
logvol / --fstype=ext4 --name=lv_root --vgname=vg_main --size=8192
logvol /home --fstype=ext4 --name=lv_home --vgname=vg_main  --fsoptions="usrquota" --size=8192 --grow
logvol swap --name=lv_swap --vgname=vg_main --size=1024
...

I only want to preserve only the /home LV during the new install. I've read about the --noformat option in the documentation, but it can be applied to the partition, volume group, and logical volume configurations. I'm not clear on which level I should use it and, more importantly, how it will identify the structures in question.

Thankfully this is a VM, so I have snapshots to fall back on, but I'd rather not waste too much time on that. So, what options should I use for the SL7 install to ensure that /home is untouched?


Output of fdisk -l if it's helpful:

Disk /dev/sda: 268.4 GB, 268435456000 bytes
255 heads, 63 sectors/track, 32635 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000852f6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       32636   261630976   8e  Linux LVM

Disk /dev/mapper/vg_main-lv_root: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_main-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_main-lv_home: 258.2 GB, 258243297280 bytes
255 heads, 63 sectors/track, 31396 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

And output of vgdisplay -v:

    Using volume group(s) on command line.
  --- Volume group ---
  VG Name               vg_main
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               249.51 GiB
  PE Size               4.00 MiB
  Total PE              63874
  Alloc PE / Size       63874 / 249.51 GiB
  Free  PE / Size       0 / 0   
  VG UUID               T03S3I-cgaj-A2OY-1e9d-FBiQ-8xpJ-NN3hUo

  --- Logical volume ---
  LV Path                /dev/vg_main/lv_root
  LV Name                lv_root
  VG Name                vg_main
  LV UUID                FPXNoA-pqjg-Krbx-O5Sn-jFzg-GGsb-Ual7ww
  LV Write Access        read/write
  LV Creation host, time rainicorn.domain.internal, 2014-06-05 14:12:41 -0400
  LV Status              available
  # open                 1
  LV Size                8.00 GiB
  Current LE             2048
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Path                /dev/vg_main/lv_home
  LV Name                lv_home
  VG Name                vg_main
  LV UUID                E38kVe-nxYm-rKop-Gwka-80Lh-T2VF-vGUkHE
  LV Write Access        read/write
  LV Creation host, time rainicorn.domain.internal, 2014-06-05 14:12:44 -0400
  LV Status              available
  # open                 1
  LV Size                240.51 GiB
  Current LE             61570
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Path                /dev/vg_main/lv_swap
  LV Name                lv_swap
  VG Name                vg_main
  LV UUID                HoZ84h-eXye-lgNw-ggTN-YIEc-X0fZ-ZLcRCo
  LV Write Access        read/write
  LV Creation host, time rainicorn.domain.internal, 2014-06-05 14:13:07 -0400
  LV Status              available
  # open                 1
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Physical volumes ---
  PV Name               /dev/sda2     
  PV UUID               shdyY0-fhMC-c7kB-LoKG-Jlk8-qN81-14toG3
  PV Status             allocatable
  Total PE / Free PE    63874 / 0
linux
redhat
lvm
partition
kickstart
asked on Server Fault Apr 22, 2019 by miken32 • edited Apr 22, 2019 by miken32

1 Answer

1

This is what ended up working for me in my SL7 kickstart file. The part directive has an --onpart option to specify what drive to look for the partition on, and the rest seem to figure it out from there. Some judicious use of --useexisting and --noformat ensured my data was waiting for me after install.

zerombr
bootloader --location="mbr" --driveorder="sda" --append="crashkernel=auto rhgb vga=788"
part /boot --fstype="xfs" --recommended --onpart=sda1
part pv.008002 --grow --size=1 --noformat --onpart=sda2
volgroup vg_main --pesize=4096 --useexisting --noformat
logvol / --fstype="xfs" --name="lv_root" --vgname="vg_main" --size=8192 --useexisting
logvol swap --name="lv_swap" --vgname="vg_main" --size=1024 --useexisting
logvol /home --fstype=ext4 --name=lv_home --vgname=vg_main  --fsoptions="usrquota" --size=8192 --grow --noformat
answered on Server Fault Apr 24, 2019 by miken32

User contributions licensed under CC BY-SA 3.0