Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Cloning Partitions via Terminal

Cloning Partitions via Terminal
Thread Tools
Dex13
Mac Elite
Join Date: Dec 2002
Location: Bay Area of San Jose
Status: Offline
Reply With Quote
Aug 22, 2013, 06:00 PM
 
Hello All!

I've been mucking about with asr, diskutil, and dd but I haven't been able to solve this question that I have.

Lets say we have this:
//
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0:GUID_partition_scheme *751.3 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 750.4 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
//

I figured out how to clone the normal boot volume (via .dmg), but how could I directly clone disk0s3 onto disk1s3? Is this even possible?

Note: I understand I can do this all with dd, BUT it takes forever and ever.
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Aug 22, 2013, 06:39 PM
 
If you do it with dd you'll also have problems if the partitions are a different size. You should be able to grow the partition later, but shrinking it is a no-go.

It doesn't look like the CLI diskutil supports the restore command found in the Disk Utility GUI. Does this need to be a command line solution?
     
mduell
Posting Junkie
Join Date: Oct 2005
Location: Houston, TX
Status: Offline
Reply With Quote
Aug 22, 2013, 07:52 PM
 
Try adding a reasonable blocksize to your dd:

dd if=/dev/disk0s3 of=/dev/disk1s3 bs=1M
     
Dex13  (op)
Mac Elite
Join Date: Dec 2002
Location: Bay Area of San Jose
Status: Offline
Reply With Quote
Aug 22, 2013, 10:10 PM
 
thanks besson and mduell

I used $ asr restore -source /dev/disk0s2 -target /dev/disk1s2 -erase -verbose

and for some reason it added the recovery hd as well (if its obvious to someone else why this happened, you clearly understand how much of a novice I am)

However, if you have lets say (bootcamp):
Type: Microsoft Basic Data
Name: Name of Bootcamp Partition
Size: GBs on GBs
IDENT: disk0s4

How could I:
find the exact size of disk0s4 and could i then use asr to restore it on disk1s4 if its the same size partition?

Also, even if I could speed up dd, is there a way for it to ignore writing blank/unused space onto the target drive?

I'm just trying to learn unix.
( Last edited by Dex13; Aug 23, 2013 at 04:25 PM. )
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 10:35 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,