Centos7 Kickstart-如何防止擦除第二个VM磁盘?

时间:2019-01-30 04:47:07

标签: linux centos centos7 redhat

我使用带有两个磁盘disk1(30GB)和disk2(50GB)的VMware VSphere ESXI通过centos7 kickstart文件创建了一个VM。通过网络安装(DHCP,TFTP,IPXE)完成安装。能够成功创建VM,我可以看到sda和sdb看起来不错。现在,我已经触摸了安装在名为/ var / test /的文件夹中的sdb中的几个文件(1.txt,2.txt等)。

我使用了选项-clearpart并忽略磁盘。

尝试了clearpart和ignoreisk选项,以保留sdb磁盘。

# Create a %pre section as below
%pre --interpreter=/usr/bin/bash
#!/bin/bash
hds=""
mymedia=""

for file in /sys/block/sd*; do
hds="$hds $(basename $file)"
done

set $hds
numhd=$(echo $#)

drive1=$(echo $hds | cut -d' ' -f1)
drive2=$(echo $hds | cut -d' ' -f2)

if [ $numhd == "2" ]  ; then
echo "#partitioning scheme generated in %pre for 2 drives" > /tmp/part-include
echo "zerombr" >> /tmp/part-include
echo "clearpart --all --drives=sda,sdb --initlabel" >> /tmp/part-include
echo "ignoredisk --only-use=sda,sdb" >> /tmp/part-include
echo "bootloader --location=mbr --driveorder=sda,sdb" >> /tmp/part-include
echo "part /boot --fstype xfs --size 512 --ondisk sda" >> /tmp/part-include
echo "part / --fstype xfs --size 20000 --ondisk sda" >> /tmp/part-include
echo "part swap --recommended --ondisk $drive1" >> /tmp/part-include
echo "part /home --fstype xfs --size 2048 --ondisk sda" >> /tmp/part-include
echo "part /var/test --fstype xfs --size 10000 --grow --ondisk sdb" >> /tmp/part-include
else
echo "#partitioning scheme generated in %pre for 1 drive" > /tmp/part-include
echo "clearpart --all" >> /tmp/part-include
echo "part /boot --fstype xfs --size 521" >> /tmp/part-include
echo "part swap --recommended" >> /tmp/part-include
echo "part / --fstype xfs --size 20000" >> /tmp/part-include
echo "part /home --fstype xfs --size 2048" >> /tmp/part-include
echo "part /var/test --fstype xfs --size 10000 --grow" >> /tmp/part-include
fi

%end
%include /tmp/part-include

触摸了sdb磁盘中的测试文件(1.txt,2.txt等),并且在kickstart安装后希望看到文件完整无缺。但是它被清理了。

0 个答案:

没有答案