|
local文件里增加的代码,注意空格
本帖最后由 2011niumao 于 2022-10-16 10:43 编辑
- if [ -n "$KLOOP" ] ; then
- ### reset the value of the root variable
- HOSTDEV="${ROOT}"
- NEWROOT="${rootmnt}"
- [ -n "$KROOT" ] && ROOT="$KROOT"
- [ -n "$KROOT" ] || ROOT="/dev/loop0"
- export ROOT
- realroot="$ROOT"
- ### auto probe the fs-type of the partition in which vhd-file live and mount it /host
- mkdir -p /host
- if [ -e ${NEWROOT}${KLOOP} ] ; then
- mount --move $NEWROOT /host
- else
- if [ -z "$HOSTFSTYPE" ] ; then
- HOSTFSTYPE="$(blkid -s TYPE -o value "${HOSTDEV}")"
- [ -z "$HOSTFSTYPE" -o "${HOSTFSTYPE}" = "ntfs" ] && HOSTFSTYPE="ntfs-3g"
- fi
- [ "${HOSTFSTYPE}" = "ntfs-3g" ] || modprobe ${HOSTFSTYPE}
- mount -t ${HOSTFSTYPE} -o rw ${HOSTDEV} /host
- fi
- ### mount the vhd-file on a loop-device
- if [ "${KLOOP#/}" != "${KLOOP}" ] ; then
- modprobe loop
- kpartx -av /host${KLOOP}
- [ -e "$realroot" ] || sleep 3
- fi
- ### mount the realroot / in vhd-file on $NEWROOT
- if [ -z "${KLOOPFSTYPE}" ] ; then
- KLOOPFSTYPE="$(blkid -s TYPE -o value "$realroot")"
- [ -z "${KLOOPFSTYPE}" ] && KLOOPFSTYPE="ext4"
- fi
- [ -e "$realroot" ] || sleep 3
- mount ${roflag} -t "${KLOOPFSTYPE}" $realroot $NEWROOT
- fi
复制代码 |
|