How to Use SD Cards for Backups on Linux
SD cards have come a long way from being simple storage for digital cameras. With capacities now reaching multiple terabytes, they present an attractive, portable backup solution. However, Linux users often encounter frustrating issues when attempting to leverage these pocket-sized storage powerhouses for serious backup purposes.
In this guide, we'll explore how to properly configure, verify, and utilize SD cards for reliable backups on Linux systems, avoiding common pitfalls that can lead to data loss and corruption.
Choosing the Right Hardware
SD Card Selection
Not all SD cards are created equal. When selecting a card for backup purposes, consider:
- Capacity vs. Authenticity: That suspiciously cheap 1TB card might actually be a 32GB card hacked to report a larger size. When the card's real capacity is exceeded, data corruption occurs.
- Speed Classification: Look for UHS-I or UHS-II cards with higher speed ratings (V30, V60, V90) for backup operations.
- Endurance Rating: Cards designed for surveillance cameras or dashcams often have better write endurance, making them suitable for frequent backups.
- Brand Reliability: Stick with reputable brands like SanDisk, Samsung, Kingston, or Lexar from authorized retailers.
Card Readers Matter
A quality card reader can make the difference between successful backups and corrupted data:
- USB 3.0 or higher connectivity offers faster transfer speeds
- Standalone powered readers provide more stable power than built-in laptop readers
- Multi-card readers with dedicated SD slots often perform better than all-in-one solutions
Verifying Your SD Card's Authenticity
Before trusting your precious data to an SD card, verify its authenticity. The excellent open-source tool F3 (Fight Flash Fraud) makes this process straightforward:
# Install F3
sudo apt install f3 # Debian/Ubuntu
sudo dnf install f3 # Fedora/RHEL
sudo pacman -S f3 # Arch Linux
# Write test files to fill the card
f3write /path/to/mounted/sdcard
# Verify the written data
f3read /path/to/mounted/sdcard
A genuine card will show consistent read/write speeds and verified capacity matching the advertised size. Counterfeit cards will report errors once the actual capacity is exceeded.
Choosing the Optimal Filesystem
Your filesystem choice dramatically impacts backup reliability, especially with large-capacity cards:
ext4: The Linux Native Option
sudo mkfs.ext4 /dev/sdX
Pros:
- Journaling prevents corruption during unexpected disconnects
- Excellent handling of many small files
- Best performance on Linux systems
Cons:
- Limited compatibility with other operating systems
- Requires additional software for Windows/macOS access
NTFS: The Windows-Friendly Option
sudo mkfs.ntfs -f /dev/sdX # -f performs a quick format
Pros:
- Good cross-platform compatibility
- Handles large files and large volumes well
- No practical file size limitations
Cons:
- Write performance can be slower on Linux systems
- Requires NTFS-3G drivers on Linux
exFAT: The Modern Cross-Platform Solution
# Install exFAT tools
sudo apt install exfatprogs # Ubuntu/Debian
sudo dnf install exfatprogs # Fedora/RHEL
# Format the card
sudo mkfs.exfat /dev/sdX
Pros:
- Designed specifically for flash media
- Excellent cross-platform compatibility
- Handles large files and volumes efficiently
- Better than FAT32 for many small files
Cons:
- Less robust than ext4 (no journaling)
- Requires additional packages on some Linux distributions
FAT32: The Legacy Option (Not Recommended for Backups)
sudo mkfs.vfat -F 32 -s 8 -S 4096 /dev/sdX
Pros:
- Universal compatibility
- Simple structure
Cons:
- 4GB file size limitation
- Poor handling of many small files
- Prone to corruption with large volumes
- Not recommended for backup purposes on cards larger than 32GB
Creating Backups with rsync
The rsync
utility is the Swiss Army knife of Linux backups. Here's how to leverage it effectively for SD card backups:
Basic Backup Command
rsync -av --progress /source/directory/ /path/to/sdcard/
The trailing slashes are important! They tell rsync to copy the contents of the source directory rather than the directory itself.
Enhanced Integrity Checking
rsync -av --progress --checksum /source/directory/ /path/to/sdcard/
The --checksum
option verifies file integrity by comparing file contents rather than just timestamps and sizes. This is slower but catches corruption issues that might otherwise go unnoticed.
Dealing with Problematic Transfers
rsync -av --progress --inplace --no-whole-file --modify-window=1 /source/directory/ /path/to/sdcard/
This command is particularly useful for troublesome SD cards:
--inplace
updates files directly rather than creating temporary copies--no-whole-file
transfers changed parts of files only--modify-window=1
allows for slight timestamp differences
Automating Your Backups
Create a simple backup script:
#!/bin/bash
# SD card backup script with verification and notification
SOURCE="/path/to/data"
DEST="/path/to/mounted/sdcard/backup"
LOG="/home/user/backup_logs/backup_$(date +%Y%m%d_%H%M%S).log"
mkdir -p "$(dirname "$LOG")"
# Ensure SD card is accessible
if ! [ -d "$DEST" ]; then
echo "Error: Backup destination not accessible!" | tee "$LOG"
exit 1
fi
# Check available space
SOURCE_SIZE=$(du -sb "$SOURCE" | cut -f1)
DEST_AVAIL=$(df -P "$DEST" | awk 'NR==2 {print $4 * 1024}')
if [ "$SOURCE_SIZE" -gt "$DEST_AVAIL" ]; then
echo "Error: Insufficient space on backup device!" | tee -a "$LOG"
exit 2
fi
# Perform backup with detailed logging
echo "Backup started at $(date)" | tee -a "$LOG"
rsync -avh --progress --checksum --stats "$SOURCE/" "$DEST/" 2>&1 | tee -a "$LOG"
# Verify successful completion
if [ ${PIPESTATUS[0]} -eq 0 ]; then
echo "Backup completed successfully at $(date)" | tee -a "$LOG"
# Optional: Send notification
# notify-send "Backup Successful" "Data has been backed up to SD card"
else
echo "Backup failed with error at $(date)" | tee -a "$LOG"
# Optional: Send notification
# notify-send -u critical "Backup Failed" "SD card backup encountered errors"
fi
Make it executable with chmod +x backup_script.sh
and schedule with cron if needed.
Troubleshooting Common Issues
Filesystem Errors During Backup
Symptoms: rsync crashes, input/output errors, sudden disconnections Common Causes:
- FAT32 limitations with many files or large volumes
- Counterfeit card exceeding actual capacity
- Card controller issues
Solutions:
- Use ext4 or exFAT filesystem instead of FAT32
- Verify card authenticity with F3
- Try a different card reader
- Break backups into smaller batches
Slow Transfer Speeds
Symptoms: Backup takes excessively long time Common Causes:
- Low-quality card with poor write performance
- Suboptimal card reader
- USB bus limitations
Solutions:
- Use a card with higher speed rating (V30+)
- Use a dedicated USB 3.0+ card reader
- Ensure card reader is connected directly to computer, not through a hub
Data Corruption After Backup
Symptoms: Files unreadable or truncated after backup completes Common Causes:
- Improper ejection/unmounting
- Power fluctuations during write operations
- Filesystem not suitable for the card
Solutions:
- Always properly unmount before removing:
sudo umount /path/to/sdcard
- Use a powered card reader
- Consider using a journaling filesystem like ext4
- Use the
--checksum
option with rsync to verify integrity
Best Practices for SD Card Backups
- Always verify your backups. Don't assume the data was written correctly.
- Label your cards. Physical labels with date and content information prevent confusion.
- Store cards properly. Use protective cases and keep away from magnetic fields.
- Rotate multiple cards. Don't rely on a single backup medium.
- Periodically refresh data. SD cards can lose data over very long storage periods (years).
- Check filesystem integrity regularly:
fsck /dev/sdX
Conclusion
SD cards can be excellent backup solutions for Linux users when properly configured and managed. By choosing the right card, verifying its authenticity, selecting an appropriate filesystem, and using robust backup commands, you can create a reliable, portable backup solution.
Remember that while SD cards offer convenience, they should be part of a broader backup strategy. Consider the 3-2-1 backup rule: three copies of your data, on two different media types, with one copy stored off-site.
Credits: Meta image Memory Card Electronics by kieutruongphoto
Featured Merch

Latest Posts
- Wiki Story: Turn Wikipedia Articles into Captivating Narratives
- How to Determine the SMTP and IMAP Servers for a Domain
- How to Determine the Email Server (MX Records) for a Domain
- How to Set max_input_vars in PHP: A Quick Guide for Developers
Featured Book

Subscribe to RSS Feed
This post was written by Ramiro Gómez (@yaph) and published on . Subscribe to the Geeksta RSS feed to be informed about new posts.
Tags: backup guide linux hardware
Disclosure: External links on this website may contain affiliate IDs, which means that I earn a commission if you make a purchase using these links. This allows me to offer hopefully valuable content for free while keeping this website sustainable. For more information, please see the disclosure section on the about page.