Changing the filesystem on AWS EC2 is a difficult task. The easy way to use XFS filesystem on AWS EC2 for hosting MongoDB is to add an extra block storage and format it as XFS
- First create a Block Storage and attach.
- Provisioned IOPS SSD is a suitable one for high volume data flow.
- Once the block storage is attached, then use the command prompt or terminal to format the disk as XFS and mount
- apt-get update
- apt-get upgrade
- lsblk —- to view the attached block device and confirm
- file -s /dev/nvme1n1 — to check if there is a filesystem already there or not. if there is no filesystem then it will return “device” . Else it will show something like this “/dev/nvme1n1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)”.
- mkfs -t xfs /dev/nvme1n1 —– command to format the disk with XFS filesystem
- apt-get install xfsprogs –— command to install xfs tools
- mkdir /mongodata
- mount /dev/nvme1n1 /data
- mount /dev/nvme1n1 /mongodatabases/
- cp /etc/fstab /etc/fstab.orig
- blkid —– to check the UUID of the block device added
- nano /etc/fstab —– and add the device like this UUID=7xxf03xx-6xxx-4xxx-9xxx-exxxxff2xxxxf /mongodatabases xfs defaults,nofail 0 2
- umount /mongodatabases/ —– unmount and mount -a to check fstab entry
- mount -a
- reboot — I did a double check by rebooting and checked if the disk is still attched and the mounted
- df -h
- lsblk
- mount