0

So I was running a dd command to clone the ssd of my steam deck to a new one I have connected externally with an adapter enclosure. Problem is like a dummy I didn’t check my battery before starting and ran out of battery part way through. It only has one USB-C port.

How would I go about running this command again correctly maybe without copying all the same files twice? I don’t mind starting all over and deleting the contents I already copied to the new drive if need be.

I just have no idea how to best go about it. I was following a video I saw on YouTube. The command I want to use is just the following below. How to cleanly do it again??

Clone command:

sudo dd if=/dev/nvmeOn1 of=/dev/sda oflag=sync bs=128M status=progress
Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
Hello
  • 1
  • 1
  • 1
    “It only has one USB-C port.” If you ask me, you should get a cheap USB-C dock or hub that allows you to connect a drive and send power to the laptop at the same time. This is a good thing to have not just in this case, but in general. One port stinks for USB-C machines. – Giacomo1968 Jan 11 '23 at 16:28
  • 1
    Absolutely. My next purchase will be a dock. Thanks! – Hello Jan 11 '23 at 16:56

1 Answers1

2

maybe without copying all the same files twice?

As far as your dd was concerned, the only files are /dev/nvmeOn1 (probably you meant /dev/nvme0n1) and /dev/sda. dd does not understand, does not analyze filesystems inside. In your case dd was copying raw content of one block device to the other. This cannot be simply "translated" to copying files from one filesystem to another.

If you have a firm clue how far your dd got then it's possible to reasonably "resume" using skip= and seek= options of dd. If not or in case of any doubts, or simply to be on the safe side, just start over. If the hardware is healthy, it should work.

Let me say this explicitly, so there is no doubt: if you want to start over, in case of the command in question there is nothing to revert, nothing to fix. Repeating the entire procedure including the command in question is a clean way to start over. The fact the same command has been run and died is irrelevant.

There may be problems if:

  • the content of /dev/nvme0n1 changes during the operation of (the new invocation of) dd; I assume the video you saw on YouTube provides a procedure that solves this problem (if not then it's flawed in the first place); I don't know the procedure, there may be some important preliminary steps (like unmounting filesystem(s) or mounting read-only) you should take before repeating the dd command after restarting the Steam Deck;

  • there is Btrfs inside (some partition(s) of) /dev/nvme0n1; the reason is cloning a Btrfs filesystem to another block device may lead to data loss; but AFAIK Steam Deck does not use Btrfs by default (at least when I'm writing this); still in general it's possible to use Btrfs with Steam Deck; this remark is mainly for future users who find this question and they know they use Btrfs;

  • you decide to abort and leave /dev/sda as it is; then the content of it (being only a partial copy of the other device) may cause some inconsistencies and thus problems; but you don't want to abort.

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
  • Hello! Thanks for going more in depth. I had typed out a reply but was still doing some research while my deck charges. – Hello Jan 11 '23 at 16:47
  • 1
    `cmp` is a way to find the offset to resume, I guess. Still, it takes time. – Tom Yan Jan 11 '23 at 16:49
  • @TomYan True. Additionally it takes effort to calculate the right `skip=` and `seek=`, unless the OP's `dd` supports `skip_bytes` and `seek_bytes`. Personally I prefer to [KISS](https://en.wikipedia.org/wiki/KISS_principle), so I'm not going to include this solution in my answer. Still, if you (or anyone) write an answer that covers the `cmp` approach nicely then I will upvote it. – Kamil Maciorowski Jan 11 '23 at 17:00
  • I was going to say I wouldn’t know how to run the compare command. I am very new to the environment in the deck as you can tell from my question probably. But out of morbid curiosity I do want to know! Thanks so much for all the help. Trying to wrap my mind around what this program does. It should essentially be formatting my drive by copying the raw bytes from the other drive? Did I understand correctly. – Hello Jan 11 '23 at 17:09
  • @Hello By "this program" you mean `dd`? or `cmp`? – Kamil Maciorowski Jan 11 '23 at 17:11
  • I did mean reading up on dd. – Hello Jan 11 '23 at 17:36
  • @Hello A block device like `nvme0n1` is somewhat different than a regular file, but in the context of your question you can imagine it as a binary blob of a fixed size. If there is a partition table, it's inside the blob and partitions are fragments of the blob, conveniently accessible as separate device files like `nvme0n1p1` or so. A filesystem is a data structure within a file (block device, regular file, whatever). Your `dd` could be `cp`. It copies one blob to the other device, so the other blob becomes the same (up to the size of the smaller device), including filesystems it contains. – Kamil Maciorowski Jan 11 '23 at 18:04
  • It’s funny but I thought I had typed the command if=/dev/nvme0n1 but I actually typed O like the youtuber said (i copy and pasted the command from the description box in the video to my notes and followed it to a T, some typo!) because I was getting an infinite loop and now it’s actually giving me a progress and completion. Thanks very much! – Hello Jan 11 '23 at 18:23