DEV Community

Cover image for Attaching Volume to a Linux Instance (EC2) cmd

Attaching Volume to a Linux Instance (EC2) cmd

1-lsblk ( List Block )
This command lists information regarding all available block devices attached to an instance and it does that by reading sysfs filesystem

Image description

2- file -s
This is used to check if a volume has file system. This command gather information about a specific device such as system type.When the ouput shows "data", this means the device has no file system on the device.

Image description

3- mkfs ( Make File System)
This command is used to create file in linux. when combined with -t=type (mkfs-t), it specified the file type

Image description

4-mount
This command is used to attaches the file system to a volume to the file tree. It is used to mount the volume at the directory created using the mkdir command.

Image description

5-/etc/fstab
This command is used to automatically mount a volume after reboot.

To mount an attached EBS volume on every system reboot, add an entry for the device to the /etc/fstab file. You can use the device name, such as /dev/xvdf, but using the device's 128-bit universally unique identifier (UUID) is the recommended method. You can open and edit the /etc/fstab using an editor such as nano or vim.

Image description

6- blkid (block ID)

The blkid (block ID) command identifies the 128-bit universally unique identifier (UUID) of the device.
Use the blkid command to identify the UUID, and make a note of the UUID of the device that you want to mount after reboot. Then add the UUID to the /etc/fstab file. (See the following item for for an explanation of the /etc/fstab file.)

Device names can change, but the UUID persists throughout the life of the partition. By using the UUID, you reduce the chances that the system becomes unbootable after a hardware reconfiguration.

Image description

Top comments (0)