Linux

在 Kickstart 安裝期間保留現有捲

  • April 24, 2019

所以,我有一台執行 Scientific Linux 6.9 的伺服器,我想在上面安裝 7。顯然不支持升級,所以我需要進行全新安裝,這很好。

我使用 Kickstart 安裝了 SL6 伺服器,具有以下選項:

...
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
...

我只想/home在新安裝期間只保留 LV。我已閱讀文件中有關該--noformat選項的資訊,但它可以應用於partitionvolume group邏輯卷配置。我不清楚我應該在哪個級別使用它,更重要的是,它如何辨識有問題的結構。

謝天謝地,這是一個虛擬機,所以我有快照可以依賴,但我不想在這上面浪費太多時間。那麼,我應該使用哪些選項來安裝 SL7 以確保/home不受影響?


輸出fdisk -l是否有幫助:

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

和輸出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

這就是在我的 SL7 kickstart 文件中最終為我工作的內容。該part指令有一個--onpart選項來指定要在哪個驅動器上查找分區,其餘的似乎從那裡找出來。一些明智的使用--useexisting--noformat確保我的數據在安裝後正在等待我。

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

引用自:https://serverfault.com/questions/964108