我正在尝试使用命令在服务器上的远程计算机(客户端)上运行脚本。
ssh -v -t root@10.68.xxx.xxx "sh /tmp/flash.sh 'root@server:/bamboo-agent-home/xml-data/latest/eng_20190124040906.sdcard' 1>&2"
“ flash.sh”具有以下内容(为了简短起见,仅显示命令而不是错误处理。)
问题:该脚本正确开始,直到在ivot_root之后到达命令为止。它打印回显“正在移动到新的根目录”,然后挂起。 有时会继续移动坐骑并再次挂起。
我无法调试,因为远程计算机已经处于挂载状态。 和-v for ssh在命令卡住后不提供任何输出。
任何帮助或建议都将受到赞赏。
MOUNT_DIR="/mnt/net"
BLOCK_MOUNT="/run/media/mmcblk1p1/"
OLDROOT="oldroot"
NOT_MOUNTED_ERROR=32
echo "unmounting $MOUNT_DIR and recreating this directory"
umount $MOUNT_DIR
rm -rf $MOUNT_DIR
mkdir $MOUNT_DIR
cd /
echo "stopping services"
sh /tst/test/testservice.sh stop
echo "mounting remote rootfs from $REMOTE_MOUNT_PATH at $MOUNT_DIR"
sshfs -o ssh_command="ssh -i /home/root/.ssh/id_test_cpib" $REMOTE_MOUNT_PATH $MOUNT_DIR
sync
echo "waiting for 120 seconds for the system to be ready for rootfs change in case it is not"
sleep 120
cd $MOUNT_DIR/
mkdir -p $MOUNT_DIR/$OLDROOT
echo "changing rootfs to .$MOUNT_DIR/$OLDROOT"
/sbin/pivot_root . $OLDROOT/
echo "moving to new root directory"
ls -la /
cd /
echo "moving the mounts"
mount --move $OLDROOT/dev/ /dev
mount --move $OLDROOT/proc/ /proc
mount --move $OLDROOT/sys/ /sys
mount --move $OLDROOT/run/ /run
mount --move $OLDROOT/var/volatile /var/volatile/