/usr/share/tcos/scripts/tcos-premount/30rootfs is in initramfs-tools-tcos 0.89.93ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | #!/bin/sh
#
if [ "$1" = "prereqs" ]; then
exit 0
fi
quiet=n
. /scripts/functions
# if break=sqmount STOP here
maybe_break rootfs
. /conf/tcos.conf
. /conf/tcos-run-functions
##############################################
TCOS_ENABLE_USENFS=$(read_cmdline_var "usenfs" "${TCOS_USENFS}")
if [ "$TCOS_ENABLE_USENFS" != "1" ]; then
_log "ROOTFS no NFS support, exiting"
exit 0
fi
rootfs_file=/mnt/tmp/rootfs-$(uname -r).squashfs
mkdir -p /mnt/tmp /target
if [ "${TCOS_USENFS}" = "nfs" ]; then
value=0
log_begin_msg "Mounting NFS /mnt/tmp"
MOPTS="nolock,ro"
mount -n -t ramfs none /target
nfsmount -o ${MOPTS} $(read_server "nfs-server"):${nfs_dir} /mnt/tmp 2>&1 > /dev/null ||\
nfsmount -o ${MOPTS} $(read_server "nfs-server"):${nfs_dir} /mnt/tmp 2>&1 > /dev/null ||\
value=1
log_end_msg $value
fi
##############################################
TCOS_ENABLE_ROOTFS=$(read_cmdline_var "rootfs" "${TCOS_ROOTFS}")
if [ "$TCOS_ENABLE_ROOTFS" != "1" ]; then
_log "ROOTFS no rootfs support, exiting"
exit 0
fi
if [ ! -f ${rootfs_file} ]; then
_log "ROOTFS is __NOT__ in /mnt/tmp"
log_begin_msg "Downloading rootfs"
download_file /tcos/rootfs-$(uname -r).squashfs ${rootfs_file}
log_end_msg $?
else
_log "ROOTFS is in /mnt/tmp"
log_begin_msg "Using NFS rootfs"
sync
log_end_msg $?
fi
# Mount squashfs filesystems
_log "ROOTFS mounting rootfs in /target"
log_begin_msg "Mounting rootfs filesystem"
mount -r -o loop -t squashfs ${rootfs_file} /target >> /tmp/initramfs.debug 2>&1
log_end_msg $?
_log "ROOTFS remounting /target as RW"
log_begin_msg "Remounting /target in rw mode"
mkdir -p /.target
mount_unionfs /mnt/rootram /.target /target
log_end_msg $?
_log "ROOTFS copy some things on /target"
# copy some things
rm -rf /target/conf/ && cp -ra /conf/ /target/
rm -rf /target/scripts/ && cp -ra /scripts/ /target/
mkdir -p /target/tmp && cp -ra /tmp/* /target/tmp
#mkdir -p /var/lib/dhcp/
#cp /var/lib/dhcp/dhclient.leases /target/var/lib/dhcp/dhclient.leases
cat /tmp/net.data > /root/tmp/net.data
cp /etc/hostname /target/etc/hostname
cp /etc/resolv.conf /target/etc/resolv.conf
cp /etc/fstab /target/etc/fstab
cp /etc/mtab /target/etc/mtab
_log "ROOTFS creating init_rootfs script"
# make a /sbin/init_rootfs
cat << EOF >> /target/init2
#!/bin/sh
echo "Loading second stage, please wait..."
. /conf/initramfs.conf
. /scripts/functions
run_scripts /scripts/tcos-bottom
EOF
chmod 755 /target/init2
_log "ROOTFS pivot_root /target"
cd /target
pivot_root . ../
_log "ROOTFS mounting /dev /proc and /sys into /target"
# mount -o bind some things
log_begin_msg "Moving /dev /proc and /sys"
mkdir -p /target/dev /target/proc /target/sys /target/mnt/tmp
mount -n -o move /dev /target/dev
mount -n -o move /sys /target/sys
mount -n -o move /mnt/tmp /target/mnt/tmp
mount -n -o move /proc /target/proc
log_end_msg $?
# enter to jail
exec chroot . /scripts/init2 <dev/console >dev/console 2>&1
_log "ROOTFS run-init /script"
#exec run-init /target/ /scripts/init2 "$@" </target/dev/console >/target/dev/console
exit 0
|