-   Linux - General (
-   -   How to easily copy changes in one linux filesystem to another ? (

grgsaliba 01-21-2013 12:01 PM

How to easily copy changes in one linux filesystem to another ?

I'm using linux (debian based distro) in embedded applications but my question is actually quite generic.

So I start out with some basic linux installation, install new programs, add my own scripts and customize various files according to the application. We then ship the first prototype devices and following customer feedback need to do some changes.

My problem is how can I easily send changes to the customer - without having to send him a full 4GB image for every update ?

The required updates might require changes to existing files, as well as addition or deletion of files in several different directories.

The best way I have found so far is to load the updated image on a prototype device, copy the entire installation to a local folder on my workstation using scp. Then I delete all the major directories in which I know there were no changes to reduce the total size as much as possible. I then send the resulting directory to the customer together with a batch file that runs scp to copy these files over to the target device.

This works fine but there are a number of problems:
- the size of the files to transfer is still larger than really required.
- manual deletion of the unchanged folders is a tedious process and mistakes are easy.
- deletion of files of the target installation is not prossible - only addition and updates are possible.

Is there any way to sort of create a "diff" of two filesystems and "automatically" generate some kind of patch that makes the target filesystem identical to the source ?


kbp 01-21-2013 06:05 PM

How does the customer usually update the device and do they want to change their process ? .. maybe they could set up a local copy of the filesystem and you/they could rsync from yours to theirs over the Internet?

grgsaliba 01-22-2013 01:49 PM

rsync is a good idea but I would prefer to have some kind of update file that can be used offline and stored for later use.


suicidaleggroll 01-22-2013 02:51 PM

What if you use rsync -avn --delete and dump the output to a log file. The -n tells rsync to do a dry run, meaning nothing is modified on the source or destination. Instead rsync prints out what it WOULD have done. You can then write a simple script to turn this log into a patch and gather all of the files it needs.

For example:

$ ls -l original/*
-rw-rw-r-- 1 user user  12 Jan 22 13:38 original/file1
-rw-rw-r-- 1 user user    6 Jan 22 13:38 original/file2
-rw-rw-r-- 1 user user    8 Jan 22 13:38 original/file3

total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:37 file4
-rw-rw-r-- 1 user user 0 Jan 22 13:37 file5

total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file6

total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file7
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file8

total 0
$ ls -l modded/*
-rw-rw-r-- 1 user user    6 Jan 22 13:39 modded/file1
-rw-rw-r-- 1 user user  19 Jan 22 13:39 modded/file2
-rw-rw-r-- 1 user user    8 Jan 22 13:38 modded/file3

total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:37 file5

total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:38 file6

total 0
-rw-rw-r-- 1 user user 0 Jan 22 13:39 newfile

You can see that in the "modded" directory, I modified file1 and file2, removed dir1/file4, removed dir3 entirely, and added dir4/newfile

$ rsync -avn --delete modded/ original/
sending incremental file list
deleting dir3/file8
deleting dir3/file7
deleting dir3/
deleting dir1/file4

sent 231 bytes  received 33 bytes  528.00 bytes/sec
total size is 33  speedup is 0.12 (DRY RUN)

The output is pretty much a list of instructions for your script.

grgsaliba 01-22-2013 04:34 PM

That's one clever idea! might be just what I need actually.

Most probably I will need to send one such update this week so I will try this out and let you know how it goes.

Thanks for the detailed reply!

All times are GMT -5. The time now is 11:31 PM.