[496] | 1 | #!/bin/sh |
---|
| 2 | # |
---|
| 3 | # This script is responsible for setting up /etc/fstab upon the |
---|
| 4 | # new instance. |
---|
| 5 | # |
---|
| 6 | # This should be a simple job, but it is complicated by some of the |
---|
| 7 | # differences between filesystems - some root filesystems will require |
---|
| 8 | # the installation of new packages, and we have to handle that here. |
---|
| 9 | # |
---|
| 10 | # Steve |
---|
| 11 | # -- |
---|
| 12 | # http://www.steve.org.uk/ |
---|
| 13 | |
---|
| 14 | prefix=$1 |
---|
| 15 | |
---|
| 16 | # |
---|
| 17 | # Source our common functions |
---|
| 18 | # |
---|
| 19 | if [ -e /usr/lib/xen-tools/common.sh ]; then |
---|
| 20 | . /usr/lib/xen-tools/common.sh |
---|
| 21 | else |
---|
| 22 | . ./hooks/common.sh |
---|
| 23 | fi |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | # |
---|
| 27 | # Log our start |
---|
| 28 | # |
---|
| 29 | logMessage Script $0 starting |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | # |
---|
| 33 | # Make sure we use ide style device names if required |
---|
| 34 | # |
---|
| 35 | device=sda |
---|
| 36 | if [ "${ide}" ]; then |
---|
| 37 | device=hda |
---|
| 38 | fi |
---|
| 39 | |
---|
| 40 | # |
---|
| 41 | # Now we have the options we can create the fstab. |
---|
| 42 | # |
---|
| 43 | has_xfs=0 |
---|
| 44 | has_reiserfs=0 |
---|
| 45 | cat <<E_O_FSTAB > ${prefix}/etc/fstab |
---|
| 46 | # /etc/fstab: static file system information. |
---|
| 47 | # |
---|
| 48 | # <file system> <mount point> <type> <options> <dump> <pass> |
---|
| 49 | proc /proc proc defaults 0 0 |
---|
| 50 | E_O_FSTAB |
---|
| 51 | for part in `seq 1 ${NUMPARTITIONS}`; do |
---|
| 52 | eval "PARTITION=\"\${PARTITION${part}}\"" |
---|
| 53 | OLDIFS="${IFS}" |
---|
| 54 | IFS=: |
---|
| 55 | x=0 |
---|
| 56 | for partdata in ${PARTITION}; do |
---|
| 57 | eval "partdata${x}=\"${partdata}\"" |
---|
| 58 | x=$(( $x+1 )) |
---|
| 59 | done |
---|
| 60 | IFS="${OLDIFS}" |
---|
| 61 | |
---|
| 62 | case "${partdata2}" in |
---|
| 63 | xfs) |
---|
| 64 | has_xfs=1 |
---|
| 65 | ;; |
---|
| 66 | reiserfs) |
---|
| 67 | has_reiserfs=1 |
---|
| 68 | ;; |
---|
| 69 | esac |
---|
| 70 | |
---|
| 71 | # This assumes a particular partition table for our ParaVM's (SIPB) |
---|
| 72 | if [ "${partdata2}" = "swap" ]; then |
---|
| 73 | echo "/dev/${device}2 none swap sw 0 0" >> ${prefix}/etc/fstab |
---|
| 74 | else |
---|
| 75 | echo "/dev/${device}1 ${partdata3} ${partdata2} ${partdata4} 0 1" >> ${prefix}/etc/fstab |
---|
| 76 | fi |
---|
| 77 | done |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | # |
---|
| 81 | # Finally we can install any required packages for the given root |
---|
| 82 | # filesystem |
---|
| 83 | # |
---|
| 84 | if [ $has_xfs -eq 1 ]; then |
---|
| 85 | installDebianPackage ${prefix} xfsprogs |
---|
| 86 | fi |
---|
| 87 | if [ $has_reiserfs -eq 1 ]; then |
---|
| 88 | installDebianPackage ${prefix} reiserfsprogs |
---|
| 89 | fi |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | # |
---|
| 93 | # Log our finish |
---|
| 94 | # |
---|
| 95 | logMessage Script $0 finished |
---|