删除RAID后没有文件系统

所以我在RAID1中的两个磁盘中有一个/ home分区,一个磁盘出现故障,因此系统引导了很多错误。 我没有另一个磁盘来replace失败的,所以我想删除RAID并只保留一个磁盘。 为此我做了:

  1. 停止RAID:

    mdadm –stop / dev / md1

  2. 调零块

    mdadm –zero-superblock / dev / md1

  3. 删除configuration文件/etc/mdadm/mdadm.conf

  4. 更新fstab

之后,我不能再挂载分区,因为它没有文件系统

我不知道我是否已经销毁了文件系统。 我能恢复吗?

fdisk -l返回:

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 

谢谢

正如我们所看到的(我在Msegade中看到了这个问题),问题在于由此产生的sda1不是一个带有文件系统的分区。 当您禁用RAID时,sda有一个分区包含一个带有自己的(DOS)分区表的映像:

 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): 

所以我们可以看到:

 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): 

当然,我们可以优化这个过程,但它是一个类似的程序使用分区,即虚拟机镜像。 首先,我们看到第一个自由循环设备:

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

然后我们将sda1附加到loop0

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

用kpartx我们创build映射的设备:

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

如果我们运行lsblk,我们看到结果:

 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 

和配对的设备文件:

 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 

所以我们现在可以把文件系统/ dev / mapper / loop0p1挂载到我们想要的地方。

我认为整个事情是失败的,因为你没有删除raid设备md1确切的步骤是:1.mdadm – 停止raid_device 2.mdadm –remove raid_device 3.mdadm – 零超级块component_device …