why is this dd command incorrect?

Forum Forums New users New Users and General Questions why is this dd command incorrect?

  • This topic has 4 replies, 2 voices, and was last updated Nov 17-9:45 pm by stevesr0.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #93309
    Member
    stevesr0

      **N.B. I figured out HOW to make it work, so this post might be useful to others. The question is why do I have to use this form of the “of=destination/backup.img”, since there are many examples of copying from /dev/sda1 to /dev/sdb2…

      Hi all,

      I am playing with the dd command in VirtualBox.

      I created two partitions (/dev/sda1 mounted to media/target and /dev/sda2 mounted to /media/destination).

      On my first attempt, I was able to create a backup.img file of /dev/sda1 in /dev/sda2.

      Tonight, attempting to repeat the dd command (after adding a second test file to /dev/sda1),
      it failed.

      I UNmounted both partitions, and used the command
      "$ sudo dd if=/dev/sda1 of=/dev/sda2/sda1backup.img".

      However, I got the error message
      dd: failed to open '/dev/sda2/sda1backup.img': Not a directory

      instead of a second backup.img file being created.

      The command only works if I mount the destination partition and rewrite the dd command as

      sudo dd if=/dev/sda1 of=/media/destination/backup2.img.

      I thought it was possible to dd between partitions (/dev/sda1 to /dev/sda2) so I don’t understand when you have to use the directory location the partition is mounted upon and when you use the /dev location itself.

      stevesr0

      • This topic was modified 5 months, 2 weeks ago by stevesr0.
      #93312
      Forum Admin
      dolphin_oracle
        Helpful
        Up
        0
        ::

        you aren’t writing a partition, you are writing a file, which means you need the mounted file system, which is not at /dev/sda2/ its at /media/destination/, as you discovered.

        #93366
        Member
        stevesr0
          Helpful
          Up
          0
          ::

          Hi dolphin_oracle,

          Thanks for comment.

          Yeh. This morning it struck me that I have heard that (a) everything in Linux is a file and (b) a directory is a special kind of file.

          But I didn’t realize that “regular” files can’t exist outside of a directory.

          I guess when you copy a partition to a partition, that involves (re)creating the DIRECTORY and FILE structures, so there is no problem for dd.

          stevesr0

          #93384
          Forum Admin
          dolphin_oracle
            Helpful
            Up
            0
            ::

            when you are copying a partition to a partition, you are copying from one file to another

            /dev/whatever to /dev/whatever2

            which are both files, in the linux sense.

            But you can’t write a file inside a file with dd, which is what your original command was trying to do. you write files inside mounted file systems. /dev being the mount point for a file system, but /dev/sdXY is not, your notion of file to file holds true.

            you can see your mounted filesystems with the “df” command.

            • This reply was modified 5 months, 2 weeks ago by dolphin_oracle.
            • This reply was modified 5 months, 2 weeks ago by dolphin_oracle.
            #93433
            Member
            stevesr0
              Helpful
              Up
              0
              ::

              Hi dolphin_oracle,

              I never thought of a partition as a file (although everything in linux is a file <g>).

              That makes perfectly good (and clear) sense.

              It is interesting that you have to use the mounted “directory” name of a partition in order for dd to be able to create an image file of a partition, but dd can put a copy of a partition into another partition (mounted) using its partition name not its mounted directory name.

              Thanks.

              stevesr0

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