1#!/bin/bash 2# Copyright 2023 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6mount_root () { 7 if [ -f "/dev/sda" ]; then 8 mount /dev/sda /newroot 9 else 10 mount /dev/vda /newroot 11 fi 12} 13 14mount -t proc /proc -t proc 15mount -t sysfs none /sys 16mount -t devtmpfs none /dev 17 18mount_root 19 20if mount_root; then 21 mkdir -p /newroot/proc /newroot/sys /newroot/dev || true 22 23 mount --move /sys /newroot/sys 24 mount --move /proc /newroot/proc 25 mount --move /dev /newroot/dev 26 ln -sf /proc/self/fd /newroot/dev/fd 27 28 cp /bin/delegate /newroot/bin/delegate || true 29 30 cd /newroot && chroot /newroot /bin/delegate 31else 32 exec /bin/delegate 33fi 34