Created
February 23, 2018 06:09
-
-
Save mamun67/f6fa8140e93e2bc6b197b5ca5ad511e1 to your computer and use it in GitHub Desktop.
Steps to make new volume available for use in EC2
This file contains hidden or 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
| 1.Connect to your instance using SSH. | |
| 2.Use the lsblk command to view your available disk devices and their mount points (if applicable) to help you determine the correct device name to use. | |
| [ec2-user ~]$ lsblk | |
| NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT | |
| xvdf 202:80 0 100G 0 disk | |
| xvda1 202:1 0 8G 0 disk / | |
| 3.Determine whether to create a file system on the volume. New volumes are raw block devices, and you must create a file system on them before you can mount and use them. Volumes that have been restored from snapshots likely have a file system on them already; if you create a new file system on top of an existing file system, the operation overwrites your data. Use the sudo file -s device command to list special information, such as file system type. | |
| [ec2-user ~]$ sudo file -s /dev/xvdf | |
| /dev/xvdf: data | |
| 4.(Conditional) Use the following command to create an ext4 file system on the volume. Substitute the device name (such as /dev/xvdf) for device_name. Depending on the requirements of your application or the limitations of your operating system, you can choose a different file system type, such as ext3 or XFS. | |
| [ec2-user ~]$ sudo mkfs -t ext4 device_name | |
| 5.Use the following command to create a mount point directory for the volume. The mount point is where the volume is located in the file system tree and where you read and write files to after you mount the volume. Substitute a location for mount_point, such as /data. | |
| [ec2-user ~]$ sudo mkdir mount_point | |
| 6.Use the following command to mount the volume at the location you just created. | |
| [ec2-user ~]$ sudo mount device_name mount_point | |
| (Optional) To mount this EBS volume on every system reboot, add an entry for the device to the /etc/fstab file. | |
| 7.Create a backup of your /etc/fstab file that you can use if you accidentally destroy or delete this file while you are editing it. | |
| [ec2-user ~]$ sudo cp /etc/fstab /etc/fstab.orig | |
| Open the /etc/fstab file using any text editor, such as nano or vim. | |
| Note | |
| You must open the file as root or by using the sudo command. | |
| Add a new line to the end of the file for your volume using the following format: | |
| device_name mount_point file_system_type fs_mntops fs_freq fs_passno | |
| 8.The last three fields on this line are the file system mount options, the dump frequency of the file system, and the order of file system checks done at boot time. If you don't know what these values should be, then use the values in the following example for them (defaults,nofail 0 2). For more information on /etc/fstab entries, see the fstab manual page (by entering man fstab on the command line). | |
| 9. | |
| You can use the system's current device name (/dev/sda1, /dev/xvda1, etc.) in /etc/fstab, but we recommend using the device's 128-bit universally unique identifier (UUID) instead. System-declared block-device names may change under a variety of circumstances, but the UUID is assigned to a volume partition when it is formatted and persists throughout the partition's service life. By using the UUID, you reduce the chances of the block-device mapping in /etc/fstab leaving the system unbootable after a hardware reconfiguration. | |
| 10.To find the UUID of a device, first display the available devices: | |
| [ec2-user ~]$ df | |
| The following is example output: | |
| Filesystem 1K-blocks Used Available Use% Mounted on | |
| /dev/xvda1 8123812 1876888 6146676 24% / | |
| devtmpfs 500712 56 500656 1% /dev | |
| tmpfs 509724 0 509724 0% /dev/shm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment