What is ApplePi-Baker? (optional)
This chapter gives you a background on certain aspects of ApplePi-Baker, which may or may not be an interesting read.
You can skip this chapter if you’re not all that interested in these details and go straight to “Installing ApplePi-Baker“.
ApplePi-Baker is a small macOS utility that allows you to backup or restore disks.
At its core, it uses the same format as produced by “dd“, a raw byte-by-byte copy of the disk – typically with the “.IMG” file extension.
As I mentioned; IMG file format is a raw copy of every single byte of the source disk, and nothing fancy is being done with it.
This also means that if your disk is 32Gb, even though you may be using only 1 byte, your backup file will still be 32Gb!
Note : For backup and restore, ApplePi-Baker only supports non–system disks.
You cannot make a backup of your macOS system disk.
Note : ApplePi-Baker does not shrink (or expand) partitions.
Since macOS, oddly enough, does not natively support any of the Linux Extended File Systems (ext), we do not have the means to easily determine what part of the disk actually is useful and what part is not. Several methods can be found to shrink the IMG file, but none of them can be used with macOS.
Note : Some folks use the “.DD” extension instead of the “.IMG” extension.
The file format is the same though (not to be confused with the old “DiskDoubler” file format).
Archiving and Compression with ApplePi-Baker
Typically, the IMG file format is very well compressible.
Commonly the “.zip” and “.tar.gz” (or “.tgz”) compression methods are being used on the resulting IMG file to reduce the needed storage space for the backup. I should mention that the format “.tar.xz” (or: “.txz”) is gaining popularity.
Maybe I should explain the difference between archiving and compressing (I had to learn this myself as well) …
An Archive is basically the bundling of a collection of files, which could be just one file as well – there is no compression involved.
Compression on the other hand, is the technique to store data in a smaller size than the original data, but does not involve building an archive – it just grabs one single file (chunk of data) and tries to store it in a smaller file.
Formats like 7Zip, Zip and Rar combine the creation of an Archive, and after that the Compression of that archive.
Formats like BZip2, GZip, LZip, and XZ, are good compression methods, but do not create an archive.
With these compression methods, one typically uses “Tar” to create an archive first before compressing said archive.
ApplePi-Baker Supported Formats
ApplePi-Baker support quite a range of file formats, in part due to libarchive that is being used.
Basically, anything libarchive can read or write, ApplePi-Baker can as well.
In ApplePi-Baker however, I have limited the formats used for creating a backup intentionally, to avoid odd-ball formats that are not supported by other tools or could be used in an incorrect way (like using GZip without TAR).
Formats supported for making a Backup
ApplePi-Baker supports the following formats (selected in the Save dialog when creating a backup). The extension is based on the commonly used extension for the selected format;
- 7Zip (extension: .7z)
- IMG (extension: .img)
- Tar BZip2 (extension: .tbz)
- Tar GZip (extension: .tgz)
- Tar LZip (extension: .tlz)
- Tar XZ (extension: .txz)
- Zip (extension: .zip)
Formats supported for doing a Restore
There is quite a variation out there when it comes to file formats for backups. I’ve tried to capture them all, even ones that are not commonly used. Feel free to post a comment below if a format is missing, and I will see what I can do to add this odd format.
- 7Zip (extension: .7z, .7zip)
- BZip (extension: .bz,. bz2, .bzip) *1
- GZip (extension: .gz, .gzip) *1
- IMG (extension: .img, .dd, .raw, .dump)
- ISO (extension: .iso) *2
- Jar (extension: .jar)
- LZip (extension: .lzip) *1
- Rar (extension: .rar) *3
- Tar (extension: .tar)
- Tar BZip2 (extension: .tbz, .tbz2, .tar.bz, .tar.bzip, .tar.bz2, .tar.bzip2)
- Tar GZip (extension: .tgz, .tar.gz, .tar.gzip)
- Tar LZip (extension: .tlz, .tar.lzip, .tar.lz)
- Tar XZ (extension .txz, .tar.xz)
- XZ (extension: .xz) *1
- Zip (extension: .zip)
*1 : These files were not created entirely correct, as they are compressed, but not archived (tar).
*2 : Be careful with ISO files, you may end up with unexpected results – see below.
*3 : Only Rar < v5 are supported (a libarchive limitation).
Some notes on File Formats
Always use TAR when using BZip2, GZip, Lzip or XZ.
(ApplePi-Baker uses TAR automatically)
One can use these compression techniques without using TAR, however, the size of the file will often not be stored in the compressed file as such. To determine what the uncompressed size will be, one often must fully decompress the file first, just to see “what came out”.
Since ApplePi-Baker (and the user) would like to know if the uncompressed data fits on their target disk, decompressing the file first would take extra time.
However; ApplePi-Baker does support files that were created without using TAR. Mostly because I made the same mistake in the past as well. But be prepared to wait a little longer when restoring a file to a disk.
Potential unexpected results with ISO files.
(Can only be used with Restore)
ApplePi-Baker basically handles almost (!) any file format you throw at it for a restore.
This implies that you can even use a so called ISO file to do a restore.
Be warned though, that ApplePi-Baker was not designed to write ISO files to (for example) a USB disk, but libarchive does support it.
By lack of testing material, I can only say: this may or may not work as expected. Please post findings in the comment section!
About Mount, Unmount and Eject
A few things you may need to know involve mounting, unmounting and ejecting disks.
Under macOS, your disk/partition can be in one of several different “states“;
- Mounted means that a disk or partition is “ready to use and visible to the end user”.
- Unmounted means that the system knows the disk or partition exists.
The end-user however, cannot see or use the partition from the Finder (but can see it in “Disk Utility”).
- Ejected a disk involves the process of physically removing a disk.
Back in the CD/DVD days, this actually meant opening the disk tray, so the user could grab the CD or DVD. Today, for example, this means that the user can unplug a USB drive. Once a disk is”ejected”, the user and the system can no longer access the disk.
Inserting a Disk
When the user inserts a drive, a CD/DVD/BluRay, plugs in an SD-Card, or a USB stick, the system will examine the disk and will try to automatically “mount” it so the user can access the disk right away.
Obviously, this mounting can fail, and a message may state that the disk needs to be initialized – common when you have an unsupported file system, like the Linux Extended File System (not uncommon for Raspberry Pi users), on that particular disk.
Disk Change notifications
macOS has a very nice, even though complicated at times, mechanism to report one of these events to your application.
Back in the day, you’d just check and see what changed every so many seconds -adding sometimes quite a workload to your computer.
But with Apple’s Disk Arbitration, this is no longer needed, and ApplePi-Baker fully uses these capabilities, minimizing the load on your computer’s resources. You’ll notice that ApplePi-Baker picks up on disk changes pretty fast.
Note : With “writing to disk” I actually mean the process of completely erasing and overwriting an entire disk as done during a restore.
The old way: Direct or as SUDO
Back in the day, your application could just write to a disk as it pleased. Obviously a tiny bit of a security problem – malicious applications or scripts would be able to destroy anything it felt like on your disk.
To minimize the chance that this would happen, so called “sudo access” (admin access) became needed to write in such a way to your disks. In the old (1.x) version of ApplePi-Baker this was still done. The command-line tools (like “dd”) were called with sudo access rights.
This came with a lot of issues and inconveniences.
Each time you started ApplePi-Baker, you would have to enter you sudo password.
Other tools still do this, either at the beginning or when executing the write task.
Apple improved its security by going a different route – the so called “Privileged Helper Tool“.
This Helper Tool is a small program, designed for one single and very specific task, and is started by launchd to execute this task when the “main” application asks it to execute for that specific task (writing to disk).
See my article on SMJobBless: Elevated Privileges in Lazarus Pascal for more technical details, if you’re interested.
However … to keep things secure, this small program will need to meet several criteria that must be met before it can even be used.
Before we can use a Helper Tool, the “main” application needs to have defined that this Helper Tool exists and what criteria need to be met (for example: the Helper tool needs to be signed by a particular developer – that would be me).
The Helper Tool needs to have defined what application(s) are allowed to call for it (with similar criteria).
After that, both applications need to be signed – theoretically, the user, or malicious software, can no longer changes this.
By the way; The signed result of the Helper tool is after that, no longer a simple executable file – only “launchd” can start the Helper tool!
Before the main application can use this Helper tool, the Helper tool needs to be installed (in
/Library/PrivilegedHelperTools/ ) and only “launchd” can do this. For this the user needs to explicitly give permission. So without the “OK” of the user, the Helper Tool will NOT be installed (and ApplePi-Baker will NOT work).
Once installed, the user will no longer need to provide a password to use the Helper Tool.
Note : ApplePi-Baker will install the Helper Tool at first run, or after you updated ApplePi-Baker to a version of ApplePi-Baker, that came with a newer version of the Helper Tool. So at first run only, you will see the message that ApplePi-Baker wants to install a Helper Tool, for which you will need to give permission.
Shrinking and Expanding Linux Partitions
As of version 2.1.0, I’ve included a mechanism to shrink or expand IMG files.
Better said: shrink or expand Linux Ext2, Ext3 or Ext4 partitions on disks that use MBR (Master Boot record) – which is very common for Raspberry Pi images.
There are a few reasons why I implemented this.
The first reason is that SD-cards are notoriously inconsistent when it comes to capacity. Even from the same brand, and the same model, can differ in size – obviously a problem when trying to restore an IMG to an SD card that is a few bytes off compared to the original.
The second reason is being able to restore to smaller or bigger SD-cards or disks.
Making a backup of a 16Gb SD card is nice, but pretty useless if you cannot restore it to a 8Gb SD-card.
Obviously this would only work if the actually used data on the original SD-card does does not exceed the capacity of the target SD-card or disk.
So this is not a generic trick that will magically turn 16Gb into 8Gb.
However, it happens quite often that of the 16Gb only a part is used, and if that part doesn’t exceed the 8Gb, then we could restore it on a 8Gb card.
Third reason would be space to store or transport backups.
Note: Using this option WILL slow down backup or restore, since multiple steps have to be taken.
Note: During backup the original disk will NOT be affected by this.
It is important to know that this only works when these criteria are met;
– The SD-card or disk has been initialized with MBR
– The partition is a Linux partition ($83)
– The partition has a Ext2, Ext3 or Ext4 filesystem
Shrink IMG Process
During a backup, if you enabled this option, ApplePi-Baker will first make a full backup to an IMG file.
Once completed, it will extract the Linux partition, check it’s file system integrity, and resize that partition to its minimum.
After resizing, the partition tables (in the IMG file) will be updated to reflect the size change as well.
After that everything will be glued back together, resulting potentially in a much smaller IMG file.
If you enabled compressing, the result will be compressed after that.
Expand IMG process
This step is thought to use the maximum available space on a disk or SD-card.
As with the shrinking process, the Linux partition will be extracted from the IMG file.
In case the original was compressed, it will need to be decompressed first – ApplePi-Baker will handle that automatically for you.
After that the partition will be resized, so the entire IMG will use as much space as possible of the target disk or SD-card.
Naturally, the partition table will be updated as well, to match the change.
Before we can get started, we obviously will need to download an install ApplePi-Baker.
After downloading the DMG file, simply double click the DMG file, and drag “ApplePi-Baker” to your “Applications” folder.
I have created a shortcut to the download for those wanting to use this in formulas (like brew etc) or link from their website.
– The direct download link to the latest version will always be https://www.tweaking4all.com/ApplePi-Baker2.dmg
– And a shorter link to this article: https://www.tweaking4all.com/ApplePi-Baker
Please like ApplePi-Baker at Alternative.to …
DOWNLOAD - ApplePi-Baker V2
|Platform: ||Mac OS X|
|Size: ||3.8 MiB|
|Date: ||August 25, 2019|
| Download Now |
First Run of ApplePi-Baker
The first time you start ApplePi-Baker (recommended to run ApplePi-Baker from you “Applications” folder!), it will display a message, asking you to install the Helper Tool.
ApplePi-Baker – Install Helper Tool
The Helper tool will be installed, by launchd, in
The purposes of the Helper Tool is to read or write a disk directly (where in the past the so called “sudo” password was needed).
After installation, you will not need your admin password anymore, not even when in the future when you start ApplePi-Baker again. Your password by the way is not stored anywhere. This request is fully handled by macOS and ApplePi-Baker has nothing to do with it.
The only time a password will be asked is to install or update the Helper Tool.
Installation of the Helper Tool takes place when it is missing or when it needs to update an existing Helper Tool.
With the arrival of official “Dark Theme” support in macOS 10.1 (mojave), we can now use this for ApplePi-Baker as well.
Support for macOS older than Mojave may vary – if possible I do recommend upgrading to the latest macOS version anyway, but I do realize that not all Macs are supported with the latest and greatest macOS.
By default, ApplePi-Baker uses the Theme set by the system (Use System Theme).
You can however force ApplePi-Baker to use the classic Light Theme (Aqua) or the newer Dark Theme.
The setting for this can be found in the ApplePi-Baker menu.
ApplePi-Baker – Theme Settings
ApplePi-Baker – Light vs Dark Theme
I’ll be the first one to say that I want to keep my Mac as clean as possible, and not every program is constantly needed or even the way you’d wanted the program to be. So here the details on Installing/Removing ApplePi-Baker;
- Drag ‘ApplePi-Baker” from “Applications” to the Trash, and empty the Trash after that.
- Delete the Preferences directory
- And finally delete the Helper Tool in Finder (or Terminal):
In this chapter, I’ll go through of the basic tasks one would go through creating a backup or doing a restore.
The next chapter will show some of the additional functions you can find in ApplePi-Baker.
One thing to keep in mind; the window has been divided in 3 vertical parts; Select Disk, Backup and Restore.
The general idea is:
- Select a Disk
- Choose an Action (backup or restore)
- Based on the chosen action; select a file
- Wait for completion of the task at hand
Step 1A – Select a Disk
Click in the leftmost column on the “Select a disk” text or the hard drive icon.
A popup menu will appear, listing the available supported disks.
If no disks are listed, then there are no suitable drives for backup or restore found.
Remember: the system disk(s) are NOT supported.
ApplePi-Baker -Select a Disk
After a disk has been selected, the selected disk will be listed under the icon, like show below in figure 5.
The red little “x” can be used to remove the selected disk.
Selected Disk listed
Step 1B – Selecting Multiple Disks (Restore Only!)
Since ApplePi-Baker now supports writing to multiple disk – for Restore Only – you can click on the disk icon again and add more disks.
When using multiple disks, disks will be written to in sequence, kind-a like so:
– Read a block from the source, write that block to disk 1, write that block to disk 2,
– Again, read a block from the source, write that block to disk 1, write that block to disk 2,
– And again, read another new block from the source, write that block to disk 1, write that block to disk 2,
– You can add a disk only once of course,…
– The selected disks will be listed in alphabetical order, not matter in what order you added them.
Selected Multiple Disks
Step 2 – Backup or Restore
In this next step, you can select what you’d like to do: Make a Backup, or Do a Restore.
Again: click on the icon of the action you’re looking for.
– When selecting a “Read-Only” disk, then you can only make a Backup – the “Restore” option will remain grayed out.
– If you selected more than one disk, then you can only do a Restore – the “Backup” option will be grayed out.
– Naturally, if you did both (read-only and multiple disks), then neither Backup or Restore will be available.
Not all SD-card readers seem to honor the “Read-Only” lock found on older SD cards.
In that case, your Mac will see it as a device it can write to – and actually WILL write to in case you selected a restore!
Based on your selection, a file dialog will open.
Backup: Here you determine where to store the file and in what format (selector at the bottom, center).
Restore: Here you can select the file you’d like to use for Restore. The format requirements will be detected automatically. Incase an archive has multiple files, you will be presented a dialog allowing you to select the file (in the Archive) that you wish to use.
For TBZ, TGZ, TLZ and TXZ files, by default “Find First File in Archive” mode is enabled. This means that ApplePi-Baker will grab the first file it finds.
This makes using these files a lot faster, but can be problematic when an archive contains more than one file. See “Enable Full Archive Seek Mode” for more details.
Step 3 – Coffee and a cookie
In this step you’ll just have to wait for the task to complete.
ApplePi-Baker also shows a percentage indicator on it’s Dock icon, and when the process has been completed (and ApplePi-Baker does not have focus) the dock icon will bounce (as expected with regular macOS applications).
Dock Icon show Progress
Note: If you enabled Resizing the Linux Partitions, several other steps will follow (and shown).
In the ApplePi-Baker window, a few estimates will be displayed as well:
- Average speed, which of course can change over time, but compared to the older ApplePi-Baker I have seen matching or better speeds.
- Estimated completion time, which indicates at what time ApplePi-Baker expects to finish the job.
- Time Left, which tells you how many hours, minutes, and/or seconds the process still will take.
The big “ Abort” button, well … it’s there just for decoration. Haha, just kidding. Obviously it’s there to abort a job.
Easy to read Progress
Additional Functions and Options
Obviously, since this is a little bit of a hobby project, things went a little out of control, and while exploring things, I have added some functions I’d figured to be useful.
At the bottom of the window, you will see a few icons. “Functions” on the left and “Options” on the right.
ApplePi-Baker Functions and Options
||Advanced Disk Panel
Reveals more details about the disks connected to your Mac and offers additional disk functions, like mount, unmount, create NOOBs, etc. – more about this below.
||Go to Tweaking4All.com
This icon opens this particular page – in case you need help.
Here you’ll find version information and credits.
Opens a small log window below ApplePi-Baker with messages. Personally I prefer this over notifications, and I can see what happened while i was not paying attention.
||Resize Linux Partitions
When enabled during backup, the Linux partition in the backup will be resized to its minimum size.
When enabled during restore, the Linux partition will be expanded to utilize all available disk space.
||Enable Full Archive Seek Mode
This is specific for Tar BZip, Tar GZip, Tar LZip and Tar XZ archives, and affects only these formats. See explanation below.
When enabled, your disk(s) will be ejected after Restore completion.
(where Eject = Unmount all partitions and Eject disk)
This tries to enable SSH on Raspberry Pi images, by saving a file “ssh” on the first mounted partition. This effectively enables SSH, ideal for a headless Raspberry Pi setup.
Note : your Raspberry Pi images has to support this for this to actually enable SSH.
When enable, notifications will be displayed in the macOS notifications. Quite annoying actually.
Shrink or Expand IMG
During backup: This will shrink a Linux partition in an IMG file, if found, to its bare minimum, so a restore can be done at a later time to a target disk or SD-card of a different size (target disk or SD-card should be the same size or bigger than the resulting IMG file size).
During restore: The Linux partition will be resized on the target disk or SD-card, so that the IMG will use all available space.
Note that this option will take a bunch of extra steps and will slow down the backup or restore process.
Enable Full Archive Seek Mode
This is ONLY for Tar BZip, Tar GZip, Tar LZip and Tar XZ archives, and affects only these formats!
For TBZ, TGZ, TLZ and TXZ files, Apple-Pi Baker will have to seek through the entire archive to find all entries, which can be slow process.
Since the first entry is found instantly, and since these archives typically have only on file entry, ApplePi-Baker by default grabs the first file entry it finds.
Under normal circumstances this should not be a problem.
However, if the archive contains more than one file entry, this can become a problem.
Say the IMG author added a “readme.txt” file, the ApplePi-Baker could by mistake take that file, resulting in a failed restore.
If you have an archive in this format, holding more than one file entry, then you may want to enable the “Full Archive Seek” mode.
Apple-Pi-baker will then find all file entries and if more than one file was found, a list will be presented to select from.
If you’re keen on checking what is going on when ApplePi-Baker is running, or we need more information when things aren’t going all that well, then the Log Window can become in handy.
You can toggle the visibility, by clicking the “Show Log-Window” button.
Right clicking the log, offers a few options:
- Copy Log to Clipboard (so you can easily post or email the log)
- Save Log to File
- Clear the log
Advanced Disk Panel
The original intent of ApplePi-Baker was to keep things simple for the user.
However,… after all these years I have seen enough users doing exotic things with my applications (which is awesome by the way!), and have seen the need for more information when troubleshooting. All this made me add this Advanced Disk Panel, and the more information I found, the more I kept adding. Remember – this is a hobby for me and it’s just fun to find all this kind of information.
Advanced Disk Information
In the Advanced Disk Panel, we can see of all the disks (visible to you or not) attached to your Mac – including mounted ISO/DMG/IMG files.
The devices printed in orange are not supported for Backup/Restore with ApplePi-Baker, as those are system disks.
More precise; these are disks that cannot be ejected – I may refine that in the future.
Note : in the upper right corner, you’ll see a disk icon. When this icon is gray (you can click it), only supported disks will be shown.
Per disk, you’ll see how it is connected, what brand/model disk it is (if provided by the manufacturer), capacity, devicename (in /dev/) and what partitions it has.
Per partition you’ll see the device name (/dev/diskXsY), it’s label and what type of partition it is – size and file system included, if applicable.
Note : If a partition is printed in Italic, then this means that this partition is NOT mounted.
Tinkering with System Disks and System Partitions … at your own risk!
If you get the insane idea to Eject your system disk (I’ll admit it, I have actually tried it!), then the system will tell you that it cannot eject the disk and nothing bad (should) happen. The same goes for mounting or unmounting.
That at least has been my experience.
No matter what my experiences are:
Please try not to tinker around with the system disks (like mounting the EFI partition) unless you really know what you’re doing.
Advanced Disk Panel
With Apples more recent way of dealing with disks (CoreStorage), you’ll potentially see some “funny” things.
In the example below:
It suggests I have two big disks (disk0 – 1 Tb, disk 1 – 744Gb)
However, My 1Tb SSD (disk0) actually holds a virtual image for disk1 and I really only have one SSD in this Mac (disk0).
Look at partition /dev/disk0s2 – an “Apple File System (AFPS) Physical Storage”.
Fusion disk users will see something similar, maybe even with an additional layer in between.
Now, if you look at /dev/disk1, then you’ll see “Synthesized Disk – Physical Store on partition /dev/disk0s2”.
So the fake (virtual) “/dev/disk1” actually lives on /dev/disk0s2.
These virtual disks come with a problem when analyzing these disks – the partitions on this disk are flexible in size and are sized as needed. These partitions do not have a fixed size (unlike normal-old-school-straight-forward-regular-plain partitions). Hence the phrase “(virtual)”, where as other partitions show an actual size.
Accessing Disk Functions
Right clicking (or CTRL + Left click) a disk or partition will reveal a popup menu with some practical functions you may appreciate.
Availability of functions does depend on what item you selected.
Extra Disk Functions
As you can see, quite a few options:
ApplePi-Baker Disk Functions
|Select this Disk (/dev/diskX)
||Add the selected disk to your disk selection for backup or restore
(double click does the same)
||Ejects a disk (unmount all partitions and eject disk)
||This will try to Mounts a Volume (partition)
||Tries to Unmount a Volume
|Reveal in Finder
||If a volume is mounted, then this will open it in Finder
|Prepare Disk for NOOBs use
||Erase a disk, and makes a single FAT partition for NOOBs use
||Expand all disks in the list, so you can see all details
||Collapse all disks in the list, so you just see the disks and no details
|Copy Structure to Clipboard as Text
||This Copies the entire tree of disks and information to your clipboard
|Copy All Drive Details to Clipboard as Text
||Copy all internal details of all disks onto your clipboard
|Copy Partition Table Info from Selected Disk
||Copies partition info from the selected disk (for debugging)
|Copy Partition Table Info from IMG file
||Copies partition info from the selected IMG file (for debugging)
|Close Advanced Disk Panel
||Close the Advanced Disk Panel view
Reporting Feedback and/or Issues
When running into issue, feel free to place a comment below …
Please keep in mind that this is a hobby for me, so do not confuse this with me being your 24/7 helpdesk.
Reporting issues …
ALWAYS mention what macOS and ApplePi-Baker version you’re using.
To make it easier, I’ve added a function in the “About” window.
Open “About” (click ), right click the version info in the upper left corner and select “Copy Version Information“.
Paste that with your issue/comment!
NEVER post huge lists!
To keep things readable, please please pretty please do not post huge lists or log dumps.
It makes things unreadable and hard to find for other users.
IF a log or list is needed, I’ll let you know,…
In case you really feel you really must post a list or a log, then please post them in the Raspberry Pi Forum or the MacOS X Software forum.