Does Fdisk Cycle /dev/sdX letters when a new device is connected??? I DDed my HD

Forum Forums Official Releases antiX-21/22 “Grup Yorum” Does Fdisk Cycle /dev/sdX letters when a new device is connected??? I DDed my HD

  • This topic has 5 replies, 4 voices, and was last updated Oct 27-8:23 am by ModdIt.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #91520
    Member
    mh4speech

      I’m just here to report a problem and ask for any help or tips there may be.
      In all my years using Linux I’ve only experienced one distro that would re-sequence the list of /dev/sdx when a new USB disk was connected (It was Puppy Live USB).
      The other day I was trying to create a new LiveUSB, I very carefull used fdisk -l to get the /dev list.
      I got /dev/sdb was the 8GB USB.
      The ISO I needed was on my personal backup HDD.
      I used DD command like I always have, and can You guess what happened?
      I DDed my personal drive on /dev/sdb!!!
      I will go back and dig up the bash history and post here if anyone wants, but this is the truth.

      Only a few MBs imaged because the ISO feed got cut lol!!

      I’m trying to repair the drive with gdisk, since it’s GPT, but not having luck.
      Would like to avoid hours and hours of disk recovery scanning & copying, would probably need to buy a new HDD to accomplish that.

      My Gdisk repair didn’t go too well because after attempting repair, I still am getting alot of partition overlap problems, and the partition print out has a whole bunch of strange ASCII spread shifted characters.

      https://lihashgnis.blogspot.com/2016/07/recovering-from-corrupted-gpt-partition_30.html

      sudo gdisk /dev/sda

      GPT fdisk (gdisk) version 1.0.1

      Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present

      Found valid GPT with protective MBR; using GPT.

      Command (? for help): r

      Recovery/transformation command (? for help): b

      Recovery/transformation command (? for help): c
      Warning! This will probably do weird things if you’ve converted an MBR to
      GPT form and haven’t yet saved the GPT! Proceed? (Y/N): Y

      Recovery/transformation command (? for help): v

      No problems found. 3437 free sectors (1.7 MiB) available in 2
      segments, the largest of which is 2014 (1007.0 KiB) in size.

      Recovery/transformation command (? for help): w

      (I have hundreds of these overlaps)
      Problem: partitions 247 and 245 overlap:
      Partition 247: 15696268867415888351 to 2477319120712193364
      Partition 245: 16500765865786403329 to 14787121452623369999

      Number Start (sector) End (sector) Size Code Name
      1 17600935877212981611 15182454288615898722 14.0 EiB FFFF 慻䪙⃌Ꮑ콭ी୕偅ꋥ璌눉ᩲ䲠䜨僪狱⦆…
      2 880994787008721874 2604427601107594263 13.4 EiB FFFF 攀ᇐЭ峦忧뜇芯㺅搑쐥ꅝ傇栒ゲ錑露꘩…
      3 10891260483665785314 12758515537693138166 13.2 EiB FFFF 㣡二
      4 12106452157409985033 2622384015923480686 12.2 EiB FFFF 
      5 17619456632864016606 13554702136629671565 2.9 EiB FFFF 蜇塀Ἆೲḝ
      6 12464392710132426910 5772785129206221170 4.3 EiB FFFF 奞 島墽贖펮頇뙳⩬怒䳢ᨹ깜簅䁲쌱瑙…
      7 7631423666205415620 11063156405151571076 4.0 EiB FFFF ∬ꀄ♂ɥ㤬䦿㉲鶕ꧥ虦鄲ᙍ閖池耴…
      8 8252554820591207050 17450299612229957164 4.6 EiB FFFF 瞻⹬쿊늪圗诘ꨅ쩫ᨛ鮫ᨚ橫⫫橫ꨫ䬪溷
      9 3640956916277253734 15945459339230290747 8.3 EiB FFFF 坼氂顈嶾䬄ţ殦낫౵眞톴ꋇ䪁㤏ഠꂯ좣賵…
      10 15519560308584119740 1780812823480135431 10.8 EiB FFFF 泾蘷ᬏ܃絜෻燷鴃
      11 957033608781200646 4333311256694136308 11.4 EiB FFFF 橹힨䝃襋︘⥡㔠椿ᐞ숱ញ襫
      12 8034067125644660618 8367283283863105039 4.0 EiB FFFF 탯⦅ﯴᢄ껛
      13 6052390770665876986 9666323954142415236 4.9 EiB FFFF ک섓Ɥ暉胑殼둦ᕀŤ䂏஘ퟢ햇㢦諼舆…
      14 6995919390429739871 14542228957018842586 7.2 EiB FFFF ㋚糆ꡔ梙奁╁ᘥ픔鍋֌젠巳踄ﴝ碗ᵓ족
      15 14704749486421331456 1595401311554009844 2.3 EiB FFFF 畷᫺삔静ፔ刨પ䴺锅ꦆⰱiꙎ᥊റꦃခຠḨ…
      16 7749777692622098585 16683327623659454922 15.3 EiB FFFF ꉢ﨏ה⊨呓쯤胧ᢡ㿪洿Ӳ蓘鵍ᴝ귭赍淋㥹…
      17 12297827174826141800 3116278974036914114 2.6 EiB FFFF 嵗핵㖚⩫⬫릯髦
      18 8176701846360521000 15486706518472346989 14.3 EiB FFFF 쵺筕

      #91521
      Forum Admin
      dolphin_oracle
        Helpful
        Up
        1
        ::

        for future reference, /dev/device names are not static to a device or filesystem. there are a variety of conditions where they can change. For a while, everytime I ran update-grub, my two drives switched designations. this is one major reason by default fstab is set up with UUIDs as the unique identifier rather the /dev/device designations.

        I also hope someone will be able to help you out.

        • This reply was modified 6 months, 1 week ago by dolphin_oracle.
        #91525
        Member
        Robin
          Helpful
          Up
          1
          ::

          Hello mh4speech

          At least I have never seen an existing sdX SCSI device name assignment getting swapped on antiX when plugging an additional device. The devices get their naming strictly by order of plugging, so the freshly plugged device will always get the next available sdX assignment.

          This means, the device you’ve overwritten and the device you wanted to write to must have been unplugged or replugged after you’ve looked up its name and before applying the dd command on it.

          You should find proof about what actually has happened in your dmesg output (or possibly system logs if existing) from these events.

          As you probably know: The devices are named simply by their detection order in linux. So e.g. during boot it is enough to have some arbitrary response speed differences of two identical drives to swap their device names on each reboot.

          But generally you should know (and what dolphin oracle already had clearly stated) that sdX SCSI device names are subject of change, not expected to be consistent between reboots (“next day…”). They are to be considered not even consistent across adding and removal of devices during the recent uptime.

          So, something must have happened betwen the very instant of time you’ve been looking up the name, and the instant you’ve been overwriting it. Only you can know what it was, and if not, you could have looked it up in dmesg at least after the incident (Possibly a faulty controller has reset the connection to the drives completely for some reason, forcing a full reassignement of devices). Without this dmesg output nobody can tell you positively what has happened, since you state you’ve looked up the drive assignment immediately before dding.

          Again, I’ve never seen such a thing happen on antiX. For me not only internal classical devices keep their assignement once they are assigned on boot, but this is true also for hotplugged USB devices once they were assigned in a session. They keep their assignment in antX, until they are unplugged, and only on replugging they might get a different assignment, when something else has been plugged or removed in between.

          Meaning: If you have two USB devices, and you unplug them and replug them in reversed order as you’ve observed originally, this will result in reversed device letter assignment for these two devices, but not affect any other assigned device names. For example, let’s assume you have sda as unpluggable internal hard drive present, and have hotplugged USB devices sdb, sdc, sdd and sde. Then after removing sdc you will see in lsblk the drives sda, sdb, sdd and sde have kept their assignment, while no sdc device is present. Whatever device you hotplug next will get assigned to sdc, and then again the next one to sdf if all other device names below are used already the moment when it is plugged.

          In short words: Without having looked up the output of

          dmesg
          mount
          lsblk
          lsusb
          sudo inxi -zFdLpv8

          immediately after, you will not find out what has actually caused your accident.

          Concerning data recovery: dd has overwritten the original data structure immediately, so probably there will not be a recovery for the overlapping areas. Data recovery in general on the modern file systems is way more complicated than you might expect and how and whether you succeed depends also on the type of file system in use. Maybe you could give fixparts tool a try. You’ll find recent .deb installer packages on its download site.

          Good luck
          Robin

          Windows is like a submarine. Open a window and serious problems will start.

          #91563
          Forum Admin
          dolphin_oracle
            Helpful
            Up
            1
            ::

            clarification: internal device designations can change on boot, but not just from something getting attached while running.

            • This reply was modified 6 months, 1 week ago by dolphin_oracle.
            #91586
            Member
            mh4speech
              Helpful
              Up
              0
              ::

              Thanks for the information and responses.
              Yea so note to self, always rerun fdisk -l after connecting any new devices, before doing a DD.

              Since We are dealing with 1.5MB of DD damage onto a 4TB GPT ext4 exernal drive, do You think there is anyway to restore the partition and filesystem? Maybe I left it as NTFS I actually don’t remember… Would Partition Magic be able to repair a large single partition, I didn’t have any additional partitions.

              I have an old minitool DataRecovery that I can setup on a Windows Laptop and buy a new HDD to transfer but trying to avoid this option.

              #91600
              Member
              ModdIt
                Helpful
                Up
                0
                ::

                Before making any changes on a disk you wish to recover data from you should make a duplicate full image
                which will enable multiple repair attempts. It is very easy to make remaining data impossible to recover.

                Below thread may be of help to you.

                https://superuser.com/questions/1066049/recovering-an-hdd-after-using-dd-on-it

              Viewing 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.