home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / boot / initrd.img-2.6.20-15-generic / initrd.img-2.6 / scripts / nfs < prev   
Encoding:
Text File  |  2007-05-25  |  2.4 KB  |  107 lines

  1. # NFS filesystem mounting            -*- shell-script -*-
  2.  
  3. # FIXME This needs error checking
  4.  
  5. retry_nr=0
  6.  
  7. # parse nfs bootargs + launch ipconfig and nfsmount
  8. do_nfsmount()
  9. {
  10.     # support ip options see linux sources Documentation/nfsroot.txt
  11.     case ${IPOPTS} in
  12.         none|off)
  13.             # Do nothing
  14.             ;;
  15.         ""|on|any)
  16.             # Bring up device
  17.             ipconfig ${DEVICE}
  18.             ;;
  19.         dhcp|bootp|rarp|both)
  20.             ipconfig -c ${IPOPTS} -d ${DEVICE}
  21.             ;;
  22.         *)
  23.             ipconfig -d $IPOPTS
  24.  
  25.             # grab device entry from ip option
  26.             NEW_DEVICE=${IPOPTS#*:*:*:*:*:*}
  27.             if [ "${NEW_DEVICE}" != "${IPOPTS}" ]; then
  28.                 NEW_DEVICE=${NEW_DEVICE%:*}
  29.             else
  30.                 # wrong parse, possibly only a partial string
  31.                 NEW_DEVICE=
  32.             fi
  33.             if [ -n "${NEW_DEVICE}" ]; then
  34.                 DEVICE="${NEW_DEVICE}"
  35.             fi
  36.             ;;
  37.     esac
  38.  
  39.     # source relevant ipconfig output
  40.     . /tmp/net-${DEVICE}.conf
  41.  
  42.     # get nfs root from dhcp
  43.     if [ "x${NFSROOT}" = "xauto" ]; then
  44.         NFSROOT=${ROOTSERVER}:${ROOTPATH}
  45.     # nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
  46.     elif [ -n "${NFSROOT}" ]; then
  47.         # nfs options are an optional arg
  48.         if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then
  49.             NFSOPTS="-o ${NFSROOT#*,}"
  50.         fi
  51.         NFSROOT=${NFSROOT%%,*}
  52.         if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then
  53.             NFSROOT=${ROOTSERVER}:${NFSROOT}
  54.         fi
  55.     fi
  56.  
  57.     if [ -z "${NFSOPTS}" ]; then
  58.         NFSOPTS="-o retrans=10"
  59.     fi
  60.  
  61.     [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-premount"
  62.     run_scripts /scripts/nfs-premount
  63.     [ "$quiet" != "y" ] && log_end_msg
  64.  
  65.     if [ ${readonly} = y ]; then
  66.         roflag="-o ro"
  67.     else
  68.         roflag="-o rw"
  69.     fi
  70.  
  71.     nfsmount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt}
  72. }
  73.  
  74. # NFS root mounting
  75. mountroot()
  76. {
  77.     [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-top"
  78.     run_scripts /scripts/nfs-top
  79.     [ "$quiet" != "y" ] && log_end_msg
  80.  
  81.     modprobe -q nfs
  82.     # For DHCP
  83.     modprobe -q af_packet
  84.  
  85.     # Default delay is around 180s
  86.     # FIXME: add usplash_write info
  87.     if [ -z "${ROOTDELAY}" ]; then
  88.         delay=180
  89.     else
  90.         delay=${ROOTDELAY}
  91.     fi
  92.  
  93.     # loop until nfsmount succeds
  94.     while [ ${retry_nr} -lt ${delay} ] && [ ! -e ${rootmnt}${init} ]; do
  95.         [ ${retry_nr} -gt 0 ] && \
  96.         [ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount"
  97.         do_nfsmount
  98.         retry_nr=$(( ${retry_nr} + 1 ))
  99.         [ ! -e ${rootmnt}${init} ] && /bin/sleep 1
  100.         [ ${retry_nr} -gt 0 ] && [ "$quiet" != "y" ] && log_end_msg
  101.     done
  102.  
  103.     [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom"
  104.     run_scripts /scripts/nfs-bottom
  105.     [ "$quiet" != "y" ] && log_end_msg
  106. }
  107.