Sunday, September 26, 2021

Testing

sudo asr restore --source /dev/disk1 --toSnapshot 9942DBA2-5C5C-4A6C-B099-79AE2C7B011D --target /dev/disk3 --erase
	Validating target...done
	Validating source...done
	Erase contents of /dev/disk3 ()? [ny]: y
	Replicating ....10....20....30....40....50....60....70....80....90....100
	Replicating ....10....20....30....40....50....60....70....80....90....100
	Restored target device is /dev/disk3s2.
Restore completed successfully.

Saturday, September 25, 2021

Cloning a macOS Big Sur partition to a USB Drive (bootable)

I'm using MacBook Air 2013 running macOS Big Sur. This is how I made a bootable backup of my macOS partition to another partition on my USB drive. Apple Software Restore (asr command line utility) allows a user to restore the content of a (system) volume (disk/partition) to another volume or disk image. This can be thought of cloning a partition.

Step 1

My USB drive has 4 partitions as shown in the image below. The internal system volume (source), macOS Big Sur, is going to be restored to NAK-macOSBigSur partition (target) on the USB drive. The partition is formatted as APFS with GUID Partition Map scheme.

NOTE: This post is about restoring from a snapshot of the system volume (which is explained in the next steps). If there is no snapshot and so it won't be specified in the command, the size of target volume (or disk image) must be greater than the size of the source system volume (not just the size of the system volume's content) or the restore will fail. Just make sure the target volume's size is bigger before the restore and then shrink it later.


Step 2

Note down the identifiers of the source system volume, macOS Big Sur, and the target USB's partition. They can be viewed in DiskUtility or from Terminal using this command:



> diskutil apfs list


APFS Containers (2 found)

|

+-- Container disk1 0A4D95E1-BDA4-4BEF-B349-D34D0B1EAD0B

|   ====================================================

|   APFS Container Reference:     disk1

|   Size (Capacity Ceiling):      89999998976 B (90.0 GB)

|   Capacity In Use By Volumes:   65204166656 B (65.2 GB) (72.4% used)

|   Capacity Not Allocated:       24795832320 B (24.8 GB) (27.6% free)

|   |

|   +-< Physical Store disk0s2 E0056EF5-6FCD-4D45-AB00-C7D273999AE5

|   |   -----------------------------------------------------------

|   |   APFS Physical Store Disk:   disk0s2

|   |   Size:                       89999998976 B (90.0 GB)

|   |

|   +-> Volume disk1s1 23C04205-6361-398C-989F-10195CDC66BA

|   |   ---------------------------------------------------

|   |   APFS Volume Disk (Role):   disk1s1 (Data)

|   |   Name:                      macOS Big Sur - Data (Case-insensitive)

|   |   Mount Point:               /System/Volumes/Data

|   |   Capacity Consumed:         47762022400 B (47.8 GB)

|   |   Sealed:                    No

|   |   FileVault:                 No

|   |

|   +-> Volume disk1s2 0300C5AA-7F28-4FB1-9B21-F128B56BD685

|   |   ---------------------------------------------------

|   |   APFS Volume Disk (Role):   disk1s2 (Preboot)

|   |   Name:                      Preboot (Case-insensitive)

|   |   Mount Point:               /System/Volumes/Preboot

|   |   Capacity Consumed:         284585984 B (284.6 MB)

|   |   Sealed:                    No

|   |   FileVault:                 No

|   |

|   +-> Volume disk1s3 FF1FA02B-5C9E-41E9-8193-4676E5DC57D3

|   |   ---------------------------------------------------

|   |   APFS Volume Disk (Role):   disk1s3 (Recovery)

|   |   Name:                      Recovery (Case-insensitive)

|   |   Mount Point:               Not Mounted

|   |   Capacity Consumed:         623341568 B (623.3 MB)

|   |   Sealed:                    No

|   |   FileVault:                 No

|   |

|   +-> Volume disk1s4 A0B8A157-01F7-4563-9C6A-CC869FE11FB5

|   |   ---------------------------------------------------

|   |   APFS Volume Disk (Role):   disk1s4 (VM)

|   |   Name:                      VM (Case-insensitive)

|   |   Mount Point:               /System/Volumes/VM

|   |   Capacity Consumed:         1074819072 B (1.1 GB)

|   |   Sealed:                    No

|   |   FileVault:                 No

|   |

|   +-> Volume disk1s5 8C1ADEAE-7361-415F-AEBF-C64BD1C00146

|       ---------------------------------------------------

|       APFS Volume Disk (Role):   disk1s5 (System)

|       Name:                      macOS Big Sur (Case-insensitive)

|       Mount Point:               Not Mounted

|       Capacity Consumed:         15330869248 B (15.3 GB)

|       Sealed:                    Broken

|       FileVault:                 No

|       |

|       Snapshot:                  9942DBA2-5C5C-4A6C-B099-79AE2C7B011D

|       Snapshot Disk:             disk1s5s1

|       Snapshot Mount Point:      /

|       Snapshot Sealed:           Yes

|

+-- Container disk3 FD345835-64FB-4924-962B-FB26C2B8F980

    ====================================================

    APFS Container Reference:     disk3

    Size (Capacity Ceiling):      76559953920 B (76.6 GB)

    Capacity In Use By Volumes:   122478592 B (122.5 MB) (0.2% used)

    Capacity Not Allocated:       76437475328 B (76.4 GB) (99.8% free)

    |

    +-< Physical Store disk4s5 17F2CE1B-2E10-411D-8ECF-0435F949DFAE

    |   -----------------------------------------------------------

    |   APFS Physical Store Disk:   disk4s5

    |   Size:                       76559953920 B (76.6 GB)

    |

    +-> Volume disk3s1 714E92A0-4F22-47A0-A72C-449E389BFC23

        ---------------------------------------------------

        APFS Volume Disk (Role):   disk3s1 (No specific role)

        Name:                      NAK-macOSBigSur (Case-insensitive)

        Mount Point:               /Volumes/NAK-macOSBigSur

        Capacity Consumed:         827392 B (827.4 KB)

        Sealed:                    No

        FileVault:                 No


Step  3

Run Apple Software Restore command as following:


> sudo asr restore --source /dev/disk1 --toSnapshot 9942DBA2-5C5C-4A6C-B099-79AE2C7B011D --target /dev/disk5 --erase --buffersize 32m  


Password:

Validating target...done

Validating source...done

Erase contents of /dev/disk5 ()? [ny]: y

Replicating ....10....20....30....40....50....60....70....80....90....100

Replicating ....10....20....30....40....50....60....70....80....90....100

Restored target device is /dev/disk5s2.

Restore completed successfully.

Apple does not allow restoring a system volume when its seal is broken and so is mine, then specifying the --snapshot option is a workaround to bypass the restriction. The snapshot was created by macOS Big Sur automatically when it updated itself and so it's the OS update snapshot.

The seal is part of Signed System Volume (SSV) technology, which is used to protect a system content on a signed system volume. With SSV, the kernel rejects any data or code (at runtime) that does not have a valid cryptographic signature from Apple to protect the integrity of the system content. I'm not sure if the seal is broken because I once booted into Recovery mode and used DiskUtility to restore the system volume to a USB drive. But, some people on the internet said the seal was broken even for a fresh install of Big Sur. 

/dev/disk1 is the identifier of the (source) system volume's container. The identifier of the system volume can also be used, /dev/disk1s1, in this case.

/dev/disk5 is the identifier of the target USB partition's container. The identifier of the partition can also be used, /dev/disk3s1, in this case.

--buffersize 32m option (32m means 32 Megabytes) makes the asr command run faster than the default buffer size. This is ideal for block-copies between partitions.  The size should be changed and experimented for an optimal value.

And the image below shows how my USB drive's partition changed after restore completed.


macOS Sierra

The asr restore command might throw the error below.

Source volume is read-write and cannot be unmounted, so it can't be block copied.

To solve that, the asr restore command must be run in Mac's Recovery mode (restart the machine and hold Command + R).

macOS High Sierra

The asr restore command always fail at the end. Many people reported the same so I downgraded to macOS Sierra.




Sunday, September 19, 2021

Errors restoring or creating a disk image from a volume using DiskUtility

I'm using Macbook Air running macOS Big Sur, and I was having troubles performing disk restore using DiskUtility.

ERROR 1: I was unable to restore a volume to a new blank disk image I created. 

There could be a couple reasons such as the size of the blank disk image is smaller than the size of the source volume or there was no partition in the disk image (must be manually created at least 1 partition). But, even if I did follow all these requirements, the restore still failed.

ERROR 2: When trying to create a new disk image from a device or folder, I got the error message like "...operation not permitted". 

The function to create a new image from a device/folder is useful because the size of the new disk image will automatically be set to the size of the source device/folder, and the contents of the device/folder are restored (cloned) to the new disk image. 

SOLUTION

The errors occured because DiskUtility did not have enough privileges to perform those operations. After assigning a Full Disk Access permission to DiskUtility, I could restore a volume to a disk image (and vice versa) without any problems.

How to assign Full Disk Access permission to DiskUtility?

Open System Preferences > Security & Privacy > Privacy then select Full Disk Access from the listbox on the left and click on the Plus sign to add DiskUtility to the right listbox and make sure it's checked.






Backing up macOS with Time Machine

I installed macOS Big Sur on my MacBook Air (11-inch 2013) and used Time Machine application to backup the macOS partition to an external USB drive. 

I also created a bootable macOS Big Sur installation USB stick for restoring the changes back in time using Time Machine, or just installing a fresh macOS Big Sur. In fact, I can also boot into Recovery Mode to perform restore or install too (pressing Command + R while the machine is starting). If the hidden Recovery partition that macOS created is also corrupted or erased, the built-in internet Recovery Mode is used instead. The internet Recovery needs WiFi access to download recovery system image from Apple then start the Recovery mode.

Time Machine backs up the neccesary files to an external hard drive and then uses the backup drive to restore the files back in time. Time Machine can be thought of System Restore in Windows (it's not cloning). I formatted the backup drive using Mac OS Extended (journaled) file system but macOS Big Sur's Time Machine reformatted it as APFS (Case-sensitive). 

Backing up with Time Machine

1. Open System Preferences > Time Machine

2. Click on Select Disk... button and choose a drive or a partition to store the backup files. In my case, the partition's name is Time Machine's Backups (MBA-BigSur) as shown in the image below.

3. Click Options... button and make sure to add any drives or paritions other than the one running OS in the exlusion list

4. Uncheck Backup Automatically so it only backs up when neended.

5. Check Show Time Machine in menu bar then the clock icon will appear at the top of the screen

6. Click on the Time Machine icon in the menu bar and select Back Up Now






ERROR: " This copy of the Install OS X Mavericks application can't be verified. it may have been corrupted or tampered with during downloading"

The error messsage was thrown when running OS X Mavericks Installer (previously downloaded from App Store).

For my case, this is because the installer file was downloaded years ago so the certificate come with it had expired. I should re-download it but it was no longer available on App Store.

Thus, the workaround is to change my machine's date (clock) to the release year of OS X Mavericks. It's easy to change the date if the installer is launched from the running OS X prior to Mavericks, but if it is launched from Recovery mode, it invovles running commands in Terminal (there's enough posts on the net about this though).

Creating OS X Mavericks (or macOS) Bootable USB Drive

When downloading OS X Mavericks from App Store, the installer file's name might be something like  "Install OS X Mavericks.app" and stored in /Application folder.  Double click on the file would launch the installer then lead to restarting machine and installing the OS X Mavericks. 

But, OS X Mavericks was not available on App Store anymore so I downloaded it from someone else's backup on the net. He renamed the file "Install OS X Mavericks.app" to "Mavericks.app" and wrapped it in a DMG file.

I'm using MacBook Air running macOS Big Sur to make this bootable USB drive, just in case my machine fails to boot for some reasons.

Method 1

1. Prepare a USB stick with at least 6 GB then open DiskUtility to format it as Mac OS Extended (Journaled) and name it as InstallOSXMavericks.

2. Double click on the DMG file in Finder to mount it and copy the Mavericks.app to the /Applications folder.

3. Open Terminal and run the following command:

sudo /Applications/Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/InstallOSXMavericks --applicationpath /Applications/Mavericks.app --nointeraction

NOTE: For macOS Sierra, the command might fail with the error message below:

/Volumes/NAK-InstallMacOSSierra is not a valid volume mount point.

If it does, run the following command:

sudo plutil -replace CFBundleShortVersionString -string "12.6.03" /Applications/Install\ macOS\ Sierra.app/Contents/Info.plist

4. Restart the machine. Before it starts, press and hold Option key until the boot menu shows up. Choose Install OS X Mavericks and wait to see if it's really bootable.

Method 2

1. Make sure DiskUtility has Full Disk Access permission. If not, assign it the permission, and here is how.

2. Prepare a USB stick with at least 6 GB then open DiskUtility to format it as Mac OS Extended (Journaled) and name it as InstallOSXMavericks.

3. Open Finder then double click on the installer file (DMG) to mount it

4. Navigate to the mounted image file then right click on Mavericks.app and select Show Package Contents. After that, open this folder Contents > SharedSupport and double click on InstallESD.dmg file to mount and show it in DiskUtility.

5. Select the USB drive from the side bar then click Restore and choose InstallESD.dmg from "Restore from" combobox and click Restore again.

6. When the restore completes, restart the machine. Before it starts, press and hold Option key until the boot menu shows up. It would not show Install OS X Mavericks like in Method 1 but EFI instead. Choose EFI then wait to see if it's really bootable. There can be another bootable device showing as EFI too. This is confusing and need to guess and try.  


NOTE: I used Method 1 to create a bootable USB for macOS Big Sur too and it worked.

Thursday, September 16, 2021

Creating a bootable Windows 10 installation USB drive

The easieset way to create a bootable installation media (USB drive) for Windows 10 (or any other Operating Systems) is using UNetbootin (a free open-source software). It can run on Mac OSes, Windows, and Linux.

I downloaded and installed UNetbootin on my MacBook Air (running macOS Big Sur) and used it to create a bootable Windows 10 installation USB drive successfully. It had two options for writing the Windows 10 setup file to the USB stick: automatically downloading Windows 10 and using local ISO file of Windows 10. I tried it with my MacBook Pro, and it did boot up from that USB. 

Step 1:

Open Terminal and run the following command to see the device identifier of the USB partition for storing Windows 10 installation file (which can be downloaded for free from Microsoft's website).

> diskutil list


For my case, I named the USB parition as REPAIRWIN10 and then the assigned identifier was disk2s6.

Step 2:

Start UNetbootin application and configure it as followings:










Unable to create a System Restore point on Windows 10 running on Macbook Pro 2011

After successfully installing Windows 10 on Macbook Pro 2011, I tried to create a System Restore point but got the failure message below.

The restore point could not be created. The shadow copy provider had an error (code 0x80042306).

Many people on the net recommended starting the Shadow Copy Provider in Services (press Windows + R then type services.msc) if it isn't running or restarting it if it is already running, but that didn't fix it.

Then, I checked the logs in Event Viewer and see the description of the error code 0x80042306 below. NOTE: To start Event Viewer, open Control Panel > System and Security then click on View event logs under Administrative Tools. After that, select Event Viewer (Local) > Windows Logs > Application (or System) and create a System Restore point so that the error shows up in the logs again.

Volume Shadow Copy Service error: Unexpected error CreateFileW(\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy38...

I googled it and some people said the AppleHFS driver (from Boot Camp) is the cause of the error, and they suggested disabling it. The driver allows read-only access to an HFS drive (HFS is a Mac OS file system format). Since I didn't need to access any HFS drives, I was fine with it. After disabling it, I was able to create System Restore.

Disabling AppleHFS driver:

1. Download and install Autoruns program (a part of Sysinternals Utilities to see the description of the error code).

2. Open File Explorer then navigate to C:\Windows\System32\drivers and rename the file AppleHFS.sys to AppleHFS_DISABLED.sys (or anything else).

3. Restart the machine.



Wednesday, September 15, 2021

Solved Issues while installing Windows 10 with VirtualBox (v6)

Message: "Something went wrong (OOBESETTINGS)"



This message showed up in the middle of installing Windows 10 with VirtualBox.

Solution 1

1. Close the window and choose Power off the machine.

2. Go to Settings and set number of CPU cores to 2.

3. Start the machine again.


Solution 2

1. Press Shift + F10 to open Command Prompt and then run the following commands:

> net user Administrator /active:yes
> net user /add MyName MyPassword
> net localgroup administrators MyName /add
> cd %windir%\system32\oobe
> msoobe.exe

2. Close the Command Prompt window then select Machine > Reset to restart the virtual machine. Don't use the close button at the edge of the window of the running machine to forcefully shut it off, it might corrupt the virtual hard disk, and the virtual machine can't start. If the similar error message shows up again or it's stuck at "Just a moment" screen, just restart it again.

3. Click OK when the message below shows up.

then, it'll lead to Administrator login screen below. From this point forward, the error message should never appear again.


NOTE: After the installation's completed, disable the Administrator user because viruses can use the user to make change to the system files (even in Boot Sector).




Saturday, September 11, 2021

Useful programs and browser's extensions for my Macbook Pro 2011 running Windows 10

Programs


QTTabBar

It adds tabs to File Explorer.

Notepad++

It's a free source code editor supported several languages.

VLC

It's easy to add subtitle for a movie and can also increase the brightness and contrast of a video if it's too dark.

Free Download Manager

- Free
- Download any files faster 
- Integrate with browsers (using extension)
- Download torrents
- Download Youtube videos (in many formats or sizes)
iGetter is a good alternative; it's free, supports browser integration, and can download a whole site.


Chrome Extensions


Video DownloadHelper (Offered by: www.downloadhelper.net)

It can download movies (MP4 files) from any sites like kissasian.al.

Free Download Manager (Offered by: Free Download Manager.ORG)

It helps transfer any downloads, even from Video DownloadHelper extension, to Free Download Manager desktop program.


#1 FB Video Downloader HD+ (SnapSave) (Offered by: SnapSave Company)

It can download videos from Facebook, just clicking on the panel at the top right corner of a video without even playing. It also provides an option to download different video sizes.


Thursday, September 9, 2021

Useful apps and browser's extensions for my Macbook Air running macOS Big Sur

Applications


BBEdit

Its free mode has enough features such as rich text formats (eg. line numbers) and multiple opening documents.

Free Download Manager (FDM)

It's free, can download torrents and Youtube videos (in many formats and sizes), and integrate with browsers to capture downloads. iGetter is a good alternative but is supported only by earlier Mac OSes at the moment. iGetter can download a whole website but not torrents and Youtube videos.

VLC

I'm using it to play movie files (MP4). It's easy to add and adjust the color and size of subtitles. I can also adjust the brightness and contrast of a video so that it's not too dark to see.


Sunday, September 5, 2021

Installing Windows 10 on Macbook Pro 2011 (unsupported Mac) and Fixing Sounds

My Macbook Pro 13-inch Early 2011 is in the list of Bootcamp Support for Windows 7 and Windows 8, but not Windows 10. It means that my machine would be fine running Windows 7 and Windows 8, yet some hardware might not be recognized when running Windows 10. However, later Mac models work just fine with Windows 10 because Apple provides hardware drivers (Bootcamp Support) for them.

[Method 1] HERE is how I successfully installed Windows 7 via VirtualBox. And here is some solved issues happened during installation. It worked with Windows 10 too, just using a Windows 10 ISO file instead, but sound didn't work out of the box. There were several steps to do for solving the sound issue. However, built-in keyboard and USB mouse worked fine without insalling drivers from Bootcamp Support (but I wasn't able to adjust screen brightness, keyboard backlight, and sounds using function keys). 

[Method 2] I was also able to install Windows 10 using a bootable USB stick (created by Bootcamp app) but built-in keyboard, trackpad, and USB mouse weren't working when starting Windows for the first time so I couldn't even install the drivers from Bootcamp Support. I had to press and hold down the power button to shutdown the machine and start it again; then Windows did some repair tasks and rebooted the machine, and the keyboard and USB mouse started to work so I was able to install the drivers from Bootcamp Support and then Windows updates. However, sound and external monitor weren't working. Sound issue could be fixed by the steps described in the section below, but external monitor couldn't, even after installing the monitor driver and firmware updates and manually updating the graphics card's driver).

Fixing WiFi, Camera, Bluetooth, and external monitor

I got WiFi, Camera, Bluetooth, and SD card reader working using Bootcamp Support version 5.1 (intended for Windows 7 and 8 only), but I had to manually install them one by one, by clicking on their corresponding setup files located in the Broadcom and Apple folders the Bootcamp Support file. I also manually installed other drivers that came along, thinking they might be useful though I didn't know what they were.

After installing Windows Updates and some drivers from Bootcamp Support, I was able to adjust screen brightnes (in Settings > System > Display) and use my external monitor connecting through Thunderbolt-to-VGA adapter.

Fixing Sound

At first, I followed everything from the video below (I backed it up here in case it gets deleted from the channel).

Here is the steps from the original post that the video referred to.

The sound still didn't work for me though it did for many others on Youtube. Under Sound, video, and game controllers section in the Device Manager settings, the sound driver got a yellow exclamation mark on it as shown here:

Then, I right clicked on it and select Update driver > Browse my computer for drivers. Then, in the Search for drivers in this location box, I browsed to DisplayAudio folder in the downloaded Bootcamp Support file and clicked OK. For my case, the location is C:\Users\Bros\Documents\bootcamp5.1.5769\$WinPEDriver$\IntelHDGraphics64\DisplayAudio.

The yellow exclamation mark was gone but I still couldn't hear any sounds. 

After that, I installed this driver CirrusAudioCS4208x64.exe from the Bootcamp Support file but still no luck. For my case, the file location is C:\Users\Bros\Documents\bootcamp5.1.5769\BootCamp\Drivers\Cirrus.

It worked after installing another driver, CirrusAudioCS4206x64.exe, located in the same folder. And the sound drivers in the Device Manager settings updated their names as shown below.