[cs615asa] mounting volumes

Jan Schaumann jschauma at stevens.edu
Sun Feb 16 15:54:16 EST 2020


Elliot Wasem <ewasem at stevens.edu> wrote:
 
> Appreciate the help. I took a look at dmesg before and after mounting, and found that before I mounted the volume, the output looked like this:
> and after I mounted the volume using the command:
> $ aws ec2 attach-volume --instance-id i-<id> --volume-id vol-<id> --device /dev/sdh
> it looked like this:
> 

A few things to note:

(1) As you can tell from the quoted text above,
screenshots of terminal output are not very useful in
online discussions; it'd be preferable to copy and
paste the text into your email.

(For example, I do not use a graphical email client and
thus do not see any images you attach; many users on
webmail clients disable the automated loading of
images for security reasons and wouldn't see your
image, either.)

(2) "mounting" a volume and "attaching" a volume are
different things; in fact, you don't _mount_ a volume,
but only a partition.

For this assignment, you do not need to mount any
partitions, as we are operating entirely on the block
level.

> which indicated to me that the device is called xbd2 . I don't see it under /dev, but I'm able to read and write to it.

Not really.

If you were to write to "/dev/xbd2", you would be
creating a regular old file named "xbd2" in the
"/dev/" directory.  (Inspect the 'ls -l' output or ask
'file /dev/xbd2'.)

That is because "xbd2" is the name of the disk, but
the OS refers to the device via partitions.  By
default, on the BSD family of OS, the 'd' partition
refers to the entire disk, which is why /dev/xbd2d
exists and can be used to reference the full disk.
This is where you want to perform your read/write
calls.

> I do however see a bunch of devices ranging from xbd2a to xbd2p .

These are the block devices created by the OS for the
given type of disk.  (For e.g. SCSI devices, you'd find
devices created that would address the different
partitions (aka "slices") as e.g., c0t5s0, where 'c0'
refers to the first _c_ontroller, 6th _t_arget, first
_s_lice.)

> I'm able to dd directly to /dev/xbd2 , and read from it with dd as well. So, I guess that's my attached volume.

See above.  You are creating a regular file and
reading/writing to that.  That file is named "xbd2",
found in the directory "/dev" on the root filesystem.

If you were to unmount your volume and attached it to
another instance, you wouldn't see the data, as it's
local to your initial instance's root file system and
root volume.

Use this as a test that your program works as
intended: after running your program, manually start a
different instance and attach your volume to that
instance, then verify you can access the data you had
written to it.

-Jan


More information about the cs615asa mailing list