moving to new root directory after pivot_root hangs

送分小仙女□ 提交于 2019-12-11 15:32:50

问题


i am trying to run a script on remote machine (client) from a server with the command.

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"

The "flash.sh" has the following (to keep it short im just showing the commands and not the error handlings.)

ISSUE: the script starts of correctly untill it reaches the command after pivot_root. It print echo "moving to new root directory" and just hangs. Sometimes goes ahead to moving the mounts and hangs again.

I have no way to debug because the remote machine is already in mounted state. and -v for ssh does not give any output after the command is stuck.

Any help or suggestions are appreciated.

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/

来源:https://stackoverflow.com/questions/54364557/moving-to-new-root-directory-after-pivot-root-hangs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!