Skip to content

Commit 91cc7b1

Browse files
committed
Add configuration control for /tmp file system
1 parent 800f002 commit 91cc7b1

File tree

8 files changed

+45
-11
lines changed

8 files changed

+45
-11
lines changed

oracle-linux-image-tools/distr/ol7-slim/image-scripts.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@
1616
#######################################
1717
# Validate distribution parameters
1818
# Globals:
19-
# ROOT_FS
19+
# ROOT_FS TMP_IN_TMPFS UEK_RELEASE LINUX_FIRMWARE STRIP_LOCALES EXCLUDE_DOCS
2020
# Arguments:
2121
# None
2222
# Returns:
2323
# None
2424
#######################################
2525
distr::validate() {
2626
[[ "${ROOT_FS,,}" =~ ^(xfs)|(btrfs)|(lvm)$ ]] || error "ROOT_FS must be xfs, btrfs or lvm"
27+
[[ "${TMP_IN_TMPFS,,}" =~ ^(yes)|(no)$ ]] || error "TMP_IN_TMPFS must be yes or no"
2728
[[ "${UEK_RELEASE}" =~ ^[56]$ ]] || error "UEK_RELEASE must be 5 or 6"
2829
[[ "${LINUX_FIRMWARE,,}" =~ ^(yes)|(no)$ ]] || error "LINUX_FIRMWARE must be yes or no"
2930
[[ "${STRIP_LOCALES,,}" =~ ^(yes)|(no)$ ]] || error "STRIP_LOCALES must be yes or no"
3031
[[ "${EXCLUDE_DOCS,,}" =~ ^(yes)|(no)|(minimal)$ ]] || error "EXCLUDE_DOCS must be yes, no or minimal"
31-
readonly ROOT_FS UEK_RELEASE LINUX_FIRMWARE STRIP_LOCALES EXCLUDE_DOCS
32+
readonly ROOT_FS TMP_IN_TMPFS UEK_RELEASE LINUX_FIRMWARE STRIP_LOCALES EXCLUDE_DOCS
3233
}
3334

3435
#######################################
@@ -75,6 +76,9 @@ logvol / --fstype=\"xfs\" --vgname=vg_main --size=4096 --name=lv_root --gr
7576
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
7677
sed -i -e 's!^%packages !%packages --excludedocs !' "${ks_file}"
7778
fi
79+
80+
# /tmp in tmpfs
81+
sed -i -e "s!^TMP_IN_TMPFS=no!TMP_IN_TMPFS=$TMP_IN_TMPFS!" "${ks_file}"
7882
}
7983

8084
#######################################

oracle-linux-image-tools/distr/ol7-slim/ol7-ks.cfg

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ grub2-mkconfig -o /boot/grub2/grub.cfg
189189

190190
EXCLUDE_DOCS="no"
191191
echo "Exclude documentation: ${EXCLUDE_DOCS^^}"
192-
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
192+
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
193193
echo "tsflags=nodocs" >> /etc/yum.conf
194194
fi
195195

196196
STRIP_LOCALES="no"
197197
echo "Strip locales: ${STRIP_LOCALES^^}"
198-
if [[ "${STRIP_LOCALES,,}" = "yes" ]]; then
198+
if [[ "${STRIP_LOCALES,,}" = "yes" ]]; then
199199
localedef --list-archive |
200200
grep -E -v '^C|^en_US' |
201201
xargs localedef --delete-from-archive
@@ -235,4 +235,10 @@ fi
235235
sed -i -e 's/^DEFAULTKERNEL=.*/DEFAULTKERNEL='"${kernel}"'/' /etc/sysconfig/kernel
236236

237237
yum install -y ${yum_options} ${kernel}
238+
239+
# use tmpfs for /tmp
240+
TMP_IN_TMPFS=no
241+
if [[ "${TMP_IN_TMPFS,,}" == "yes" ]]; then
242+
systemctl enable tmp.mount
243+
fi
238244
%end

oracle-linux-image-tools/distr/ol8-aarch64/image-scripts.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#######################################
1919
# Validate distribution parameters
2020
# Globals:
21-
# ISO_LABEL RESCUE_KERNEL ROOT_FS
21+
# ROOT_FS TMP_IN_TMPFS RESCUE_KERNEL ISO_LABEL LINUX_FIRMWARE EXCLUDE_DOCS
2222
# Arguments:
2323
# None
2424
# Returns:
@@ -27,11 +27,12 @@
2727
distr::validate() {
2828
[[ "${ROOT_FS,,}" =~ ^(xfs)|(btrfs)|(lvm)$ ]] || error "ROOT_FS must be xfs, btrfs or lvm"
2929
[[ "${ROOT_FS,,}" = "btrfs" ]] && echo_message "Note that for btrfs root filesystem you need to use an UEK boot ISO"
30+
[[ "${TMP_IN_TMPFS,,}" =~ ^(yes)|(no)$ ]] || error "TMP_IN_TMPFS must be yes or no"
3031
[[ "${RESCUE_KERNEL,,}" =~ ^(yes)|(no)$ ]] || error "RESCUE_KERNEL must be yes or no"
3132
[[ -n ${ISO_LABEL} ]] || error "ISO_LABEL must be provided"
3233
[[ "${LINUX_FIRMWARE,,}" =~ ^(yes)|(no)$ ]] || error "LINUX_FIRMWARE must be yes or no"
3334
[[ "${EXCLUDE_DOCS,,}" =~ ^(yes)|(no)|(minimal)$ ]] || error "EXCLUDE_DOCS must be yes, no or minimal"
34-
readonly ROOT_FS RESCUE_KERNEL ISO_LABEL LINUX_FIRMWARE EXCLUDE_DOCS
35+
readonly ROOT_FS TMP_IN_TMPFS RESCUE_KERNEL ISO_LABEL LINUX_FIRMWARE EXCLUDE_DOCS
3536
}
3637

3738
#######################################
@@ -98,6 +99,9 @@ logvol / --fstype=\"xfs\" --vgname=vg_main --size=4096 --name=lv_root --gr
9899
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
99100
sed -i -e 's!^%packages!%packages --excludedocs!' "${ks_file}"
100101
fi
102+
103+
# /tmp in tmpfs
104+
sed -i -e "s!^TMP_IN_TMPFS=no!TMP_IN_TMPFS=$TMP_IN_TMPFS!" "${ks_file}"
101105
}
102106

103107
#######################################

oracle-linux-image-tools/distr/ol8-aarch64/ol8-aarch64-ks.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fi
189189

190190
EXCLUDE_DOCS="no"
191191
echo "Exclude documentation: ${EXCLUDE_DOCS^^}"
192-
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
192+
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
193193
echo "tsflags=nodocs" >> /etc/dnf/dnf.conf
194194
fi
195195

@@ -225,6 +225,11 @@ else
225225
dnf install -y ${dnf_options} ${kernel}
226226
fi
227227

228+
# use tmpfs for /tmp
229+
TMP_IN_TMPFS=no
230+
if [[ "${TMP_IN_TMPFS,,}" == "yes" ]]; then
231+
systemctl enable tmp.mount
232+
fi
228233
%end
229234

230235
%addon com_redhat_kdump --disable

oracle-linux-image-tools/distr/ol8-slim/image-scripts.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#######################################
1919
# Validate distribution parameters
2020
# Globals:
21-
# RESCUE_LERNEL ROOT_FS
21+
# ROOT_FS TMP_IN_TMPFS RESCUE_KERNEL LINUX_FIRMWARE EXCLUDE_DOCS
2222
# Arguments:
2323
# None
2424
# Returns:
@@ -27,10 +27,11 @@
2727
distr::validate() {
2828
[[ "${ROOT_FS,,}" =~ ^(xfs)|(btrfs)|(lvm)$ ]] || error "ROOT_FS must be xfs, btrfs or lvm"
2929
[[ "${ROOT_FS,,}" = "btrfs" ]] && echo_message "Note that for btrfs root filesystem you need to use an UEK boot ISO"
30+
[[ "${TMP_IN_TMPFS,,}" =~ ^(yes)|(no)$ ]] || error "TMP_IN_TMPFS must be yes or no"
3031
[[ "${RESCUE_KERNEL,,}" =~ ^(yes)|(no)$ ]] || error "RESCUE_KERNEL must be yes or no"
3132
[[ "${LINUX_FIRMWARE,,}" =~ ^(yes)|(no)$ ]] || error "LINUX_FIRMWARE must be yes or no"
3233
[[ "${EXCLUDE_DOCS,,}" =~ ^(yes)|(no)|(minimal)$ ]] || error "EXCLUDE_DOCS must be yes, no or minimal"
33-
readonly ROOT_FS RESCUE_KERNEL LINUX_FIRMWARE EXCLUDE_DOCS
34+
readonly ROOT_FS TMP_IN_TMPFS RESCUE_KERNEL LINUX_FIRMWARE EXCLUDE_DOCS
3435
}
3536

3637
#######################################
@@ -79,6 +80,9 @@ logvol / --fstype=\"xfs\" --vgname=vg_main --size=4096 --name=lv_root --gr
7980
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
8081
sed -i -e 's!^%packages!%packages --excludedocs!' "${ks_file}"
8182
fi
83+
84+
# /tmp in tmpfs
85+
sed -i -e "s!^TMP_IN_TMPFS=no!TMP_IN_TMPFS=$TMP_IN_TMPFS!" "${ks_file}"
8286
}
8387

8488
#######################################

oracle-linux-image-tools/distr/ol8-slim/ol8-ks.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ grub2-mkconfig -o /boot/grub2/grub.cfg
155155

156156
EXCLUDE_DOCS="no"
157157
echo "Exclude documentation: ${EXCLUDE_DOCS^^}"
158-
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
158+
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
159159
echo "tsflags=nodocs" >> /etc/dnf/dnf.conf
160160
fi
161161

@@ -196,6 +196,11 @@ else
196196
dnf install -y ${dnf_options} ${kernel}
197197
fi
198198

199+
# use tmpfs for /tmp
200+
TMP_IN_TMPFS=no
201+
if [[ "${TMP_IN_TMPFS,,}" == "yes" ]]; then
202+
systemctl enable tmp.mount
203+
fi
199204
%end
200205

201206
%addon com_redhat_kdump --disable

oracle-linux-image-tools/env.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ CLOUD="none"
5050
# Root filesystem: btrfs, xfs or lvm (Default: xfs)
5151
# ROOT_FS=
5252

53+
# Set /tmp to tmpfs
54+
# TMP_IN_TMPFS="no"
55+
5356
# Which kernel? (uek, rhck, modrhck, default is distribution / cloud specific)
5457
# KERNEL=
5558

oracle-linux-image-tools/env.properties.defaults

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ SELINUX="enforcing"
2424
# Allocated disk size for the image.
2525
DISK_SIZE_GB=15
2626

27+
# Set /tmp to tmpfs
28+
TMP_IN_TMPFS="no"
29+
2730
# Root access to the VM. You must provide either a password or a key file.
2831
SSH_PASSWORD=
2932
SSH_KEY_FILE=
@@ -50,7 +53,7 @@ QEMU_BINARY=""
5053
# If defined, override generated VM_NAME
5154
VM_NAME=
5255

53-
# The following two parameters can be specified when using a boot install image
56+
# The following two parameters can be specified when using a boot install image
5457
# instead of a full DVD ISO image
5558
# URL to an installation tree on a remote server
5659
REPO_URL=

0 commit comments

Comments
 (0)