On 2021-08-24 at 12:12 +0300, Reco wrote: > Hi. > > On Tue, Aug 24, 2021 at 12:04:40PM +0300, Semih Ozlem wrote: > > I accidentally turned my hard disk to swap (I was using a usb for > > swap, > > when entering the command I wrote the wrong disk id). Can I recover > > the > > disk to its previous form? > > Most of the files are likely were left intact, but the partition > table > is likely to be destroyed. > I suggest doing the usual: > > 1) Immediately copy all disk contents by ddrescue (or equvalent) > elsewhere. > 2) Put the disk in question aside, do not attach it to anything. > 3) Operate on disk copy from pt 1 only. > 4) Install "testdisk" package, and feed your disk image to photorec > (it's > provided by "testdisk"). > > Reco
Actually, testdisk itself (not photorec) is probably able to recover the header. mkswap seems to only touch little more than the first 1000 bytes (plus a label). *If* it wasn't actually used as a swap disk (in which case, who knows what might have been overwritten), everything will be there. If you turned into a swap the full disk, and not a partition, then "only" the partition table and/or bootloader will have been overwritten, which should be quite recoverable by testdisk (and reinstalling grub, probably). Good luck