If I understood correctly, you have already fixed the volume, even though you have a lost+found
directory which may or may not have critical files.
What is going on now that's blocking the VM from booting? It still can't find the boot device?
Your fdisk -l
output seems a bit off to me. Have you considered the possibility that only the partition table was damaged? In this scenario, your snapshot may be helpful, and in the best case you won't even need a(nother) fsck. But we'll need something to try to find the partition offsets - I've used testdisk successfully more than once.
In the worst case scenario, if you need to scrape anything from the volume, forensic tools like PhotoRec or Autopsy/The Sleuth Kit may prove useful.
If none of this works, give us a lsblk -o NAME,RM,SIZE,RO,TYPE,MAJ:MIN -fat
too (these flags are just to show as much information as possible), and relevant dmesg
output, if any.
Looking at the partition table for /dev/loop0
and the disk image sizes reported for /dev/loop0
and /dev/loop1
, I'm inclined to suggest that the two disks were simply bolted together and then the partition table was built for the resulting virtual disk:
Disk /dev/loop0: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Device Boot Start End Sectors Size Id Type
/dev/loop0p1 * 2048 4196351 4194304 2G 7 HPFS/NTFS/exFAT
/dev/loop0p2 4196352 1250273279 1246076928 594.2G 7 HPFS/NTFS/exFAT
and
Disk /dev/loop1: 298.1 GiB, 320072933376 bytes, 625142448 sectors
If we take the two disks at 298.1 GiB and 298.1 GiB we get 596.2 GiB total. If we then take the sizes of the two partitions 2G + 594.2G we also get 596.2 GiB. (This assumes the "G" indicates GiB.)
You have already warned that you cannot get mdadm
to recognise the superblock information, so purely on the basis of the disk partition labels I would attempt to build the array like this:
mdadm --build /dev/md0 --raid-devices=2 --level=0 --chunk=128 /dev/loop0 /dev/loop1
cat /proc/mdstat
I have a chunk size of 128KiB to match the chunk size described by the metadata still present on the disks.
If that works you can then proceed to access the partition in the resulting RAID0.
ld=$(losetup --show --find --offset=$((4196352*512)) /dev/md0)
echo loop device is $ld
mkdir -p /mnt/dsk
mount -t ntfs -o ro $ld /mnt/dsk
We already have a couple of loop devices in use, so I've avoided assuming the name of the next free loop device and instead asked the losetup
command to tell me the one it's used; this is put into $ld
. The offset of 4196532 sectors (each of 512 bytes) corresponds to the offset into the image of the second partition. We could equally have omitted the offset from the losetup
command and added it to the mount
options.
Best Answer
lsscsi
On servers where I have a lot of HDDs I've traditionally used
lsscsi
to determine which HDD is plugged into which port.You can use this output to get the names + the device & generic device names:
And use this to get the list of ports on your MB that correspond to the above devices:
You can also use the verbose output instead:
NOTE: The port that it's plugged into is the first digit in this block,
[0]
vs.[4]
in thelsscsi -H
output, for example.lshw
I've also been able to use
lshw
for this because it tells you which ports etc. a particular HDD is plugged into so it's easier to figure out which one is which in a system that has multiples. Below you can see/dev/sda
along with its serial number:You can figure out which is which based on the coordinates of their respective bus info & physical id.
smartctl
The other method I've used in the past is
smartctl
. You can query each device independently to find out it's serial number, make & model and figure out which device it is once you open up the case.ledctl/ledmon
On higher end rackmounted servers you can use
ledctl usageledctl
to light up the LED for a given HDD through its/dev/
device name.References