Switch from vol_id to blkid if using udev >=146-1 (Closes: #555529).
[debian-live-boot.git] / scripts / live-bottom / 12fstab
blobb2f187c560cd28cc612635359e1be84b29400da1
1 #!/bin/sh
3 #set -e
5 # initramfs-tools header
7 PREREQ=""
8 FSTAB=/root/etc/fstab
10 prereqs()
12 echo "${PREREQ}"
15 case "${1}" in
16 prereqs)
17 prereqs
18 exit 0
20 esac
22 # live-initramfs header
24 . /scripts/live-functions
26 if [ -n "${NOFSTAB}" ]
27 then
28 exit 0
31 log_begin_msg "Configuring fstab"
33 # live-initramfs script
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
39 cat > ${FSTAB} << EOF
40 # /etc/fstab: static file system information.
42 # <file system> <mount point> <type> <options> <dump> <pass>
44 EOF
48 if ! grep -qs "^${UNIONTYPE}" "${FSTAB}"
49 then
50 echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> "${FSTAB}"
53 if ! grep -qs "^tmpfs /tmp" "${FSTAB}"
54 then
55 echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> "${FSTAB}"
58 if [ -z "${NOSWAP}" ]
59 then
60 devices=""
62 for device in /dev/[hs]d[a-z][0-9]*
64 if ! [ -b "${device}" ]
65 then
66 continue
69 if [ -x /lib/udev/vol_id ]
70 then
71 /lib/udev/vol_id ${device%%[0-9]*} 2>/dev/null | grep -q "^ID_FS_USAGE=raid" && continue
74 magic=$(/bin/dd if="${device}" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
76 if [ "${magic}" = "SWAPSPACE2" -o "${magic}" = "SWAP-SPACE" ]
77 then
78 #log "Found ${device}"
79 devices="${devices} ${device}"
81 done
83 # Remove all auto swap entries
84 if grep -qs "swap swap" "${FSTAB}"
85 then
86 grep -v "swap swap" "${FSTAB}" > "${FSTAB}".tmp
87 mv "${FSTAB}".tmp "${FSTAB}"
90 # Add new swap entries
91 for device in ${devices}
93 echo "${device} swap swap defaults 0 0" >> "${FSTAB}"
94 done
97 # disabled for now
98 #rm -f /root/etc/rcS.d/S*checkroot.sh
100 if [ "${NOFASTBOOT}" != "Yes" ]
101 then
102 touch root/fastboot
105 log_end_msg