Linux – Corrupt Linux sda3 var drive – need some files

corruptionlinux

It's 3 a.m., and my hosting company says a 'networking issue' occurred and, in summary, they can replace the hard drive that has developed a 'fault', but they will not assist me in recovering my data off it.

I need to access and download the contents of a single folder from a (CentOS) sda3 drive, one I missed in my backups, that is, var/www/vhosts/mydomain.com/httpdocs/images/.

What can I try next?

I have logged in and tried:

rescue:~# fdisk -l

Disk /dev/sda: 1500.3 GB, 1500311977984 bytes
64 heads, 32 sectors/track, 1430809 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        3816     3907568   83  Linux
/dev/sda2            3817        5724     1953792   82  Linux swap / Solaris
/dev/sda3            5725     1430809  1459287040   8e  Linux LVM

rescue:~# mount /dev/sda1 /mnt

rescue:~# mount
/dev/ram0 on / type ext2 (rw,errors=remount-ro)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sda1 on /mnt type ext3 (rw)

rescue:~# cat /mnt/etc/fstab
/dev/sda1       /               ext3    defaults        1 1
/dev/sda2       none            swap    sw
/dev/vg00/usr   /usr            xfs     defaults        0 2
/dev/vg00/var   /var            xfs     defaults,usrquota       0 2
/dev/vg00/home  /home           xfs     defaults,usrquota       0 2
devpts          /dev/pts        devpts  gid=5,mode=620  0 0
none            /proc           proc    defaults        0 0
none            /tmp    tmpfs   defaults        0 0

rescue:~# fsck /mnt/var
fsck 1.37 (21-Mar-2005)
e2fsck 1.37 (21-Mar-2005)
fsck.ext2: Is a directory while trying to open /mnt/var
The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

rescue:~# fsck /dev/sda3
fsck 1.37 (21-Mar-2005)
e2fsck 1.37 (21-Mar-2005)
Couldn't find ext2 superblock, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sda3
The superblock could not be read or does not describe a correct ext2
filesystem.  If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>

Update

Since following the brilliant advice given below I have managed to mount the drive, but I cannot see my website directory.. This looking pretty bad now, and extremely strange. Is there anything else I can do please? The drive size still reflects that my files should be there..

rescue:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               vg00
  PV Size               1.36 TB / not usable 0
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              356271
  Free PE               353199
  Allocated PE          3072
  PV UUID               YeULc0-E3XN-aF29-6Odh-JWFZ-U9qY-4KvGvl

rescue:~# vgchange -a y
  3 logical volume(s) in volume group "vg00" now active

rescue:~# fsck /dev/vg00/var
fsck 1.37 (21-Mar-2005)

rescue:~# mount /dev/vg00/var /mnt/var

Then when I look at the space:

rescue:/# cd /mnt/var/www/vhosts/
rescue:/mnt/var/www/vhosts# ll
total 0
drwxr-xr-x  10 root root 88 Jul 24 16:19 chroot
drwxr-xr-x   5 root root 49 Jul 24 16:16 default

My website folder is not listed.

Update

rescue:/mnt/var/www/vhosts# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/ram0             252M  219M   33M  88% /
tmpfs                 7.9G  4.0K  7.9G   1% /dev/shm
/dev/sda1             3.7G  319M  3.4G   9% /mnt
/dev/mapper/vg00-var  4.0G  104M  3.9G   3% /mnt/var

That looks about as bad as it can get.. Am I at a total loss?

Best Answer

You won't be able to fsck /dev/sda3 directly. From your example, /dev/sda3 doesn't have a filesystem on it, it has an LVM "physical volume":

rescue:~# fdisk -l
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        3816     3907568   83  Linux
/dev/sda2            3817        5724     1953792   82  Linux swap / Solaris
/dev/sda3            5725     1430809  1459287040   8e  Linux LVM

This physical volume most likely has (at least) one "volume group", which can in turn have multiple "logical volumes":

rescue:~# cat /mnt/etc/fstab
[...]
/dev/vg00/usr   /usr            xfs     defaults        0 2
/dev/vg00/var   /var            xfs     defaults,usrquota       0 2
/dev/vg00/home  /home           xfs     defaults,usrquota       0 2

These logical volumes are where the filesystems live that you'll need to mount.

To proceed, you'll need to get the system to recognize /dev/sda3 as a physical volume. Run pvdisplay to see if the volume is detected; if you're lucky, it is, and you can use vgchange -a y to activate the volume group into /dev/vg00. That will make /dev/vg00/var available to be fsck'ed and mounted as a standard filesystem.

Related Topic