Dev/Embedded/Rootfs: Difference between revisions

From Embeded Linux (and more) Wiki by Nathael
< Dev‎ | Embedded
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Busybox rootfs ==
== [[Dev/Embedded/Rootfs/BusyBox|BusyBox rootfs]] ==


== Devuan rootfs ==
== Devuan rootfs ==
Line 5: Line 5:
* [[Dev/Embedded/Rootfs/Devuan/Config|Devuan configuration]]
* [[Dev/Embedded/Rootfs/Devuan/Config|Devuan configuration]]


== Rootfs Backup (or Copy) ==
== [[Dev/Embedded/Rootfs/Backup|Rootfs backup or copy]] ==
First of all, avoid any site which tells you to use ''dd'' to backup or clone your system, as it's author either does not want to take some time to explain how things work, or simply doesn't know.<br />
When using ''dd'' :
* you won't be able to extract the content to explore it on your development system
* you will not be able to change the partition sizes or layout when creating a copy
* you will not be able to change the filesystem type
* even if you compress the result, extracting it will require as much space as your SD card had, using 4GB (or 8, or 16 ?), and no way to extract to a smaller µSD card or you may loose data and get a broken filesystem.
* and you will also copy any junk found on the SD card, as the empty space is not necessarily filled with zeroes, making a bigger image than required, even when compressed !!
 
The right way to do it is to use tar.
 
For each partition you need to backup, you must mount it on an empty directory, possibly with ''bind'' mount option, and then create an archive :
mntpoint=/mnt/tmp
mkdir ${mntpoint}
disk=mmcblk0  # Use the right disk name (sda, sdb, ... mmcblk1, ...)
partition=p1  # Use the right partition indicator (p1, p2, p3, ... for mmcblk* or simply 1, 2, 3, ... for sd*)
mount -o bind /dev/${disk}${partition} ${mntpoint}
cd ${mntpoint}
tar cjf /somewhere/else/backup_${disk}${partition}_$(date +%Y-%m-%d).tar.bz2 *
cd && umount ${mntpoint}
You can of course chose the backup image name according to your preferences, this is only an example, but the Archive file '''MUST be on another partition'''.<br />
Alternatively you can combine tar and ssh to directly transfer the archive to your host system :

Latest revision as of 00:27, 17 October 2019