Linux – How to mount a LVM controlled ext4 file system stored on a AWS EBS volume built from a snapshot

amazon-ebsext4linuxlvm

I have a ext4 file system that is part of a Logical Volume and the underlying storage is AWS EBS. I took a snapshot of the EBS and then used that to create a new EBS volume and attached it to theEC2 instance.

Since this is a binary copy of the original volume it shared the same UUID as the original LV, so I tried this to add the new device partition (/dev/xvdi1) into an existing volume group:

> # pvremove /dev/xvdi1
  Labels on physical volume "/dev/xvdi1" successfully wiped  
> # pvcreate /dev/xvdi1
 Physical volume "/dev/xvdi1" successfully created
> 
> # vgextend VGoraarch /dev/xvdi1  
 Volume group "VGoraarch" successfully extended
> 
> # lvcreate -l 100%FREE -n LVoraarch_snapshot VGoraarch /dev/xvdi1
> Logical volume "LVoraarch_snapshot" created.

When I try to do the mount:

> # mount -t ext4 /dev/mapper/VGoraarch-LVoraarch_snapshot /oraarch_snapshot mount: wrong fs type, bad option, bad superblock on
> /dev/mapper/VGoraarch-LVoraarch_snapshot,
>        missing codepage or helper program, or other error
>        In some cases useful info is found in syslog - try
>        dmesg | tail  or so

What's the correct way to get this mounted?

EDIT: Mounting to the same EC2 instance

Best Answer

All you need to do is import it. Example:

# pvscan
pvscan -- reading all physical volumes (this may take a while...)
pvscan -- inactive PV "/dev/sdb1"  is in EXPORTED VG "design" [996 MB / 996 MB free]
pvscan -- inactive PV "/dev/sdb2"  is in EXPORTED VG "design" [996 MB / 244 MB free]
pvscan -- total: 2 [1.95 GB] / in use: 2 [1.95 GB] / in no VG: 0 [0]

# vgimport design
Volume group "vg" successfully imported

# vgchange -ay design

# mkdir -p /mnt/design/users
# mount /dev/design/users /mnt/design/users

(Copied from http://tldp.org/HOWTO/LVM-HOWTO/recipemovevgtonewsys.html)