USB install linux,关于ks文件路径的问题(EL7)

在使用USB安装系统时,发现系统在启动的时候,出现无法启动的原因,主要现象表现为/dev/root not exist.解决方法可以采用针对系统识别的不同结果进行修改,在syslinux.cfg文件中将地址改为指定的设备。如:

ks=hd:sdb1:/ks.cfg.

在ks文件中,你可以将系统安装到sda的设备中,如:

bootloader --location=mbr --boot-drive=sdaclearpart --all --drives=sdapart /boot --fstype=ext4 --size=500 --ondisk=sdapart / --size=8000 --fstype ext4 --ondisk=sdapart swap --size=4096 --ondisk=sda

但这样做,对批量的处理来说,可能就比较繁琐了.我们可以使用以下的方法进行处理,就可以避免手工修改的工作。syslinux.cfg文件中。

ks=hd:LABEL=Qfong:/ks.cfg(注意LABEL的长度和制作iso时指定LABEL)

在ks文件中,如果不指定分区,系统会默认将bootloader安装在本次引导启动的盘中,也就是USB所在设备,导致无法继续安装,这时候需要指定bootloader –location=mbr –boot-drive=? boot-drive=哪个设备?这个需要做判断了,在ks文件中,使用%pre选项,该选项是在安装前执行的script文件.下面我们将判断哪个设备的script写在下面,供大家参考。

#%include /tmp/partitions#%pre#!/bin/sh# find the first drive that doesn’t have removable media and isn’t USBDIR=”/sys/block”ROOTDRIVE=””for DEV in sda sdb sdc sdd sde hda hdb hdc hdd hde; do  if [ -d $DIR/$DEV ]; then    readlink -f $DIR/$DEV/device | grep -q /usb    if [ $? -ne 0 ]; then      REMOVABLE=`cat $DIR/$DEV/removable`      if (( $REMOVABLE == 0 )); then        if [ -z $ROOTDRIVE ]; then          ROOTDRIVE=$DEV        fi      fi    fi  fidone# Check for RAID controller disksif [ -z $ROOTDRIVE ]; then  for DEV in c0d0 c0d1 c0d2 c1d0 c1d1 c1d2; do    if [ -d $DIR/cciss!$DEV ]; then      if [ -z $ROOTDRIVE ]; then        ROOTDRIVE=cciss/$DEV      fi    fi  doneficat << EOF > /tmp/partitionsbootloader –location=mbr –driveorder=$ROOTDRIVEclearpart –all –drives=$ROOTDRIVE –initlabelpart /boot –fstype=ext3 –size=75 –ondisk=$ROOTDRIVEpart / –fstype=ext3 –size=4096 –ondisk=$ROOTDRIVE –asprimary –growpart swap –size=2048 –ondisk=$ROOTDRIVEEOF
USB install linux,关于ks文件路径的问题(EL7)

相关文章:

你感兴趣的文章:

标签云: