- Как я могу отслеживать прогресс dd
- 5 ответов
- How To Create Disk Image on Mac OS X With dd Command
- How To Create Disk Image on Mac OS X With dd Command
- 1. Create disk image with dd command
- 2. Unmount the disk
- 3. Create the disk image with dd
- How do I write dd images to disk again?
- Not a fan of command line?
- Etcher app
- Summing up
- Quick: dd with progress indication on macOS
- Dave Jansen
- Alternative method: gdd (works, but slower)
- Sign up for more like this.
- Manage docker without needing sudo on your Synology NAS
- Automatically schedule a photos re-index on your Synology NAS to add missing images
- Add custom resolution and refresh rate when using Wayland/Gnome
Как я могу отслеживать прогресс dd
Я использую следующую команду для создания загрузочной SD-карты
Есть ли способ отслеживать прогресс?
5 ответов
Такая же информация, отображаемая каждую секунду в ответе klanomath, может отображаться с использованием вашей команды. Вам просто нужно ввести символ T с клавиатуры, а dd команда выполняет.
Нажав символ control T , вы отправляете тот же SIGINFO к команде dd , что команда pkill -INFO -x dd отправляет.
dd сам не предоставляет индикатор выполнения. Вы можете оценить прогресс процесса копирования dd, добавив команду pkill -INFO , хотя.
Что переводится в колоссальные 18,1 ГБ /с.
Прежде всего, установите Менеджер пакетов Homebrew . Затем вам нужно установить pv и dialog с помощью этой команды:
Затем вы можете запустить эту команду, чтобы получить индикатор выполнения с помощью команды:
, но обязательно замените disk.img на путь к изображению и diskX с идентификатором диска вашей SD-карты. Если вы хотите что-то более графическое, вы можете попробовать следующее:
Это легко! Для macOS High Sierra и ниже просто запустите цикл while, и он будет работать до тех пор, пока он не будет завершен. Просто сделайте код ниже в другом окне:
Приведенный ниже код будет работать в ящике при загрузке прошивки или в полнофункциональной ОС
while kill -0 $PID; do $(caffeinate -t 10) $(kill — INFO $PID) echo “still copying file” “$(date)”; done
^ Чтобы машина не просыпалась (кофеин) без использования «доморощенного» или инструментов, недоступных в стандартной Mac OS X, поскольку для доморощенного требуется интернет и фактическая ОС для его установки.
ПРИМЕЧАНИЕ. Вышеупомянутое требует, чтобы вы заменили PID идентификатором процесса, и он будет постоянно показывать прогресс
Вы можете нажать Control + t , пока выполняется команда dd или для хорошего индикатора выполнения вы можете установить pv (просмотрщик каналов) через Homebrew:
, а затем выполните:
или (знающий размер изображения, 16 ГБ в этом примере):
Пример вывода 2:
(переданные данные, прошедшее время, скорость, индикатор выполнения и расчетное время):
Источник
How To Create Disk Image on Mac OS X With dd Command
- Create new disk images from USB or SD card
- Write images to disk or USB or SD card
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | macOS or older OS X |
Est. reading time | 2m |
You also need to use diskutil command manipulates the structure of local disks including listing and unmouting disks before you create or write images to disk.
WARNING: Please be careful when running the following commands, as you might destroy essential data or disk. Always keep verified backups for your Mac.
How To Create Disk Image on Mac OS X With dd Command
The procedure is as follows:
- Open the Terminal app
- Get disk list with the diskutil list
- To create the disk image: dd if=/dev/DISK of=image.dd bs=512
- To write the disk image: dd if=image.dd of=/dev/DISK
Let us see all commands in details.
1. Create disk image with dd command
Open the Terminal application and type the following command to list disks:
$ diskutil list
Fig.01: Insert in your SD card, or USB pen/HDD, and see /dev/diskN name
2. Unmount the disk
Unmount the disk called /dev/disk2:
$ diskutil unmountDisk /dev/disk2
Here is what we see:
3. Create the disk image with dd
Finally create the disk image of the entire disk /dev/disk2:
$ sudo dd if=/dev/disk2 of=backup.my.sdcard-18-oct-2015.img.dd bs=512
OR
$ sudo dd if=/dev/disk2 of=backup.my.sdcard-18-oct-2015.img.dd bs=1m
OR
$ sudo dd if=/dev/disk2 of=foo.bar.img.dd bs=64k
It will take some time, and you won’t see any updates on the screen. You can press the ctrl + t (hold control key and press t ) to see dd command progress on macOS:
You can create compressed disk image as follows:
$ sudo dd if=/dev/disk2 bs=64K | gzip -c > backup.disk.img.dd.gz
Where,
- dd : Command name
- if=/dev/disk2 : Input disk name
- of=backup.my.sdcard-18-oct-2015.img.dd : Output image name
- bs=64k or bs=1m or bs=512 : Set both input and output block size to n bytes.
- gzip -c > backup.disk.img.dd.gz : Create compressed disk image using gzip
You can verify your disk with file command:
$ file disk-name-here.img.dd
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
How do I write dd images to disk again?
The syntax is as follows:
$ diskutil list
$ diskutil unmountDisk /dev/disk2
$ sudo dd if=backup.my.sdcard-18-oct-2015.img.dd of=/dev/disk2
### Restores compressed image and write /dev/disk2 ###
$ sudo sh -c ‘gunzip -c backup.disk.img.dd.gz | dd of=/dev/disk2’
See dd command man page for more info.
Not a fan of command line?
You can use ‘Disk Utility’ GUI tool to create and restore images. First ‘Open Disk Utility’ by visiting the Applications > Utilities folder:
Fig. 02: Disk utility in action
Choose File > New > Image from «Untitled». Next, enter a name for the disk image, then choose where to save it:
Fig.03: Saving SD card image
Etcher app
Etcher is an SD card flasher app that is simple for end users, extensible for developers, and works on any platform including macOS. However, it is written in JS, HTML, node.js and Electron. So if you want to download external and fat app go here. Personally, I recommend and use the CLI or inbuilt apps.
Summing up
You leaned how create disk image on Mac OS using the dd command and GUI apps.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
This is great. But in you GUI example, you left out how to write the image to say a flash drive. My problem is simple. How do I copy a Bootable MaxOSX flash drive to another MacOSX flash drive and it remain bootable. Can that be done in the GUI?
Exactly, I need to copy a Mac Disk Image on a hard drive to a flash drive. With the “restore disk image” function completely omitted or hidden in the new and (ahem) “improved” disk utility, I am completely dead in the water with a Mac I am unable to resurrect. I found this article unhelpful and incomplete. Does ANYBODY out there know how to fashion a quick tutorial to accomplish this and be both thorough and comprehensive UNLIKE this article? Please? Anyone?
Try out ApplePi-Baker
Its a simple GUI based tool to create / flash images of disks and works with pretty much all file systems etc and its so easy to use!
Thanks for this tip! 😀
Howdy. I just ran this command: sudo dd if=/dev/disk5 of=/dev/disk1 bs=131072
It asked me for my password and I entered it and then the cursor moved down to the next line and stayed there.
Does that sound right? Is it frozen or just working? Is there no progress indicator?
Thanks!
C
That’s correct, there is no progress indicator. If you really want you can quiz the process it runs in, in a seperate terminal but there really is no need.
Just leave it go, it can take a while depending the same of the image you are moving.
Is there a way to create the image to only use the “used” part of the disk you are copying? I have a 126 gig sd card that I want to flash to another card but the used area is very small. To restore the 126 gig image looks like it will take another 38 hours.
If you use the “dd” command with rdisk instead of disk, the cloning will be 20x faster.
e.g.:
dd if=/dev/disk2 -> dd if=/dev/rdisk2
dd of=/dev/disk2 -> dd of=/dev/rdisk2
My External HDD restored from spindle problem, now shows larger volume. The actual size is 1.5Tb it is showing 4.1Tb. It doesn’t mount automatically, shows in disk utility. Can’t erase or repair or format using disk utility gives “Cannot allocate memory” or “Resource busy” error.
Tried all of the above dd commands, gives “Resource busy” error when used the command with gzip, otherwise gives “/dev/destination drive/foo.img: Not a directory” error. The unmount using dd was successful.
Most ‘free’ or open source disc recovery softwares have no luck recovering or properly scanning this disk.
Does anyone got any idea what could be the problem?
My bad, it is showing as 4.1Gb not 4.1Tb.
Hi
$ sudo dd if=/dev/disk2 of=foo.bar.img.dd bs=64k
I have always seen if=iso file and of=target disk. why in your example this is other way ? i’m confused. Have i missed something ?
Hi there,
I didn’t get where to write the destination for the dd to be created ?
With a mac myou need to indentify and unmount the disk before you use dd
use terminal on a mac
sudo diskutil list
Now unmount the disk
sudo diskutil umountdisk /dev/disk2
Then you can write the image the best is to an rdisk device:
sudo dd if=raveos.img of=/dev/rdisk2
After a while the USB disk in ready to use.
Thank you for this it worked well.
was having trouble doing it on a Linux system
Openbsd works Great but didn’t have it installed,
so decided to try it on my Trusted Mac!
Источник
Quick: dd with progress indication on macOS
Dave Jansen
While newer versions of dd on Ubuntu or the like come with a new option called status=progress , the one included with macOS sadly does not.
A nice way I found to get progress indication whilst still being able to benefit from the huge speed increase in using /dev/rdiskX is to install a tool called pv , also known as Pipe Viewer.
Now, split up your dd command into two, and pipe everything through pv. If you know the size of the input drive, provide that to pv as-well as it will further improve the output. Take this example, where my input drive is 64GB:
This will result in a familiar looking progress indicator, as-well as an ETA and transfer speeds.
This method also works very well when zeroing out drives, something I had to do quite a lot recently as I was preparing to sell off some older drives. Using the following command for a 500GB drive, for example, worked great:
It’s quite useful to finally have some insight into how far along a task like this is, as it’s usually quite a time consuming one.
Alternative method: gdd (works, but slower)
Another way to achieve something similar would be to use brew to install coreutils , which will come with a newer version of dd that supports the status option.
All tools installed with this package are named with g prefixed to them, so you can run gdd to use this packages’ version of dd.
Sadly, this version of dd lacks support for macOS’ «raw» disk support ( /dev/rdiskX ), which means it will be significantly slower to copy a disk over, but there might be certain scenarios where this method is preferred.
I hope this helps!
Sign up for more like this.
Manage docker without needing sudo on your Synology NAS
If you’ve installed and used docker before, you’re probably familiar with adding your computer’s user account to the docker user group to allow you to control docker (and docker-compose) without needing to use sudo. For production setups it might be beneficial to maintain that level of security, but for a
Automatically schedule a photos re-index on your Synology NAS to add missing images
If you’ve been having trouble getting Synology Photos to more consistently show newly added images and videos, this might be of use to you.
Add custom resolution and refresh rate when using Wayland/Gnome
Monitors and/or adapters don’t always return all the supported resolutions and refresh rates to your computer. In those cases you may need to do some finagling to get the right configuration to work. On Windows you can usually rely on your graphics card’s accompanying software to offer such functionality,
Источник