0

So I had the /home partition in two disks in RAID1, one disk failed so the system booted with lots of errors about that. I didn't have another disk to replace the one that failed, so I wanted to remove the raid and keep only one disk. To do that I did:

  1. Stop the RAID:

    mdadm --stop /dev/md1

  2. Zeroing the blocks

    mdadm --zero-superblock /dev/md1

  3. Remove the config file /etc/mdadm/mdadm.conf

  4. Update the fstab

After that, I can no longer mount the partition because it appears as it doesn't have a filesystem.

I don't know if I have destroyed the filesystem. Can I recover it?

fdisk -l returns:

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 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: dos
Disk identifier: 0x000f04de

Device     Boot Start        End    Sectors   Size Id Type
/dev/sda1        2048 1953523711 1953521664 931.5G da Non-FS data

Thanks

1

As we saw (I saw the problem in situ with Msegade), the problem was the resultant sda1 wasn't a partition with a filesystem within. When you disabled the RAID, sda had 1 partition that contained an image with its own (DOS) partition table:

root@server:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 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: dos
Disk identifier: 0x000f04de

Device     Boot Start        End    Sectors   Size Id Type
/dev/sda1        2048 1953523711 1953521664 931.5G da Non-FS data


Command (m for help):

So we can see:

root@server:~# fdisk /dev/sda1

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sda1: 931.5 GiB, 1000203091968 bytes, 1953521664 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: dos
Disk identifier: 0x00000000

Device      Boot Start        End    Sectors   Size Id Type
/dev/sda1p1 *     2048 1953521663 1953519616 931.5G 83 Linux


Command (m for help): 

Sure we can optimize this process, but it is a similar procedure for using partitions into i.e. a virtual machine image. First, we see the first free loop device:

root@server:~# losetup -f
/dev/loop0

Then we attach our sda1 to loop0

root@server:~# losetup /dev/loop0 /dev/sda1

With kpartx we create the mapped devices:

root@server:~# kpartx -av /dev/loop0

If we run lsblk, we see the result:

root@server:~# lsblk 
NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda         8:0    0 931.5G  0 disk 
`-sda1      8:1    0 931.5G  0 part 
sdb         8:16   0 931.5G  0 disk 
|-sdb1      8:17   0   953M  0 part /
[...]
loop0       7:0    0 931.5G  0 loop 
`-loop0p1 253:0    0 931.5G  0 part

And the maped device file:

root@server:~# ls -lsa /dev/mapper/
total 0
0 drwxr-xr-x  2 root root      80 Jun 23 16:02 .
0 drwxr-xr-x 19 root root    3500 Jun 23 16:02 ..
0 crw-------  1 root root 10, 236 Jun 23 16:02 control
0 lrwxrwxrwx  1 root root       7 Jun 23 16:02 loop0p1 -> ../dm-0

So we now can mount the filesystem /dev/mapper/loop0p1 where we want.

0

I think the whole thing is failing because you didn't remove the raid device md1 The exact steps are : 1. mdadm --stop raid_device 2. mdadm --remove raid_device 3. mdadm --zero-superblock component_device…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.