7

I have linux installed on SD card, I used this command to install the rootfs

tar xpjf rootfs.tar.bz -C /mnt/rootfs/

Now, I made some changes to the rootfs and I would like to create a backup that I can use with the same command above, I tried using:

tar cpjf rootfs.tar.bz2 /mnt/rootfs
and
tar cpjf rootfs.tar.bz2 -C / mnt/rootfs
I also tried
tar cpjf rootfs.tar.bz2 /mnt/rootfs/*

And tried:

cd /mnt/rootfs
tar -cvpjf rootfs.tar.bz2 --exclude=/rootfs.tar.bz2 .
tar: ./rootfs.tar.bz2: file changed as we read it

but I end up with an archive that has two levels before the file system i.e mnt/rootfs/files What am I doing wrong ?

casperOne
  • 73,706
  • 19
  • 184
  • 253
iabdalkader
  • 17,009
  • 4
  • 47
  • 74

1 Answers1

14

That's because it starts from current working directory, you can do:

cd /mnt/rootfs
tar cpjf /rootfs.tar.bz2 .

And that should create an archive at /rootfs.tar.bz2 with its root at the contents of /mnt/rootfs/

alex88
  • 4,788
  • 4
  • 39
  • 60