How to Recover Files from a RAID System using a Bootable Linux USB Flash Drive

ibilgen
3 min readNov 8, 2019

--

When my Linux OS has failed to start, I decided to recover my important files using a bootable Linux USB disk before any attempt to fix the OS. I booted the computer from USB disk which was created with “Startup Disk Creator”. Then I selected “Try Ubuntu” option. But, I couldn’t see the the main disk which is setup with RAID system. After a search of the issue, I got that I need to mount the device to view the files.

First, run fdisk command to view all disk partitions. You can find the disk where the home directory exists from the size and type information.

bilgen@ubuntu:~$ sudo fdisk -l
[sudo] password for bilgen:
Disk /dev/loop0: 1.5 GiB, 1601015808 bytes, 3126984 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F1DF14A1-CEAA-4358-8F23-7E045C825302
Device Start End Sectors Size Type
/dev/sda1 2048 7814035455 7814033408 3.7T Linux RAID
Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C0D2CED1-16BC-4863-B338-4FFBF6BEA339
Device Start End Sectors Size Type
/dev/sdb1 2048 4095 2048 1M BIOS boot
/dev/sdb2 4096 195315711 195311616 93.1G Linux filesystem
/dev/sdb3 195315712 976771071 781455360 372.6G Linux filesystem
Disk /dev/sdc: 3.7 TiB, 4000787030016 bytes, 7814037168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 80FB5BD5-2E09-4AB8-8D25-BC6F0990DE11
Device Start End Sectors Size Type
/dev/sdc1 2048 7814035455 7814033408 3.7T Linux RAID
Disk /dev/sdd: 3.8 GiB, 4027580416 bytes, 7866368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x6fee4eb0
Device Boot Start End Sectors Size Id Type
/dev/sdd1 * 0 3251199 3251200 1.6G 0 Empty
/dev/sdd2 3221944 3226935 4992 2.4M ef EFI (FAT-12/16/32)
bilgen@ubuntu:/media/ubuntu/3019fd60-4ebb-417f-87b6-a0ec185bc564/home$ cat /proc/mdstat
Personalities :
unused devices: <none>

You can’t directly mount a disk with a RAID system. You need to run mdadm command to assemble the RAID array. I added force argument to accomplish the process.

bilgen@ubuntu:~$ sudo mdadm --assemble --scan
mdadm: /dev/md/0 assembled from 2 drives - not enough to start the array while not clean - consider --force.
bilgen@ubuntu:~$ sudo mdadm --assemble --scan --force
mdadm: Marking array /dev/md/0 as 'clean'
mdadm: /dev/md/0 has been started with 2 drives (out of 3).

Note: Install mdadm if it is not installed.

bilgen@ubuntu:~$ sudo apt-get install mdadm

You can mount the device now.

bilgen@ubuntu:~$ sudo mount /dev/md/0 /home/bilgen/Desktop

That’s it! Once you mounted it, you can access and copy your files.

bilgen@ubuntu:~$ cd /home/bilgen/Desktop/
bilgen@ubuntu:~/Desktop$ ls
lost+found user1 user2 VirtMach workspace

Below commands are useful for examination

$ cat /proc/mdstat

$ lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

After all done, it should look like below.

Note: When md0 exists in /proc/mdstat but seems to be inactive , I stopped the service then try assembling.

$ sudo mdadm --stop /dev/md0

$ sudo mdadm --assemble --scan

Run the service

sudo mdadm --manage /dev/md0 --run

To make the RAID device automatically mount at boot time

$ mdadm --examine --scan >> /etc/mdadm/mdadm.conf

For more information:

https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-18-04

--

--