#!/bin/sh # if [ "$1" = "prereqs" ]; then exit 0 fi . /scripts/functions . /conf/tcos.conf . /conf/tcos-run-functions quiet=n # if break=mountnfs STOP here maybe_break mountnfs # read /tmp/less_ram if [ "$(cat /tmp/less_ram)" = "0" ]; then # have more than TCOS_MIN_RAM exit 0 fi # if use NFS try to mount: # # SERVER_IP:/var/lib/tcos/fs-$(uname -r) # MNTOPT="ro,nolock,rsize=2048,wsize=2048,retrans=10" NFS_RO=/mnt/nfs NFS_RW=/root mkdir -p /root mkdir -p /mnt/nfs # say to usplash more timeout if [ -x /sbin/usplash_write ]; then /sbin/usplash_write "TIMEOUT 180" || true fi # NFS or NBD ? NFS_MODE=$(read_cmdline_var "nfsmode" "nfs") if [ "${NFS_MODE}" = "nbd" ]; then # mount root-$(uname -r).squashfs as /dev/nbd0 log_begin_msg "Mounting remote squashfs with NBD" NBD_PORT=$(read_cmdline_var "nbdport" "2001") # load 1 nbd devices modprobe nbd nbds_max=1 # wait for device while [ ! -e /dev/nbd0 ]; do sleep 1 done nbd-client tcos-server $NBD_PORT /dev/nbd0 sleep 1 mount /dev/nbd0 /mnt/nfs log_end_msg $? else log_begin_msg "Trying to mount NFS" nfsmount -o $MNTOPT $(read_server "nfs-server"):${TCOS_VAR}/fs-$(uname -r) ${NFS_RO} 2>/dev/null # try again if [ $? -ne 0 ]; then log_begin_msg "Second retry to mount NFS" nfsmount -o $MNTOPT $(read_server "nfs-server"):${TCOS_VAR}/fs-$(uname -r) ${NFS_RO} 2> /dev/null fi if [ $? -ne 0 ]; then panic "Unable to mount NFS, check NFS service in server and ${TCOS_VAR}/fs-$(uname -r) dir" fi log_end_msg $? fi # end of NFS_MODE # remount /root in RW mode log_begin_msg "Remounting root in RW mode" mkdir -p /mnt/ram mount -t tmpfs -o size=5m tmpfs /mnt/ram if [ $(grep -c unionfs /proc/modules) = 0 ] && [ $(grep -c aufs /proc/modules) != 0 ]; then mount -t aufs -o br:/mnt/ram:/mnt/nfs none /root >> /tmp/initramfs.debug 2>&1 else # NFS mounts must have nfsro instead of ro (see man unionfs) with kernel < 2.6.22 if [ "$(uname -r| awk -F"[.|-]" '{print $3}')" -lt 22 ] && [ "${NFS_MODE}" != "nbd" ] ; then mount -t unionfs -o dirs=/mnt/ram=rw:/mnt/nfs=nfsro unionfs /root else mount -t unionfs -o dirs=/mnt/ram=rw:/mnt/nfs=ro unionfs /root fi fi log_end_msg $? maybe_break move_mnt # Set browseable NFS and RAM dirs mkdir -p /root/.dirs/nfs mkdir -p /root/.dirs/ram mount -o move /mnt/nfs /root/.dirs/nfs mount -o move /mnt/ram /root/.dirs/ram exit 0