Create a /tmp partition that uses filesystem type of tmpfs in kickstart?
I'm writing a kickstart script to use when PXE booting to automatically configure new systems with basic settings. I've got everything working except for the partitioning of the boot drive: my /tmp
directory is under my /
(root) partition instead of a dedicated tmpfs
partition. I've found this support article on the topic, but it's locked behind a paywall.
This is what I have so far for partitioning in my kickstart script:
part /boot --fstype=xfs --size=1024 --ondisk=vda
part pv.01 --fstype=lvmpv --size=1 --grow --ondisk=vda
volgroup myvg --pesize=4096 pv.01
logvol swap --vgname=myvg --fstype=swap --recommended --name=swap
logvol / --vgname=myvg --fstype=xfs --grow --size=1024 --name=root
And this is the output of df
that it results in:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/myvg-root 17G 1.5G 15G 10% /
/dev/vda1 976M 144M 766M 16% /boot
tmpfs 379M 0 379M 0% /run/user/1000
The solution was unrelated to partitioning. The option to mount /tmp
as a tmpfs
is actually handled by the systemd unit file tmp.mount
, so it can be enabled in a kickstart script by enabling tmp.mount
in the post install script:
# Run post-install configuration
%post --interpreter=/usr/bin/bash --erroronfail --log=/var/log/kickstart-post.log
systemctl enable tmp.mount
%end
Which results in this df
output after boot:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/myvg-root 17G 1.5G 15G 10% /
tmpfs 1.9G 8.0K 1.9G 1% /tmp
/dev/vda1 976M 144M 766M 16% /boot
tmpfs 379M 0 379M 0% /run/user/1000
This is essentially the inverse of the process documented on the archlinux wiki for disabling this feature.
More info is available on the archlinux wiki, but an important thing to note is that if another partition is already mounted at /tmp
then this unit will have no effect, even if it is enabled.
Related reading on the pros/cons of putting /tmp
on a tmpfs
here: https://access.redhat.com/discussions/688183