scripts/local脚本mount_root脚本文件分析
来源:互联网 发布:美白水知乎 编辑:程序博客网 时间:2024/05/17 07:02
pre_mountroot()
{
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && log_end_msg
# Don't wait for a root device that doesn't have a corresponding
# device in /dev (ie, mtd0)
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
return
fi
while [ -z "${FSTYPE}" ]; do
case $DPKG_ARCH in
powerpc|ppc64|ppc64el)
ARCHDELAY=180
;;
*)
ARCHDELAY=30
;;
esac
FSTYPE=$(wait-for-root "${ROOT}" ${ROOTDELAY:-$ARCHDELAY})
# Load ubi with the correct MTD partition and return since
# fstype doesn't work with a char device like ubi.
if [ -n "$UBIMTD" ]; then
modprobe ubi mtd=$UBIMTD
return
fi
# Run failure hooks, hoping one of them can fix up the system
# and we can restart the wait loop. If they all fail, abort
# and move on to the panic handler and shell.
if [ -z "${FSTYPE}" ] && ! try_failure_hooks; then
break
fi
done
# We've given up, but we'll let the user fix matters if they can
while [ -z "${FSTYPE}" -a ! -e "${ROOT}" ]; do
# give hint about renamed root
case "${ROOT}" in
/dev/hd*)
suffix="${ROOT#/dev/hd}"
major="${suffix%[[:digit:]]}"
major="${major%[[:digit:]]}"
if [ -d "/sys/block/sd${major}" ]; then
echo "WARNING bootdevice may be renamed. Try root=/dev/sd${suffix}"
fi
;;
/dev/sd*)
suffix="${ROOT#/dev/sd}"
major="${suffix%[[:digit:]]}"
major="${major%[[:digit:]]}"
if [ -d "/sys/block/hd${major}" ]; then
echo "WARNING bootdevice may be renamed. Try root=/dev/hd${suffix}"
fi
;;
esac
echo "Gave up waiting for root device. Common problems:"
echo " - Boot args (cat /proc/cmdline)"
echo " - Check rootdelay= (did the system wait long enough?)"
echo " - Check root= (did the system wait for the right device?)"
echo " - Missing modules (cat /proc/modules; ls /dev)"
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
done
}
mountroot()
{
pre_mountroot
# Get the root filesystem type if not set
if [ -z "${ROOTFSTYPE}" ]; then
[ -n "${FSTYPE}" ] || FSTYPE=$(blkid -s TYPE -o value "${ROOT}")
ROOTFSTYPE="${FSTYPE}"
else
FSTYPE=${ROOTFSTYPE}
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && log_end_msg
if [ "${readonly}" = "y" ] && \
[ -z "$LOOP" ]; then
roflag=-r
else
roflag=-w
fi
# FIXME This has no error checking
[ -n "${FSTYPE}" ] && modprobe ${FSTYPE}
# FIXME This has no error checking
# Mount root
mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
mountroot_status="$?"
if [ "$LOOP" ]; then
if [ "$mountroot_status" != 0 ]; then
if [ ${FSTYPE} = ntfs ] || [ ${FSTYPE} = vfat ]; then
panic "
Could not mount the partition ${ROOT}.
This could also happen if the file system is not clean because of an operating
system crash, an interrupted boot process, an improper shutdown, or unplugging
of a removable device without first unmounting or ejecting it. To fix this,
simply reboot into Windows, let it fully start, log in, run 'chkdsk /r', then
gracefully shut down and reboot back into Windows. After this you should be
able to reboot again and resume the installation.
(filesystem = ${FSTYPE}, error code = $mountroot_status)
"
fi
fi
mkdir -p /host
mount -o move ${rootmnt} /host
while [ ! -e "/host/${LOOP#/}" ]; do
panic "ALERT! /host/${LOOP#/} does not exist. Dropping to a shell!"
done
# Get the loop filesystem type if not set
if [ -z "${LOOPFSTYPE}" ]; then
eval $(fstype < "/host/${LOOP#/}")
else
FSTYPE="${LOOPFSTYPE}"
fi
if [ "$FSTYPE" = "unknown" ] && [ -x /sbin/blkid ]; then
FSTYPE=$(/sbin/blkid -s TYPE -o value "/host/${LOOP#/}")
[ -z "$FSTYPE" ] && FSTYPE="unknown"
fi
if [ ${readonly} = y ]; then
roflag=-r
else
roflag=-w
fi
# FIXME This has no error checking
modprobe loop
modprobe ${FSTYPE}
# FIXME This has no error checking
mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "/host/${LOOP#/}" ${rootmnt}
if [ -d ${rootmnt}/host ]; then
mount -o move /host ${rootmnt}/host
fi
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg
}
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && log_end_msg
上图中有Begin: 和done.
functions里面有定义
log_begin_msg()
{
_log_msg "Begin: $@ ... "
}
log_end_msg()
{
_log_msg "done.\n"
}
sudo blkid
[sudo] password for chenghao:
/dev/sda1: UUID="6AEC5FFFEC5FC44B" TYPE="ntfs"
/dev/sda2: LABEL="M-fM-^VM-0M-eM-^JM- M-eM-^MM-7" UUID="386E959C6E95540A" TYPE="ntfs"
/dev/sda3: LABEL="dd" UUID="9C509B6A509B49C2" TYPE="ntfs"
/dev/sda5: LABEL="M-fM-^VM-0M-eM-^JM- M-eM-^MM-7" UUID="DE6AA0B46AA08ABB" TYPE="ntfs"
/dev/sda6: UUID="C426D5ED46DE7E6A" TYPE="ntfs"
/dev/sda7: SEC_TYPE="msdos" UUID="0007-5305" TYPE="vfat"
/dev/sda8: UUID="cb57e3e8-6f60-42c1-863d-1617454d360e" TYPE="ext4"
/dev/sda9: UUID="290c66fe-f885-4783-9db4-e45d090f75bd" TYPE="swap"
chenghao@chenghao-Lenovo-Product:~$
终于找到了出错的原因。
- scripts/local脚本mount_root脚本文件分析
- Scripts to manage Local Users—windows用户管理脚本
- PowerShell 脚本(Scripts)
- Scripts:找出后台trace文件的脚本sess_user_trace_file_location.sql
- solr scripts.conf 脚本解析
- npm 脚本(npm scripts)
- Bash Scripts(Bash 脚本)I
- 链接脚本.lds文件分析
- linux启动后执行脚本(/etc/rc.local文件)
- GNU-ld连接脚本 Linker Scripts
- Scripts:数据库升级诊断脚本dbupgdiag.sql
- Scripts:此脚本慎用lob_fragmentation_user.sql
- Scripts:列出用户信息的脚本sec_users.sql
- Scripts:查看表空间的语句脚本
- Unity3D深入浅出 - 脚本开发基础(Scripts)
- 【脚本】Useful collection of linux bash scripts
- MySql backup scripts--Mysql备份脚本
- 自动修改linux下/etc/sysconfig/network-scripts/ifcfg-ethX网卡文件的脚本
- javafX初探(按钮)
- android调用系统分享实现朋友圈同时分享文字和图片(可多张)
- 论证select count(*)和select count(1)
- memcache的一致性hash算法使用
- 字符串转换为整数
- scripts/local脚本mount_root脚本文件分析
- 块设备驱动分析及编写
- 庄阻姿专住做锥资撞走准滓追诅籽宗佐赘
- 如何理解java采用Unicode编码
- UVA 11151
- 发送标准广播
- MySQL 5.6.14 win32 zip版安装
- fds fgdfds
- 求一批整数中出现最多的个位数字