Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm looking through this guide for how to add an EBS volume to an Amazon EC2 instance, and I've found this little part of instructions hard to follow:

Create an XFS file system on the EBS volume and mount it as /vol

grep -q xfs /proc/filesystems || sudo modprobe xfs
sudo mkfs.xfs /dev/sdh

echo "/dev/sdh /vol xfs noatime 0 0" | sudo tee -a /etc/fstab
sudo mkdir -m 000 /vol
sudo mount /vol

You now have a 10 GB (or whatever size you specified) EBS volume mounted under /vol with an XFS file system, and it will be automatically mounted if the instance reboots.

I don't believe I have mkfs.xfs installed, although mkfs is a valid command. This is a little too much piping and advanced syntax for me - I'm trying to figure out how to make this work on Ubuntu 10.04 and am not having any luck with it.

Can someone tell me what is being attempted here so I can try and understand it and get it working for my Ubuntu EC2 Instance?

update

A few things I figured out:

  • on my instance I had to use /dev/xvdh and not /dev/sdh
  • still not sure what grep -q xfs /proc/filesystems || sudo modprobe xfs is doing as running each of those commands does not show any results.
  • afaik the fstab is just to automatically connect the volume at boot
share|improve this question

2 Answers 2

up vote 3 down vote accepted
grep -q xfs /proc/filesystems || sudo modprobe xfs

/proc/filesystems lists all the filesystems that your kernel knows about. (Try cat /proc/filesystems to see. In the resulting list, nodev indicates that the filesystem does not expect an associated block device.)

So grep -q xfs /proc/filesystems is checking to see if your kernel knows about XFS. (The -q means "don't print anything, just set the exit status.") If not, it runs sudo modprobe xfs to load the XFS module. (The || means "run the next command only if the previous command exited non-zero," and has nothing to do with a single | that creates a pipeline.)

sudo mkfs.xfs /dev/sdh

This creates an empty XFS filesystem on the block device /dev/sdh (i.e., it formats the partition). You might have to install an XFS tools package (usually called xfsprogs) if you don't have mkfs.xfs.

echo "/dev/sdh /vol xfs noatime 0 0" | sudo tee -a /etc/fstab

This appends a line to /etc/fstab so the volume will be mounted automatically during boot. The block device needs to match the one you formatted.

sudo mkdir -m 000 /vol

This creates the directory where the new volume will be mounted. It could be anything you like. It's created without access permissions (mode 000) so that nobody will write anything to the directory when the filesystem is not mounted.

sudo mount /vol

This mounts the volume immediately, so you don't have to reboot. (It gets the mount parameters from /etc/fstab.)

share|improve this answer

If mkfs.xfs is not installed, then you skipped this step in the article:

sudo apt-get install -y xfsprogs

You wrote:

on my instance i had to use /dev/xvdh and not /dev/sdh

Yes, this is the way that attached volumes and ephemeral storage show up on modern versions of Ubuntu on EC2. The article is a bit out of date with the name of the device, but I still do everything else as described in it.

Disclosure: I wrote that article.

share|improve this answer
    
Thanks Eric. Comments were closed and I was not having much luck figuring it out. I actually did not skip the first step, but turns out /dev/sda1 was already full so it did not install with that command :) Mostly I was confused about there not being much explanation about that group of commands. Thanks for taking the time to write a great article - there is not too many good guides out there for ec2. Also, is /proc/filesystems still accurate? Or did that change to /proc/fs ? –  cwd Jan 4 '12 at 3:51
    
@cwd, /proc/filesystems is a file that lists the known filesystems. /proc/fs is a directory where certain filesystems provide more information about themselves and/or allow their parameters to be tweaked. –  cjm Jan 4 '12 at 4:32
    
@cjm - thanks! I'll have a look tomorrow –  cwd Jan 4 '12 at 4:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.