I'm intending to do a raw backup (alike DD do if I'm not mistaken) of the SD card on a Windows machine and than zipping it. For that reason I would like to clear all unused sectors before making the copy, as than the zipping will result in the smallest possible file.
Q: Does Stretch have a program available which can do that, and if so which is it ?
The only way to make sectors that are not in use zero that I can think of, is to do a complete write of a blank piece of something..with zeros and copy only the valid data ontop it.
That means working at the file copy level, not the DD level.
i.e. you need to create a new partion system that is all zeros, except the partion inmformation of course, then copy all the files onto it and then zip the lot up.
--
If I had all the money I've spent on drink...
..I'd spend it on drink.
Alas, I'm looking for a backup method of an in-use card (updated, installed programs - the works). Would also be nice if I could backup a LibreElec/Kodi configured card with it.
I am not at all sure if I can copy /all/ files (to begin with), and if writing them back to a newly created SD card (using noobs) will result in, functionally, the same as the origional.
Which is why my thoughts went toward a "raw" copy - either the full SD card, or per partition (not sure about which one yet).
And to be honest, I just now realized that clearing out unused sectors on a LibreElec/Kodi configured card might be a problem ... (no user accessible OS).
The PI seems to work thisaway - please correct me if you know better .
1/. It needs first partition as VFAT containing some boot level stuff.
2/. Everything else is just files in an EXT4 partion
3/. There is no 'boot sector' as such.
4/. The ext4 partiton is in use mounted as root
5/. the vfat partion is mounted as /boot.
6/. The ONLY info OUTSIDE of files that is on te SD card iare te partition UUIDS which are used by fstab and mount to mount the partitions. You can get roynd that anyway by editing fstab to use te raw device types..e.g. /dev/mmcblk0p2 on / and /dev/mmcblk0p1 on /boot
If you do that you have a bootable system irrespetive of partition UUID
# ??? how come no users accessible OS?
You can allegedly ssh into LibreElec. It is a stripped down linux.
So most basic linux comnnads should be there somewhere.
Well in any case using - say - a live linux DVD to boot an intel class machine, and an SD card reader, its no big deal to mount both partitions on the SD card, and file copy their contents onto the host machines disk.
Then you have essentially all the file level info. Which you can zip up.
To create a bootable image in a new SD card, you use a live linux boot system, to create a 40Mbyte vfat partition on a new SD card and format the rest as ext4
Then unzip and copy the files to the partrtions, eject the card and put it in a Pi and boot it..
--
All political activity makes complete sense once the proposition that
all government is basically a self-legalising protection racket, is
Not what you asked for, but I have used 'partimage' on linux systems for years. It will back up the used sectors of a partition. It can also compress the image and/or backup over the network. It is linux only, and seems not to be in the raspbian repository. You could use a linux live cd on your win machine to do it - or you could download the source and build it on your raspbian. I first became aware of partimage several years ago when I wanted to upgrade the hard drive on a laptop. Copied out the image, partitioned the new drive and copied back - as I recall it can restore an image to a larger partition with no hassle.
dd stops when the disk is full - the empty space is written with zeroes.
then delete the file and make your disk backup. dd backups are usually the whole disk, but when you zip it you should see the difference (depending on your otherwise empty space)
You can also try rsync: which is a Raspbian package and will copy data to any other partitions and ignore cruft on the source:
- use a partitioning utility to set up partitions on the new SD-card (in a USB-SD card adapter or a USB-connected HDD
- use rsync to copy the partition contents across.
- boot off the new SD card.
You can also use any archiving system such as tar for the EXT4 partition and ZIP for the FAT partition. Don't use zip for the EXT4 partition because it will play merry hell with Linux permissions and file ownership.
Any of these will only copy the contents of directories and files, while ignoring anything that isn't part of a directory or file.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.