|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
After you attach an Amazon EBS volume to your instance, it is exposed as a block device. You can format the volume with any file system and then mount it. After you make the Amazon EBS volume available for use, you can access it in the same ways that you access any other volume. You can also take snapshots of your Amazon EBS volume for backup purposes or to use as a baseline when you create another volume.
To make an Amazon EBS volume available for use on Linux
Connect to your instance using SSH. For more information, see Connect to Your Instance.
Depending on the block device driver of your instance's kernel, the device may be
attached with a different name than what you specify. For example, if you specify a
device name of
/dev/sdh, your device may be renamed
/dev/hdh by the kernel; in some
cases, even the trailing letter may also change (where
/dev/xvde). Amazon Linux AMIs create a symbolic link from
the renamed device path to the name you specify, but other AMIs may behave
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.
lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT xvdf 202:80 0 100G 0 disk xvda1 202:1 0 8G 0 disk /
output of lsblk removes the
/dev/ prefix from
full device paths. In this example,
/dev/xvda1 is mounted as the
root device (note the
MOUNTPOINT is listed as
the root of the Linux file system hierarchy), and
attached, but it has not been mounted yet.
Determine if you need to create a file system on the volume. New volumes are raw
block devices, and you need to 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
sudo file -s /dev/xvdf/dev/xvdf: data
the output of the previous command shows simply
data for the device,
then there is no file system on the device and you need to create one. You can go on to
Step 4. If you run this command on a device that
contains a file system, then your output will be
sudo file -s /dev/xvda1/dev/xvda1: Linux rev 1.0 ext4 filesystem data, UUID=1701d228-e1bd-4094-a14c-8c64d6819362 (needs journal recovery) (extents) (large files) (huge files)
the above example, the device contains
Linux rev 1.0 ext4 filesystem
data, so this volume does not need a file system created (you can skip Step 4 if your output shows file system data).
(Optional) Use the following command to create an ext4 file system on the volume.
Substitute the device name (such as
device_name. Depending on the requirements of your
application or the limitations of your operating system, you may opt for a different
file system type, such as ext3 or XFS.
This step assumes that you're mounting an empty volume. If you're mounting a volume that already has data on it (for example, a volume that was restored from a snapshot), don't use mkfs before mounting the volume (skip to the next step instead). Otherwise, you'll format the volume and delete the existing data.
sudo mkfs -t ext4
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
Use the following command to mount the volume at the location you just created.
(Optional) To mount this Amazon EBS volume on every system reboot, add an entry for the
device to the
Create a backup of your
/etc/fstab file that you can use if
you accidentally destroy or delete this file while you are editing
sudo cp /etc/fstab /etc/fstab.orig
/etc/fstab file using your favorite text editor,
such as nano or vim.
Add a new line to the end of the file for your volume using the following format.
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 example below for
defaults 0 2). For more information on
/etc/fstab entries, see the fstab manual
page (by entering man fstab on the command line). For example, to
mount the ext4 file system on the device
/dev/xvdf at the mount
/data, add the following entry to
/dev/xvdf /data ext4 defaults 0 2
After you've added the new entry to
/etc/fstab, you need to
check that your entry works. Run the sudo mount -a command to
mount all file systems in
sudo mount -a
the above command does not produce an error, then your
/etc/fstab file is OK and your file system will mount
automatically at the next boot. If the command does produce any errors, examine the
errors and try to correct your
Errors in the
/etc/fstab file can render a system
unbootable. Do not shut down a system that has errors in the
(Optional) If you are unsure how to correct
errors, you can always restore your backup
/etc/fstab file with
sudo mv /etc/fstab.orig /etc/fstab
To use an Amazon EBS volume
Log in to your instance using Remote Desktop.
Windows Server 2012: Go to the Start screen.
Windows Server 2008: On the taskbar, click Start, and then click Run.
Type diskmgmt.msc and press Enter. The Disk Management utility opens.
If you're mounting a volume that already has data on it (for example, a public data set), make sure you don't reformat the volume and delete the existing data.
Select the disk that represents the new Amazon EBS volume.
On the Disk Management menu, select Action - All Tasks - Online.
A new disk needs to be initialized before it can be used. To initialize the disk:
In the Disk Management utility, select the new Amazon EBS volume disk.
On the Disk Management menu, select Action - All Tasks - Initialize Disk.
In the Initialize Disk dialog, select the disk to initialize, select the desired partition style, and press OK.
Your new Amazon EBS volume is now available for use. Any data written to this file system is written to the Amazon EBS volume and is transparent to applications using the device.