2024 10 10 managing data devices
Adding an additional detachable volume is useful for a few reasons, the most significant being that the data is sequestered from the rest of the system—a system that is intended to be mostly ephemeral, allowing at-will upgrades without threatening your data. This guide will explain how to add a volume:
- At AMI launch / instance creation
- To an existing AMI instance
- Extending a
/data
drive
WARNING: We cannot be responsible for your data. Please have a backup of your /data
before working on any of these solutions.
Adding a /data
volume during instance creation
When you are starting a lit instance for the first time (as of 0.34-08-27-b / ami-083b2a4e57c3301f2
) a 2TB root volume is automatically created and the /data
volume will be placed there. If you want to move your /data
to its own volume, you should add the volume while you are launching the instance.
- While launching the instance, you will see the root volume specified and there will be a button to “Add new volume” (figure-1)
- Click the button to add a new volume. Input the size (in gigabytes) of the volume you wish to be your new data directory. Leave the type as gp3. (figure-2)
HINT: Know your data and choose a size wisely, but it’s relatively simple to resize later.
HINT2: If your data volume needs to be larger than 16.4 TB, use “io2” as your volume type.
-
Continue with the launch configuration.
-
When the server is up and configured, connect to the instance (see “Connecting to an Instance”) as the ‘ubuntu’ user and run the ‘initdata’ command. (This will stop the platform immediately)
Adding a /data
volume to an instance with an existing partition
- Shut down the EC2 instance.
- Go to EC2 > Volumes > Create volume or visit (HERE) to add a volume through the web console.
- On the “Create Volume” screen make sure you have selected the correct Volume Type (gp3 up to 16.4TB, io2 for anything above that).
- Set your preferred size.
- Set your IOPS. Max is 16000, more IOPS means more I/O operations per second (see info in the console for more)
- Set the throughput—the AMOUNT of data that can be moved in a given amount of time. (see info in the console for more)
- Set the availability zone—best practice is to set it the same as your platform server.
- Scroll to the bottom and click “Create volume”
- Wait a few seconds, the volume will create itself. You will see the window with all of the volumes associated with your amazon web account. Select ONLY the new volume you have created. This will apply a checkmark next to the volume (figure-3)
- Make sure the volume you created is selected and look to make sure it is blue and “available”. Go to the menu in the upper-right and click Actions Attach Volume (figure-4)
- If you created the volume in the correct availability zone, you should be able to select your LIT instance to attach the volume to. Select a mount point. AWS will let you know if you cannot use the device name. (figure-5)
- Start the instance.
- Connect to the instance.
- Log in as the ‘ubuntu’ user.
- Run the ‘initdata’ command.
Extending a /data
volume
This engineering relies heavily on AWS documentation found HERE: Extend the file system after resizing an Amazon EBS volume -- AWS makes extending volumes very easy. This is, by far, the fastest, easiest, and safest way to grow your data drive. However, in the event that the work does go bad it is also by far the most destructive, and as such (and as always) you should keep or create a backup of this device.
- Log into your AWS console.
- Head to your instances.
- Click on your instance for which you wish to grow the data partition.
- Click on “Storage” for this instance and locate the “Volume ID” that contains the device name containing the partition you wish to grow.
- Click on the Volume ID you wish to grow.
- Check the box next to the ID.
- Click on the “Actions” drop down at the top of the console.
- Select “Modify Volume”
- Modify the volume details to customize the size, IOPS and throughput of your device.
- Click MODIFY to set the details and finalize.
- Use the console to watch and verify that the storage job has been completed. (Depending on the changes, this can take a long time—watch the console carefully.)
If you select the volume you have modified, you will notice that it will tell you what state the volume is in—and while it is “growing” or “optimizing”, AWS is still modifying the volume:
- While it is not required by AWS, we urge you to now reboot the system ONCE THE JOB IS COMPLETE.
At this point, the drive has been grown, but the /data
partition must be grown and then formatted to the new size. Once the platform has returned to service, log in as the ‘ubuntu’ user and finish the extension by running the “growpart” script in this manner:
**Usage: Run growpart using the device that you are trying to grow, dropping the “p” portion of the device name, but using the partition number (1) as an extra command switch… so since your /data/
partition is on /dev/nvme0n1p1
, you would growpart /dev/nvme0n1 1 **