Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I'm creating a tar via script like this. I am compressing with bzip2.
tar -cjpf /mnt/mybook/cfg.tar.bz2 /home/cfg
mybook is a usb drive on sdb1 formated as fat32. I can't use ntfs since I have the older kernel.... Linux version 2.4.21-15.0.3.EL (email@example.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-37)) #1 Tue Jun 29 18:17:52 EDT 2004
My problem is when I extract the tar it errors saying cannot set permissions to 600: Operation not permited. I am creating the tar and restoring it as root.
I have tried restoring with
tar -C /home/cfg -xjpf /mnt/mybook/cfg.tar.bz2 --overwrite
tar -xjpf /mnt/mybook/cfg.tar.bz2
Both extract the files but all ownership is root. I only have two users on the system say UserA who has a security of 600 and root. What am I missing that tar is not preserving UserA and making everything root when I extract.
When I run tar -tjvf /mnt/mybook/cfg.tar.bz2 it appears to be correct. It stored all read/write properties and ownwer and permissions.
-rw-rw-r-- UserA/user 198 2006-01-23 10:43:08 home/cfg/gatxrpt.cfg
The command I am using to create the tar is
tar -cjpf /mnt/mybook/cfg.tar.bz2 /home/cfg
When I extract to /tmp using "tar -C /tmp -xjpvf cfg.tar.bz2" It appears to have worked. All file permissions were there. Yet when I do the same thing on the fat 32 drive no permissoins were saved. So I guess extracting to the Fat 32 filesystem may be the culprit.. I guess I will have to change my script extact to tmp then cp -frdp to get the files to the correct folder with correct permissions. Kind of a pain but at least I can script that out. Thanks for all your suggestions.
When you untar on a fat32 volume, permissions and ownership cannot be preserved as fat32 does not support those features of *NIX filesystems/
If you really want to do what you are trying to do, you need a *NIX filesystem on the USB drive. Do not use a journaled filesystem as USB does not support DMA access and the journal accesses will slow things down. ext2 is a good choice.
oh yes, if you extract the tar on a fat32 it really loose the owner and modes.
Extracting the files to /tmp and after that copying to the correct folder will work, but instead, you can extract the files to the right place in one single operation. There is no need to use an intermediate place unless you do some kind of filtering or any other operation on the files.
The best approach is to change to parent directory of the folder you want to create (or restore) a backup. As far I understand it is cfg on /home, right ?
The point of the USB is storage is it will take daily backups run via cron. In the even of a failure I use Clonezilla to restore my image then all I have to do is restore the last backup from the USB drive. I don't have the space on the host system to hold the backup. Nor is it a good idea. After all the point of a backup is in case the host fails. I plan on writing a script to loop through the key folders and export them by folder name to the USB drive. Tar with bzip2 seems to be the best way for compression. I'm not to worried about speed since it will run after hours via cron which is why I am using bzip2 over gzip.
something of the effect of this
export backup_date='date +%F'
if [[ ! -d /mnt/mybook/$backup-date ]];then
mkdir -p /mnt/mybook/$backup-date
for DIR in `find /home `
tar -cpjf /mnt/mybook/$Backup-date/$DIR.tar.bz2
Then reverse it for the restore. You get the point. Since the drives are not used in production yet I may take Neddy's point and format them as linux ext2. Just to be on the safe side and not risk loosing my key owners and permissions.
I'm sorry but I didn't get the point: Why do you need to restore the backup on usb disk ?
For sure it is fine to create a tar file on usb disk, there is no problem with this.
On restore you just need to extract the files directly on their original place, or am I missing something ?
For sure, as Neddy told us, you can format your usb disk as ext2, but my point is this is unnecessary. You can restore files directly to their original place. Do you known you can select just a few files to extract, you don't need to restore the whole thing ? Something like "cd /home; tar -xjvf /mnt/mybook/cfg.tar.bz2 cfg/folder-a/file1 cfg/folder-b/file2 cfg/folder-c" ...
marozsas I don't need to restore it to the usb. The problem was I need the usb to hold it. I plan on extacting it from the USB to the host system. I will attempt this again today and post the results later. Also I plan on restoring the whole tar file since this is in the event the system completely fails and I loose all data. Now if a user deletes a file they needed off the host then I can just manually restore that rather than all the data.
ok, I was confused because you told us you are in fact extracting to a fat32:
Originally Posted by z01krh
Yet when I do the same thing on the fat 32 drive no permissoins were saved. So I guess extracting to the Fat 32 filesystem may be the culprit.
and now you clarify:
Originally Posted by z01krh
... I don't need to restore it to the usb.
so, I was lost about what you really are doing....
Anyway, if you don't need to restore it to a fat32 filesystem, just to store the tar file on a fat32 filesystem, it is ok. You should not have any problem with this. You don't need to format your usb disk as ext2, as fat32 it is ok.
But this brings us back to the original situation you described in your first post, and I am not sure if your restore problem with owner/modes was solved or not.
The permissions and ownerships are properly preserved inside the tarball regardless of the filesystem the tarball is stored on. They are lost on untarring to any filesystem that does not support *NIX permissions. This has no effect on the content of the tarball.