DEV Community

Damrongsak Reetanon
Damrongsak Reetanon

Posted on

Show progress when Disk Dump (dd) in macOS

ปัญหาผมคือ ต้องเขียน ISO file ขนาด 1.6 GB ลงไปที่ USB Drive ก็ด้วยความเคยชินก็ใช้คำสั่ง dd sudo dd if=ovirt-node-ng-installer-4.4.4-2021020810.el8.iso of=/dev/disk2 ที่เคยใช้อยู่เป็นประจำ แต่ก็ไม่ได้คิดอะไรมาก ส่วนใหญ่ใช้เวลาไม่นานก็เสร็จเรียบร้อย แต่พอเจอในสถานการณ์นี้ USB Drive เก่ามากแล้ว รอนานนนนนนนนนน มากกกกกกกกก โดยที่ไม่รู้ว่า คำสั่ง dd กำลังทำงานอยู่ หรือว่าหยุดทำงานไปแล้ว
ในใจก็คิดว่า ต้องมีคนมีปัญหาอย่างเราสิ แล้วเค้าแก้ยังไง สุดท้ายก็เจอว่า คำสั่งได้ผลการทำงานเหมือนกัน ชื่อว่า gdd ที่เป็นชุด คำสั่งใน coreutils จาก GNU ก็เลยต้องติดตั้ง coreutils เพิ่มด้วย brew และ ใช้คำสั่ง gdd พร้อมกับ status=progress ก็จะเห็นว่า คำสั่ง gdd เขียนไฟล์ไปแล้วเท่าไหร่ คำสั่งทำงานไปแล้วกี่วินาที และเขียนไปที่ output ด้วยความเร็วเท่าไหร่

  1. ติดตั้ง coreutils ด้วยคำสั่ง brew
❯ brew install coreutils
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/services).
==> New Formulae

...

==> Downloading https://homebrew.bintray.com/bottles/coreutils-8.32.big_sur.bottle.2.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/371ec57703b3646e0113331308b6e03617c2a7f91e15e113380b605455daba20?response-content-disposition=attachment%3Bfilename%3D%22coreutils-8.32.big_sur.bottle.2.tar.gz%22&Policy=eyJTdGF
######################################################################## 100.0%
==> Pouring coreutils-8.32.big_sur.bottle.2.tar.gz
==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
  PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
==> Summary
🍺  /usr/local/Cellar/coreutils/8.32: 476 files, 12.5MB
Enter fullscreen mode Exit fullscreen mode
  1. ใช้คำสั่ง gdd อ่านไฟล์ ovirt-node-ng-installer-4.4.4-2021020810.el8.iso เพื่อเขียนไปที่ /dev/disk2 พร้อมทั้งแสดงสถานะขณะทำงาน
❯ sudo gdd if=ovirt-node-ng-installer-4.4.4-2021020810.el8.iso of=/dev/disk2 status=progress
458949120 bytes (459 MB, 438 MiB) copied, 235 s, 2.0 MB/s
Enter fullscreen mode Exit fullscreen mode
  1. หลังจากทำงานเสร็จเรียบร้อย ก็จะมีสรุปภาพรวมของการทำงาน
❯ sudo gdd if=ovirt-node-ng-installer-4.4.4-2021020810.el8.iso of=/dev/disk2 status=progress
1674600960 bytes (1.7 GB, 1.6 GiB) copied, 858 s, 2.0 MB/s
3274752+0 records in
3274752+0 records out
1676673024 bytes (1.7 GB, 1.6 GiB) copied, 858.97 s, 2.0 MB/s
Enter fullscreen mode Exit fullscreen mode

มูลค่าความสุข

Latest comments (0)