Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to sysadmin.

I am trying to launch a EBS-backed EC2 instance.

I did the following based on mongodb docs:

sudo mdadm --verbose --create /dev/md0 --level=10 --chunk=256 --raid-devices=1 /dev/xvdh1
echo 'DEVICE /dev/xvdh1' | sudo tee -a /etc/mdadm.conf
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
sudo blockdev --setra 128 /dev/md0
sudo blockdev --setra 128 /dev/xvdh1
sudo dd if=/dev/zero of=/dev/md0 bs=512 count=1
sudo pvcreate /dev/md0
sudo vgcreate vg0 /dev/md0
sudo lvcreate -l 90%vg -n data vg0
sudo mke2fs -t ext4 -F /dev/vg0/data
sudo mkdir /data
echo '/dev/vg0/data /data ext4 defaults,auto,noatime,noexec 0 0' | sudo tee -a /etc/fstab
sudo mount /data

Now I terminated EC2 instance and trying to re-mount the EBS-vols to newly launched instance.

What I was not sure:

  • which of the above steps I need to do?
  • Which of the above steps I can skip?
  • Which of the above steps I SHOULD NOT DO at all ?(which can make things inconsistent)

On the new EC2 instace, I tried to execute the following cmd but then aborted due to warning.

I was not sure

sudo mdadm --verbose --create /dev/md0 --level=10 --chunk=256 --raid-devices=1 /dev/xvdh1
mdadm: layout defaults to n2
mdadm: layout defaults to n2
mdadm: /dev/xvdh1 appears to be part of a raid array:
    level=raid10 devices=5 ctime=Fri Jul 26 18:01:23 2013

After going thru warning/errors while executing, I skipped following steps and re-mounted:

sudo pvcreate /dev/md0
sudo vgcreate vg0 /dev/md0
sudo lvcreate -l 90%vg -n data vg0

but all the data in EBS vol is lost.

If somebody could verify, that would be great help.

share|improve this question

migrated from dba.stackexchange.com Jul 27 '13 at 21:20

This question came from our site for database professionals who wish to improve their database skills and learn from others in the community.

1 Answer 1

You dont need to create a mirror from a single EBS volume, if you arent going to mirror it, you could have used it directly.

sudo pvcreate /dev/xvdh1
sudo vgcreate vg0 /dev/xvdh1
sudo lvcreate -l 90%vg -n data vg0
sudo mke2fs -t ext4 -F /dev/vg0/data

Then if you detach this volume and attach somewhere else.

sudo pvscan

will show the new partition.

sudo lvsan 

Will show the logical volumes on this migrated partition.

sudo lvactive <volume name>

Will activate the volume so you can mount it.

sudo mkdir /data
sudo mount  /dev/vg0/data /data

If you want this to be mounted every time you boot, add it to the /etc/fstab

share|improve this answer

Your Answer

 
discard

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