Recover DD-d partition info

hunandoz
hunandoz Posts: 17  Freshman Member
First Comment
edited February 2020 in Personal Cloud Storage
Dear all,

I have unfortunately deleted my sda partition info with (dd if=/dev/zero of=/dev/sda) when I wanted to repair my SD Card partion table in sdb. :-( 
Right now system is up and running, but if I lose power, perform restart -->everything will be gone. I do not have backup possibilty of the total NAS content.
If possible I would like to recover the partitions without removing the HDD from the system. Also if possible I do not want to install debian/ubuntu onto a PC.

Thank you for your help in advance!

lsblk:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 140M 1 loop /ram_bin
sda 8:0 0 1.8T 0 disk:
|-sda1 8:1 0 502M 0 part /zyxel/mnt/sysdisk
`-sda2 8:2 0 1.8T 0 part
`-md0 9:0 0 1.8T 0 linear /i-data/1877af91

fdisk -l:
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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 identifier: 0x00000000
Disk /dev/sda doesn't contain a valid partition table


#NAS_Feb_2020
«1

Comments

  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    Dear All,
    if mdstat states md0 has active device  sda2 - am I ok?
    cat /proc/mdstat
    Personalities : [linear] [raid0] [raid1]
    md0 : active linear sda2[0]
          1952996928 blocks super 1.2 0k rounding

    mdadm --examine /dev/sda1
    mdadm: No md superblock detected on /dev/sda1.

    mdadm --examine /dev/sda2
    /dev/sda2:
    Magic : a92b4efc
    Version : 1.2
    Feature Map : 0x0
    Array UUID : 1877af91:c4d12aaf:62318110:85a049b4
    Name : NAS:0 (local to host NAS)
    Creation Time : Sun Mar 24 23:38:55 2019
    Raid Level : linear
    Raid Devices : 1
    Avail Dev Size : 1952996928 (1862.52 GiB 1999.87 GB)
    Used Dev Size : 0
    Data Offset : 2048 sectors
    Super Offset : 8 sectors
    State : clean
    Device UUID : 2a4ec1ab:c15d1211:dbf7ffc6:10f1e4d3
    Update Time : Sun Mar 24 23:38:55 2019
    Checksum : e2dc1423 - correct
    Events : 0
    Rounding : 0K
    Device Role : Active device 0
    Array State : A ('A' == active, '.' == missing)
  • Mijzelf
    Mijzelf Posts: 2,761  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    You'll have to recreate the partition table manually. You can find the start sector and size of the partitions with

    cat /sys/block/sda/sda1/start
    cat /sys/block/sda/sda1/size
    cat /sys/block/sda/sda2/start
    cat /sys/block/sda/sda2/size

  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    Mijzelf,
    Thank you for the starting step; Now I know the start/size for both partition. 
    cat /sys/block/sda/sda1/start
    63
    cat /sys/block/sda/sda1/size
    1028097

    cat /sys/block/sda/sda2/start
    1028160
    cat /sys/block/sda/sda2/size
    3905995905

    Can ou help me with fdisk as well?
    I am afraid as the NAS sees the volume (sda2) as JBOD [as far as I understand it], so I do not want crush it.


  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    I have just checked one more thing; /dev/md0 is as well existing in fdisk. 

    fdisk -l
    Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
    255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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 identifier: 0x00000000

    Disk /dev/sda doesn't contain a valid partition table

    Disk /dev/md0: 1999.9 GB, 1999868854784 bytes
    2 heads, 4 sectors/track, 488249232 cylinders, total 3905993857 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 identifier: 0x00000000

    Disk /dev/md0 doesn't contain a valid partition table

  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    Mijzelf,

    As far as I have checked;
    fdisk /dev/sda (am I need sudo?)
    select "n" as new partition
    select "p" as primary (? - it will "name" it as sda1?)
    enter "63"
    enter "1028097"
    repeat with sda2 data
    n, p, 1028160, 3905995905.

    How to connect it to md0? (Sorry for my poor linux knowledge)
    Thank you for your patience, and understanding,
  • Mijzelf
    Mijzelf Posts: 2,761  Guru Member
    250 Answers 2500 Comments Friend Collector Seventh Anniversary
    I have just checked one more thing; /dev/md0 is as well existing in fdisk.
    fdisk runs on any block device, and even on files. But as you can see, md0 doesn't contain a valid partition table, so it's pretty meaningless here.
    As far as I have checked;
    fdisk /dev/sda (am I need sudo?)
    By default there is no sudo on the box. If you logged in using the same credentials as you used to dd the partition table away, you don't need it.
    (? - it will "name" it as sda1?)
    Yes.
    How to connect it to md0?
    You don't need to. The partition table is not more then a database which contains the location and size of the partitions. You didn't change anything in the partition itself, so if you recover the table, the partitions will be as they always were. sda2 contains a header which tells it's a part of md0.



  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    Mijzelf,
    Thank you for the given instruction. 
    But I was unable to create 1st partition, as the possible value range is 2048  - 3907029167.
    I have stopped / quit from fdisk.
  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    Mijzelf,
    One more question. I am able to create the sda2, the id is 83 - "linux" is it OK?
  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    Mijzelf, 
    Sorry to asking many questions. 
    The end sector shall be 1028160 + 3905995905 = 3907029167
    Am I right?
  • hunandoz
    hunandoz Posts: 17  Freshman Member
    First Comment
    I have googled, and switched on "dos compatibility flag" with issue "c". Many thanks!!!
    Shall I do anything else?

Consumer Product Help Center