The default root filesystem on an NVMe instance in the l2-series on Safespring's platform comes with an ext4 filesystem, but in some cases, users may need to create additional partitions or use a different filesystem.
Sometimes you would like to repartition this disk into several partitions if the application you want to run demands a separate partition or a certain filesystem that is not the default ext4 that the root filesystem from the cloud image is running by default. One application that demands this is MongoDB so if your aiming at setup a MongoDB cluster you will need to perform this on your cluster nodes.
Repartitioning NVMe Root FS in Safespring
- Start by creating a new instance in OpenStack with a flavor in the l2-series to ensure that the node have local NVMe.
- During the instance creation process, on the “Configuration” tab, select “Manual” for the disk partitioning option.
- In the “Customization Script” field, enter the following cloud-config code:
#cloud-config # Ubuntu 18.04+ resize_rootfs: false write_files: - content: | # Any text path: /etc/growroot-disabled runcmd: - [ sgdisk, -e, /dev/sda ] - [ partprobe ] - [ parted, -s, /dev/sda, mkpart, primary, xfs, "25%", "100%" ] - [ growpart, /dev/sda, 1 ] - [ resize2fs, /dev/sda1 ]
- Modify the above code as per your requirements. You can change the partition size and file system according to your needs.
- Click on “Launch Instance” to create the instance.
- Once the instance is launched, SSH into the instance using a tool like PuTTY.
- Check the disk partitions by running the following command. Create the new filesystem on the partition, in this case it is XFS. Ensure that the device number X below corresponds to the one from the listing of fdisk.
bash# sudo fdisk -l bash# sudo mkfs.xfs /dev/sdaX
- Mount the new partition by running the following command:
bash# sudo mount /dev/sdaX /mnt
- Verify that the partition has been mounted by running the following command:
bash# df -h
- Congratulations! You have successfully repartitioned the root filesystem and enabled XFS on the other partition using cloud-config.