Last active
December 28, 2021 00:45
-
-
Save jazzl0ver/8959215eaed6e8367f9a4486a5690809 to your computer and use it in GitHub Desktop.
Setup GFS2 shared storage in Proxmox VE 6 on top of iSCSI LUN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-- there're four proxmox boxes (vm-box-1..vm-box-4) | |
#-- all commands should be issued on one of the boxes | |
for i in $(seq 1 4); do ssh vm-box-$i apt install dlm-controld gfs2-utils -y; done | |
for i in $(seq 1 4); do ssh vm-box-$i 'echo DLM_CONTROLD_OPTS="--enable_fencing 0" >> /etc/default/dlm; systemctl restart dlm'; done | |
#-- check if /dev/misc folder exists. if not, run: | |
for i in $(seq 1 4); do ssh vm-box-$i "systemctl stop dlm; rmmod gfs2; rmmod dlm; sleep 3; systemctl restart udev; sleep 3; systemctl start dlm"; done | |
#-- add iscsi storage to proxmox (check shared) | |
#-- -j number should match the number of proxmox boxes, replace sdf with your iscsi device name | |
mkfs.gfs2 -t MyClusterNmae:sdf-iscsi-lun0-gfs2 -j 4 -J 64 /dev/sdf | |
mnt="/mnt/pve/iscsi-lun0-gfs2" | |
uuid=$(blkid /dev/sdf | sed -n 's/.*UUID=\"\([^\"]*\)\".*/\1/p') | |
escaped_mnt=$(systemd-escape -p --suffix=mount $mnt) | |
cat > "/etc/systemd/system/$escaped_mnt" <<EOT | |
[Unit] | |
Description = Mount GFS2 share over iSCSI LUN | |
Wants=open-iscsi.service dlm.service | |
After=open-iscsi.service dlm.service | |
[Mount] | |
What=/dev/disk/by-uuid/$uuid | |
Where=$mnt | |
Type=gfs2 | |
Options=_netdev,acl | |
[Install] | |
WantedBy=multi-user.target | |
EOT | |
for i in $(seq 1 4); do scp "/etc/systemd/system/$escaped_mnt" vm-box-$i:/etc/systemd/system/; ssh vm-box-$i "mkdir -p $mnt; systemctl daemon-reload; systemctl enable \"/etc/systemd/system/$escaped_mnt\""; done | |
#-- add directory storage proxmox (check shared) for /mnt/pve/iscsi-lun0-gfs2 | |
#-------------------------------------------------------- | |
#-- to revert everything back: | |
#-- disable/remove directory storage | |
for i in $(seq 1 4); do ssh vm-box-$i "systemctl stop \"$escaped_mnt\"; systemctl disable \"$escaped_mnt\"; systemctl daemon-reload"; done | |
#-- disable/remove iscsi storage in proxmox | |
#-- if no other iscsi targets exist, delete all sessions: | |
for i in $(seq 1 4); do ssh vm-box-$i "iscsiadm -m node --logout; iscsiadm -m node --op delete"; done | |
#-- otherwise use -T switch to specify certain target in the above commands |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment