Skip to content

Commit

Permalink
Merge pull request #5885 from szczepax/add_fstab_mount
Browse files Browse the repository at this point in the history
FEAT: permanent mounting of PMem in ansible script
  • Loading branch information
grom72 committed Oct 24, 2023
2 parents 069efd7 + 4d67cd6 commit eb24429
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions utils/ansible/configure-pmem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@
vars:
newRegions: false
testUser: pmdkuser
mountPoint: /mnt/pmem0

tasks:
- name: "Test if ndctl is installed"
shell: which ndctl

- name: "Remove fstab entry if it exist"
ansible.posix.mount:
path: "{{ mountPoint }}"
state: absent_from_fstab
backup: true

- name: "Unmount namespaces if they exist"
shell: sudo umount /dev/pmem* || true

Expand Down Expand Up @@ -64,7 +71,6 @@
#!/usr/bin/env bash
DEV_DAX_R=0x0000
FS_DAX_R=0x0001
MOUNT_POINT="/mnt/pmem0"
function check_alignment() {
local size=$1
Expand Down Expand Up @@ -118,13 +124,13 @@
pmem_name=$(create_fsdax)
if [ ! -d "${MOUNT_POINT}" ]; then
sudo mkdir ${MOUNT_POINT}
if [ ! -d "{{ mountPoint }}" ]; then
sudo mkdir {{ mountPoint }}
fi
sudo mkfs.ext4 -F /dev/${pmem_name}
sudo mount -o dax /dev/${pmem_name} ${MOUNT_POINT}
sudo chown -R {{ testUser }} ${MOUNT_POINT}
sudo mount -o dax=always /dev/${pmem_name} {{ mountPoint }}
sudo chown -R {{ testUser }} {{ mountPoint }}
sudo chmod 777 /dev/dax* || true
sudo chmod a+rw /sys/bus/nd/devices/region*/deep_flush
Expand All @@ -133,3 +139,17 @@
register: script

- debug: var=script

- name: "Get PMEM device name for {{ mountPoint }} mount point"
shell: |
mount | sed -nr "s/^.*(\/dev\/\S+) on \/mnt\/pmem0.*$/\1/p"
register: pmem_name

- name: "Add /etc/fstab entry for PMEM"
ansible.posix.mount:
path: "{{ mountPoint }}"
src: "{{ pmem_name.stdout }}"
fstype: ext4
opts: rw,relatime,dax=always
state: present
backup: true

0 comments on commit eb24429

Please sign in to comment.