Adding debian version 2.0~a1-1.
[live-boot-grml.git] / scripts / live-bottom / 12fstab
1 #!/bin/sh
2
3 #set -e
4
5 # initramfs-tools header
6
7 PREREQ=""
8 FSTAB=/root/etc/fstab
9
10 prereqs()
11 {
12         echo "${PREREQ}"
13 }
14
15 case "${1}" in
16         prereqs)
17                 prereqs
18                 exit 0
19                 ;;
20 esac
21
22 # live-boot header
23
24 . /scripts/live-functions
25
26 if [ -n "${NOFSTAB}" ]
27 then
28         exit 0
29 fi
30
31 log_begin_msg "Configuring fstab"
32
33 # live-boot script
34
35 # Create a fake fstab only if it doesn't exist or if its the debootstrap template
36 if [ ! -f "${FSTAB}" ] || grep -qs 'UNCONFIGURED FSTAB FOR BASE SYSTEM' "${FSTAB}"
37 then
38
39 cat > ${FSTAB} << EOF
40 # /etc/fstab: static file system information.
41 #
42 # <file system> <mount point>   <type>  <options>       <dump>  <pass>
43
44 EOF
45
46 fi
47
48 if ! grep -qs  "^${UNIONTYPE}" "${FSTAB}"
49 then
50         echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> "${FSTAB}"
51 fi
52
53 if ! grep -qs "^tmpfs /tmp" "${FSTAB}"
54 then
55         echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> "${FSTAB}"
56 fi
57
58 if [ -n "${SWAPON}" ]
59 then
60         devices=""
61
62         for device in /dev/[hs]d[a-z][0-9]*
63         do
64                 if ! [ -b "${device}" ]
65                 then
66                         continue
67                 fi
68
69                 # udev (>= 146) no longer provides vol_id
70                 if [ -x /lib/udev/vol_id ]
71                 then
72                         # lenny
73                         /lib/udev/vol_id ${device%%[0-9]*} 2>/dev/null | grep -q "^ID_FS_USAGE=raid" && continue
74                 else
75                         # squeeze
76                         /sbin/blkid -o udev -p ${device%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue
77                 fi
78
79                 magic=$(/bin/dd if="${device}" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
80
81                 if [ "${magic}" = "SWAPSPACE2" -o "${magic}" = "SWAP-SPACE" ]
82                 then
83                         #log "Found ${device}"
84                         devices="${devices} ${device}"
85                 fi
86         done
87
88         # Remove all auto swap entries
89         if grep -qs  "swap swap" "${FSTAB}"
90         then
91                 grep -v "swap swap" "${FSTAB}" > "${FSTAB}".tmp
92                 mv "${FSTAB}".tmp "${FSTAB}"
93         fi
94
95         # Add new swap entries
96         for device in ${devices}
97         do
98                 echo "${device} swap swap defaults 0 0" >> "${FSTAB}"
99         done
100 fi
101
102 # disabled for now
103 #rm -f /root/etc/rcS.d/S*checkroot.sh
104
105 if [ "${NOFASTBOOT}" != "Yes" ]
106 then
107         touch root/fastboot
108 fi
109
110 log_end_msg