How to use LUKS data disk encryption in MapR
MapR (now part of HPE Ezmeral) supports encryption at various levels, but using LUKS (Linux Unified Key Setup) encryption for data disks is a system-level operation that must be done outside of MapR’s native encryption features. Here’s a step-by-step guide to set up LUKS disk encryption on a MapR node and ensure MapR can access the encrypted disk after unlocking it.
Steps to Set Up LUKS Disk Encryption for MapR Data Disks
1. Identify the Disk to Encrypt
Find the disk you want to encrypt using the lsblk or fdisk command:
bash
lsblk
fdisk -l
For example, if the disk to be encrypted is /dev/sdb, use that in the following steps.
2. Install the Necessary Packages
Ensure you have the required tools to set up LUKS encryption:
sudo apt-get install cryptsetup # For Ubuntu/Debian
sudo yum install cryptsetup # For CentOS/RHEL
3. Set Up LUKS Encryption on the Disk
Run the following command to initialize the disk with LUKS encryption:
sudo cryptsetup luksFormat /dev/sdb
You’ll be prompted to confirm the operation and set a passphrase.
⚠️ Warning: This will erase all existing data on the disk.
4. Open and Map the Encrypted Disk
Unlock the encrypted disk and map it to a device:
sudo cryptsetup open /dev/sdb mapr_data_disk
You can verify that the encrypted device is available:
lsblk
5. Format the Encrypted Disk
Format the newly mapped device with a filesystem that MapR supports (typically ext4 or xfs):
sudo mkfs.ext4 /dev/mapper/mapr_data_disk
6. Mount the Encrypted Disk
Create a mount point and mount the encrypted disk:
sudo mkdir -p /opt/mapr/data
sudo mount /dev/mapper/mapr_data_disk /opt/mapr/data
7. Make the Mount Persistent
Edit the /etc/crypttab file to automatically unlock the disk at boot:
echo “mapr_data_disk /dev/sdb none luks” | sudo tee -a /etc/crypttab
Then, add an entry to /etc/fstab to mount the disk automatically after it is unlocked:
echo “/dev/mapper/mapr_data_disk /opt/mapr/data ext4 defaults 0 0” | sudo tee -a /etc/fstab
8. Ensure MapR Can Access the Disk
Make sure the MapR user has the necessary permissions to access the encrypted disk:
sudo chown -R mapr:mapr /opt/mapr/data
9. Test the Setup
Reboot the system to ensure the encrypted disk is unlocked and mounted correctly:
sudo reboot
After the system reboots, verify that the disk is unlocked and mounted:
lsblk
df -h
10. Verify MapR Storage Pools
After the encrypted disk is mounted, add it to the MapR storage pool:
maprcli disk add -server <server_name> -disks /dev/mapper/mapr_data_disk
Additional Considerations
- Passphrase Management: Consider integrating with a key management system (KMS) to avoid manual passphrase entry.
- Performance Impact: Encryption may introduce some performance overhead, so test accordingly.
- Backup Configuration Files: Ensure you back up /etc/crypttab and /etc/fstab for disaster recovery.