Backup Data Lifecycle
Relevant source files
The following files were used as context for generating this wiki page:
The Backup Data Lifecycle within the safe64switch utility governs the preservation of critical system configuration files before destructive or transformative operations occur. This system ensures that the Raspberry Pi's boot configuration can be restored in the event of an unsuccessful migration from 32-bit to 64-bit architecture.
The scope of this lifecycle is centered on the /boot/config.txt file, which contains essential firmware and kernel parameters for the Raspberry Pi hardware. By creating a timestamp-adjacent backup, the system provides a safety net for users performing low-level kernel switches.
Sources: README.md:1-10, safe64.sh:3-5
Backup Generation Phase
The lifecycle begins with a validation check to ensure the environment is a Raspberry Pi, followed immediately by the duplication of the active configuration. This is a synchronous operation that must succeed for the script to continue.
Trigger Mechanism
The backup is triggered automatically upon execution of the safe64.sh script, specifically after the environment check passes. The script uses the set -e flag to ensure that if the backup process fails, the subsequent configuration changes are never reached.
Sources: safe64.sh:6-18
Backup Logic and Flow
The following diagram illustrates the sequence of operations leading to the creation of the backup file:
The flow shows that the backup is the first persistent file system change performed by the utility.
Sources: safe64.sh:11-30
Data Retention and Storage
The system utilizes a simple naming convention for data persistence, targeting the same directory as the source file to ensure availability during boot-time recovery scenarios.
File Specifications
| Property | Value | Description |
|---|---|---|
| Source Path | /boot/config.txt | The active firmware configuration file. |
| Backup Path | /boot/config.txt.bak | The preserved state before 64-bit modification. |
| Command | cp | Standard copy utility used for duplication. |
Sources: safe64.sh:17-18
State Transitions
The lifecycle involves transitions from an "Active" state to a "Preserved" state.
This diagram demonstrates the non-destructive nature of the backup process relative to the original file.
Sources: safe64.sh:11-23
Modification and Integrity
After the backup is secured, the active configuration undergoes specific modifications. The integrity of the backup is maintained by ensuring no further write operations target the .bak extension.
Configuration Changes
The script performs the following modifications to the active config.txt:
- 64-bit Kernel Activation: Appends
arm_64bit=1if not already present. - GPU Memory Optimization: Appends
gpu_mem=16to optimize resources for 64-bit operation.
# Backup current config
echo "Backing up /boot/config.txt to /boot/config.txt.bak"
cp /boot/config.txt /boot/config.txt.bak
# Enable 64-bit kernel
if ! grep -q "^arm_64bit=1" /boot/config.txt; then
echo "Enabling 64-bit kernel..."
echo "arm_64bit=1" >> /boot/config.txt
fi
Sources: safe64.sh:17-25
Recovery and Rollback
While the script automates the creation of the backup, the lifecycle concludes with the user's ability to manually restore the system. The README.md references a "rollback timer" functionality intended to complement this backup, providing a safety window for the user to confirm system stability after the 64-bit switch.
Sources: README.md:4, safe64.sh:29-31
The Backup Data Lifecycle ensures that the transition to 64-bit architecture is reversible by maintaining a static snapshot of the system's boot parameters, thereby mitigating the risk of boot failure on Raspberry Pi hardware.