diskutil list
, showed the following:$ diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *500.3 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 499.4 GB disk0s2 3: Apple_Boot Recovery HD 650.0 MB disk0s3 /dev/disk2 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *13.8 MB disk2 1: Apple_HFS C_PGP2FV_B_A0 13.8 MB disk2s1 /dev/disk3 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *500.1 GB disk3 1: EFI EFI 209.7 MB disk3s1 2: Apple_HFS TOSHIBA EXT 499.8 GB disk3s2 3: Apple_Boot Boot OS X 134.2 MB disk3s3 $
Both the internal and external disk drives are 500 GB drives. I would
expect the internal disk drive to be disk0 and the external one to have
a higher disk number, e.g., disk3 in this case, and I can tell that is the
case from "Apple_HFS TOSHIBA EXT" in the output. I can also confirm that
with a diskutil info /dev/disk3
command, which shows that
disk3 is, indeed, the Toshiba external USB drive.
$ diskutil info /dev/disk3 Device Identifier: disk3 Device Node: /dev/disk3 Part of Whole: disk3 Device / Media Name: TOSHIBA External USB 3.0 Media Volume Name: Not applicable (no file system) Mounted: Not applicable (no file system) File System: None Content (IOContent): GUID_partition_scheme OS Can Be Installed: No Media Type: Generic Protocol: USB SMART Status: Not Supported Total Size: 500.1 GB (500107862016 Bytes) (exactly 976773168 512-Byte-Units) Volume Free Space: Not applicable (no file system) Device Block Size: 512 Bytes Read-Only Media: No Read-Only Volume: Not applicable (no file system) Ejectable: Yes Whole: Yes Internal: No OS 9 Drivers: No Low Level Format: Not supported $
Following the instructions provided at Restore a full-disk .dmg file to a raw block device, I mounted the Apple Disk Image .dmg file as a block device with the following hdid command.
$ hdid -nomount "/Users/Shared/TOSHIBA EXT.dmg" /dev/disk4
I could see from the output of the command that the TOSHIBA EXT.dmg
file was designated as /dev/disk4
and I could also see
it had that designation from a diskutil list
command.
$ diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *500.3 GB disk0 1: EFI EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 499.4 GB disk0s2 3: Apple_Boot Recovery HD 650.0 MB disk0s3 /dev/disk2 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *13.8 MB disk2 1: Apple_HFS C_PGP2FV_B_A0 13.8 MB disk2s1 /dev/disk3 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *500.1 GB disk3 1: EFI EFI 209.7 MB disk3s1 2: Apple_HFS TOSHIBA EXT 499.8 GB disk3s2 3: Apple_Boot Boot OS X 134.2 MB disk3s3 /dev/disk4 #: TYPE NAME SIZE IDENTIFIER 0: TOSHIBA EXT *500.0 GB disk4
I then tried restoring the disk drive's
partitions and contents using the
dd command
dd if=/dev/disk4 of=/dev/disk3 bs=131072
; the if
parameter indicates the input device and the of
parameter the
output device. I set the block size to be 131072 as in the example. I received
a "permission denied" message initially, which led me to realize that I needed
to use the sudo command to run the command
with elevated privileges. However, then I received a message
indicating the account I was logged into wasn't in the sudoers file.
$ dd if=/dev/disk4 of=/dev/disk3 bs=131072 dd: /dev/disk3: Permission denied $ sudo dd if=/dev/disk4 of=/dev/disk3 bs=131072 Password: jasmith1 is not in the sudoers file. This incident will be reported.
I dealt with that issue by clicking on Users & Groups under
System Preferences, which is accessible by clicking on the Apple icon
at the top left-hand corner of the screen, then selecting the account from
the account list by clicking on it and then checking the box for "Allow user
to administer the computer", which resulted in a window appearing
stating "For this change to take effect, you must restart the computer."
However, I was then able to run the dd
command without rebooting
the system, though when I next attempted to do so, I received a "Resource busy"
message.
$ sudo dd if=/dev/disk4 of=/dev/disk3 bs=131072 Password: dd: /dev/disk3: Resource busy
In the OS X Finder application, I clicked on the eject icon next to the drive under Devices to dismount the external USB drive. I was then able to successfully run the command and restore the drive from the disk image I had created previously.
$ sudo dd if=/dev/disk4 of=/dev/disk3 bs=131072 Password: 3814692+1 records in 3814692+1 records out 499999343104 bytes transferred in 19392.505352 secs (25783123 bytes/sec) $
Restoring the data to the drive took over 5 1/2 hours. The transfer
rate was about 197 Mbs (25783123 bytes/sec). At the conclusion of the
restoration, I disconnected the USB cable from the drive to the laptop
and then reconnected it. I was then able to see all of the original files on
the system. And a diskutil info /dev/disk3
command showed the
drive was now formatted with an NTFS partion as it had been when I purchased
it rather than Apple's
Hierachical File System (HFS) file system as it was prior to the
start of the restore operation with dd.
$ diskutil info /dev/disk3 Device Identifier: disk3 Device Node: /dev/disk3 Part of Whole: disk3 Device / Media Name: TOSHIBA External USB 3.0 Media Volume Name: TOSHIBA EXT Mounted: Yes Mount Point: /Volumes/TOSHIBA EXT File System Personality: NTFS Type (Bundle): ntfs Name (User Visible): Windows NT File System (NTFS) Content (IOContent): None OS Can Be Installed: No Media Type: Generic Protocol: USB SMART Status: Not Supported Total Size: 500.1 GB (500107862016 Bytes) (exactly 976773168 512-Byte-Units) Volume Free Space: 499.7 GB (499712028672 Bytes) (exactly 976000056 512-Byte-Units) Device Block Size: 512 Bytes Allocation Block Size: 4096 Bytes Read-Only Media: No Read-Only Volume: Yes Ejectable: Yes Whole: Yes Internal: No OS 9 Drivers: No Low Level Format: Not supported $
References: