Ls

如何檢查 /dev/sdt 的內容

  • April 12, 2019

我希望這不是一個大問題,但它最終可能會成為一個非常大的問題。

在某些情況下,我錯誤地在我的 27" iMac 上執行了這個命令:

sudo dd if=ubuntu-rescue.img of=/dev/sdt bs=1m

之後,它給了我以下輸出:

233+1 records in
233+1 records out
244570112 bytes transferred in 2.275065 secs (107500277 bytes/sec)

問題是,我不打算將 ubuntu-rescue.img 移動到/dev/sdt. 哎呀!

我現在正在嘗試弄清楚原始內容/dev/sdt/是什麼(在我錯誤地將數據寫入該文件之前),以及是否有辦法檢查內容(刪除錯誤複製到那裡的磁碟映像,或者以某種方式將內容/dev/sdt恢復到其原始狀態)。

另外,這個dd命令會刪除之前的所有內容,還是只是向其中添加數據?

我現在的主要問題是我不知道是什麼/dev/sdt(它是文件嗎?驅動程序?安裝的驅動器?等等),所以我無法知道如何檢查造成的損壞。因此,當我執行此命令時,我需要了解我在看什麼:

ls /dev

以及如何檢查/訪問/讀取這些文件的內容。

我該怎麼辦?


For some further analysis, here are various output from various commands:

Not a directory:

   $ cd /dev/sdt
   -bash: cd: /dev/sdt: Not a directory

"Special Character" file

   $ file /dev/sdt
   /dev/sdt: character special

Verbose ls output:

   $ ls -l /dev/sdt
   crw-rw-rw-  1 root  wheel    0,   0 Dec 28 14:02 /dev/sdt

"Size of" `/dev/sdt`

   $ du -sk /dev/sdt
   0    /dev/sdt

I ran the same commands from update #1 on a new Mac Mini (that didn't have its `/dev/sdt` drive tampered with `dd`, and it gave me the **exact same** output as I got on the the iMac after I ran the erroneous `dd` command. Does this mean that the /dev/sdt didn't "record" the contents of the dd transfer? Because the "size" of /dev/sdt displays as zero when I run `$ ls -l /dev/sdt`. Could it be that I got lucky and didn't do any permanent damage?

Both of these commands: `$ du -sk /dev/sdt` and `$ ls -l /dev/sdt` give me the same results on the iMac (where the erroneous `dd` command was run) as it did on the untouched Mac Mini, showing that the data stored in `/dev/sdt` reads at 0 bytes. This makes me assume that this drive is a temporary system drive that is not meant to store data, because even after 240 MB of data was erroneously `dd`'d into it, it still reads at zero byes.

Lastly, I was given a good idea (by user frostschutz) to run this command:

   dd if=/dev/sdt of=mystery bs=1M count=234

And compare the results of the "mystery" file with the contents of the ubuntu-resuce.img, and the output from that experimental `dd` left me with a file called "mystery" which was exactly zero bytes. So I am starting to feel confident that I didn't do any lasting damage, and that this drive is always empty.

After listening to your very helpful discussions, and reading more on an [another (separate, but closely-related) question of mine here on U&L][1], I discovered that my question has already been asked, so for anyone wanting to read more on this discussion, you can look [here][2].

 [1]: https://unix.stackexchange.com/questions/176304/why-does-the-unix-system-need-so-many-0-byte-drives-at-dev?noredirect=1#comment291323_176304
 [2]: https://unix.stackexchange.com/questions/18239/understanding-dev-and-its-subdirs-and-files

我驚訝地發現我的 Mac Book Air確實有一個*/dev/sdt字元特殊設備。由於我無法理解它的本質,我查閱了我的Mac OS X for Unix Geeks副本。在第 60 頁,有/dev中所有條目的列表。確實提到了sdt ,並給出了令人費解的解釋:*

sdt 無證

這是全書唯一提到的。

因此,首先它不是儲存設備。其次,你不太可能用它來做任何事情。同時,我看不出任何真正的擔心理由。

引用自:https://unix.stackexchange.com/questions/176281