I made a mistake yesterday and deleted a partition that I thought was overlapping another partition. I've tried using TestDisk to find the original structure, but without success. After I ran the following series of fateful commands, nothing boots now. Can anyone help me?
$this->bbcode_second_pass_code('', '
[root@alarmpi ~]# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.24.1).
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/mmcblk0: 1.9 GiB, 2007498752 bytes, 3920896 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: 0x417ee54b
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 2048 186367 92160 c W95 FAT32 (LBA)
/dev/mmcblk0p2 186368 3667967 1740800 5 Extended
/dev/mmcblk0p5 188416 3667967 1739776 83 Linux
Command (m for help): d
Partition number (1,2,5, default 5): 2
Partition 2 has been deleted.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
[root@alarmpi ~]# reboot
')
Before all this trouble, I thought /dev/mmcblk0p2 looked very strange, as it starts just a few thousand blocks before /dev/mmcblk0p5, but ends the same. I guessed (incorrectly) that just removing /dev/mmcblk0p2 (which was not in use by the system, as far as I could tell) would be okay. But I think it removed both partitions at the same time. I am hoping that there is a way to directly edit the partition table and manually define the start, end, and type of each partition, in the hopes that everything will boot again.
Output of TestDisk searching for partitions:
$this->bbcode_second_pass_code('', '
Hard disk list
Disk /dev/sda - 256 GB / 238 GiB - CHS 31130 255 63, sector size=512 - SAMSUNG MZMTD256HAGM-000L1, S/N:S15GNEACC02484, FW:DXT42L0Q
Disk /dev/sdc - 2007 MB / 1914 MiB - CHS 244 255 63, sector size=512 - Kingston FCR-HS219/1, S/N:094602011451, FW:9738
Partition table type (auto): Intel
Disk /dev/sdc - 2007 MB / 1914 MiB - Kingston FCR-HS219/1
Partition table type: Intel
Analyse Disk /dev/sdc - 2007 MB / 1914 MiB - CHS 244 255 63
Geometry from i386 MBR: head=154 sector=45
FAT16 at 0/32/33
Info: size boot_sector 184320, partition 184320
FAT1 : 1-180
FAT2 : 181-360
start_rootdir : 361
Data : 393-184316
sectors : 184320
cluster_size : 4
no_of_cluster : 45981 (2 - 45982)
fat_length 180 calculated 180
heads/cylinder 61 (FAT) != 255 (HD)
sect/track 62 (FAT) != 63 (HD)
Current partition structure:
Warning: number of heads/cylinder mismatches 61 (FAT) != 255 (HD)
Warning: number of sectors per track mismatches 62 (FAT) != 63 (HD)
1 * FAT16 >32M 0 32 33 11 153 14 184320 [NO NAME]
2 P Linux 11 153 15 228 81 45 3481600
search_part()
Disk /dev/sdc - 2007 MB / 1914 MiB - CHS 244 255 63
FAT16 at 0/32/33
FAT1 : 1-180
FAT2 : 181-360
start_rootdir : 361
Data : 393-184316
sectors : 184320
cluster_size : 4
no_of_cluster : 45981 (2 - 45982)
fat_length 180 calculated 180
heads/cylinder 61 (FAT) != 255 (HD)
sect/track 62 (FAT) != 63 (HD)
FAT16 at 0/32/33
FAT16 >32M 0 32 33 11 153 14 184320 [NO NAME]
FAT16, blocksize=2048, 94 MB / 90 MiB
')