Project

General

Profile

« Previous | Next » 

Revision 91d8c6c9

Added by Christian McDonald about 3 years ago

Revert "Fixes RAM disk handling on ZFS (support boot environments)"

This reverts commit e6b47d6812b1a46738c75a8991cd1393b200d7ef

View differences:

src/etc/inc/pkg-utils.inc
114 114
		}
115 115
	}
116 116

  
117
	// if (isset($config['system']['use_mfs_tmpvar']) &&
118
	//     !file_exists("/conf/ram_disks_failed")) {
119
	// 	$pkg_env_vars['PKG_DBDIR'] = '/root/var/db/pkg';
120
	// 	$pkg_env_vars['PKG_CACHEDIR'] = '/root/var/cache/pkg';
121
	// }
117
	if (isset($config['system']['use_mfs_tmpvar']) &&
118
	    !file_exists("/conf/ram_disks_failed")) {
119
		$pkg_env_vars['PKG_DBDIR'] = '/root/var/db/pkg';
120
		$pkg_env_vars['PKG_CACHEDIR'] = '/root/var/cache/pkg';
121
	}
122 122

  
123 123
	foreach ($extra_env as $key => $value) {
124 124
		$pkg_env_vars[$key] = $value;
src/etc/pfSense-rc
144 144
	/sbin/reboot
145 145
fi
146 146

  
147
. /etc/rc.ramdisk_functions.sh
148

  
149 147
# Handle ZFS read-only case
150 148
unset USE_ZFS
151 149
if /sbin/kldstat -qm zfs; then
......
165 163
			/sbin/zpool import -f bootpool
166 164
		fi
167 165
		# We need to handle ZFS boot environments here
168
		_be_mount_zfs
166
		echo "Enabling ZFS boot environment..."
167
		/etc/rc.d/zfsbe onestart
169 168
	fi
170 169
fi
171 170

  
......
182 181
# Sanity check the clock
183 182
/etc/rc.checkclock
184 183

  
184
. /etc/rc.ramdisk_functions.sh
185

  
185 186
# Check if RAM disks are enabled, store for repeated use
186 187
if ramdisk_check_enabled; then
187 188
	USE_RAMDISK=true
188 189
fi
189 190

  
190
# Relocate pkgdb on UFS based on desired RAM disk settings
191
if [ -z "${USE_ZFS}" ]; then
192
	ramdisk_relocate_pkgdb_all
193
fi
191
# Relocate pkgdb based on desired RAM disk settings
192
ramdisk_relocate_pkgdb_all
194 193

  
195 194
# Dismount /tmp and /var on ZFS if using RAM disks and they are separate volumes
196 195
if [ -n "${USE_ZFS}" -a -n "${USE_RAMDISK}" ]; then
197
	ramdisk_fixup_zfs_unmount
196
	ramdisk_fixup_zfs umount
198 197
fi
199 198

  
200 199
# Attempt to create and mount RAM disks
......
202 201
	/etc/rc.embedded
203 202
fi
204 203

  
205
# If RAM disks are active, make symlinks for pkg database on UFS
204
# If RAM disks are active, make symlinks for pkg database
206 205
if [ -n "${USE_RAMDISK}" -o -n "${MOVE_PKG_DATA}" ]; then
207
	if [ -z "${USE_ZFS}" ]; then
208
		ramdisk_link_pkgdb
209
	fi
206
	ramdisk_link_pkgdb
210 207
fi
211 208

  
212 209
# If activating RAM disks failed, then undo some of the above actions
213 210
if [ -n "${USE_RAMDISK}" ] && ramdisk_failed; then
214
	ramdisk_fixup_zfs_mount
215
	if [ -z "${USE_ZFS}" ]; then
216
		ramdisk_relocate_pkgdb disk
217
	fi
211
	ramdisk_fixup_zfs mount
212
	ramdisk_relocate_pkgdb disk
218 213
else
219 214
	ramdisk_reset_status
220 215
fi
src/etc/rc.ramdisk_functions.sh
26 26
RAMDISK_DEFAULT_SIZE_tmp=40
27 27
RAMDISK_DEFAULT_SIZE_var=60
28 28

  
29
# Replacement for /etc/rc.d/zfsbe onestart
30
_be_remount_ds() {
31
	local _dataset="${1}"
32

  
33
	/sbin/zfs list -rH -o mountpoint,name,canmount,mounted -s mountpoint -t filesystem "${_dataset}" | \
34
	while read _mp _name _canmount _mounted ; do
35
		# skip filesystems that must *not* be mounted
36
		[ "${_canmount}" = "off" -o "${_mp}" = "/" ] && continue
37
		# unmount the dataset if mounted...
38
		[ "$_mounted" = "yes" ] && /sbin/umount -f "${_name}"
39
		# mount the dataset
40
		/sbin/zfs mount "${_name}"
41
	done
42
}
43

  
44
# Replacement for /etc/rc.d/zfsbe onestart
45
_be_mount_zfs() {
46
	echo -n "Mounting ZFS boot environment..."
47
	/sbin/mount -p | while read _dev _mp _type _rest; do
48
		[ "${_mp}"  = "/" ] || continue
49
		if [ "${_type}" = "zfs" ] ; then
50
			_be_remount_ds "${_dev}"
51
		fi
52
		break
53
	done
54
	echo " done."
55
}
56

  
57 29
# Check if RAM disks are enabled in config.xml
58 30
ramdisk_check_enabled () {
59 31
	[ "$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)" = "true" ]
......
216 188
	fi
217 189
}
218 190

  
219
# Unmounts parent and subordinate datasets
220
ramdisk_zfs_deep_unmount() {
221
	local _path="${1}"
222

  
223
	/sbin/zfs list -rH -o name,mountpoint -S mountpoint -t filesystem "${_path}" | \
224
	while read _name _mp; do
225
		echo -n "Unmounting ZFS volume ${_name} at ${_mp} for RAM disk..."
226
		/sbin/zfs unmount -f "${_name}" 1>/dev/null 2>&1
227
		echo " done."
228
	done
229
}
230

  
231
# Mounts ZFS datasets and BE datasets
232
ramdisk_fixup_zfs_mount() {
233
	echo -n "Mounting ZFS volumes..."
234
	/sbin/zfs mount -a 1>/dev/null 2>&1
235
	_be_mount_zfs
236
	echo " done."
237
}
238

  
239
# Unmounts ZFS datasets and remounts BE datasets
240
ramdisk_fixup_zfs_unmount() {
241
	ramdisk_zfs_deep_unmount "/tmp"
242
	ramdisk_zfs_deep_unmount "/var"
243
	_be_mount_zfs
191
# Either unmount or mount /var and /tmp in ZFS as needed to avoid conflicts with
192
#   active RAM disk options.
193
ramdisk_fixup_zfs () {
194
	# Mount /var and /tmp on ZFS filesystems when necessary
195
	if [ ${1} = "mount" ]; then
196
		echo "Remounting ZFS volumes"
197
		zfs mount -a
198
	else
199
		zfs list -H -o name,mountpoint |
200
		    while read volume mountpoint; do
201
			[ "${mountpoint}" != "/var" -a "${mountpoint}" != "/tmp" ] \
202
				&& continue
203
			echo "Dismounting ZFS volume ${volume} for RAM disk"
204
			/sbin/zfs umount ${volume}
205
		done
206
	fi
244 207
}
src/etc/skel/dot.shrc
35 35
fi
36 36

  
37 37
USE_MFS_TMPVAR=$(/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar)
38
# if [ "${USE_MFS_TMPVAR}" = "true" ] && [ ! -f /conf/ram_disks_failed ]; then
39
# 	export PKG_DBDIR='/root/var/db/pkg'
40
# 	export PKG_CACHEDIR='/root/var/cache/pkg'
41
# fi
38
if [ "${USE_MFS_TMPVAR}" = "true" ] && [ ! -f /conf/ram_disks_failed ]; then
39
	export PKG_DBDIR='/root/var/db/pkg'
40
	export PKG_CACHEDIR='/root/var/cache/pkg'
41
fi
42 42

  
43 43
# Detect interactive logins and display the shell
44 44
unset _interactive
src/etc/skel/dot.tcshrc
76 76
endif
77 77

  
78 78
set use_mfs_tmpvar=`/usr/local/sbin/read_xml_tag.sh boolean system/use_mfs_tmpvar`
79
# if ( $use_mfs_tmpvar == "true" && ! -f "/conf/ram_disks_failed" ) then
80
# 	setenv PKG_DBDIR '/root/var/db/pkg'
81
# 	setenv PKG_CACHEDIR '/root/var/cache/pkg'
82
# endif
79
if ( $use_mfs_tmpvar == "true" && ! -f "/conf/ram_disks_failed" ) then
80
	setenv PKG_DBDIR '/root/var/db/pkg'
81
	setenv PKG_CACHEDIR '/root/var/cache/pkg'
82
endif

Also available in: Unified diff