LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 02-22-2008, 06:53 PM   #1
xhimi
Member
 
Registered: Aug 2007
Posts: 30

Rep: Reputation: 15
Post cut up a big tar file


I need to know : How can cut up (fragment) a large tar file in the bset way (without data corruption) with my redhat 7.3 commands. For example I have a 3.2GB tar file and I want to cut up in 2 pieces smaller than
2GB and not equal size.thanks

p.s I read for split(not supported by my OS),cat command but how can I?
 
Old 02-22-2008, 07:23 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
You can use the split program to do that. I imagine you will be saving the slices on an external drive with the fat32 file system. You can restore files from a split archive be cat'ing the pieces together and piping the output to the input of tar:
example:
cat /media/usbdrive/archive.tar.* | tar xvf - /home/username/Documents/docfile.pdf
 
Old 02-22-2008, 07:40 PM   #3
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
you may be able to accomplish this with 'dd'.

myfile.tar == 688MB
to break it, first part 400MB, second part remaining (288MB)
Code:
dd if=myfile.tar of=myfile.tar.dd.1 bs=4096 count=102400
dd if=myfile.tar of=myfile.tar.dd.2 bs=4096 skip=102400
then to construct the single .tar again
Code:
dd if=myfile.tar.dd.2 of=myfile.tar.dd.1 bs=4096 seek=102400
mv myfile.tar.dd.1 myfile-from-dd.tar
it'd be a good idea to have a SUM for the original (md5sum, sha1sum, ...) to make sure it matches after you put the parts back together.


in my example (and test) it did
Code:
sha1sum myfile.tar myfile-from-dd.tar
da6c69be653d619080566808d43eddff89185c6c  myfile.tar
da6c69be653d619080566808d43eddff89185c6c  myfile-from-dd.tar
and the files extracted successfully with 'tar xvf myfile-from-dd.tar' and their sums matched as well (as expected since the tar files were identical but just an extra level of checking )

you can look at the man page for more options and see what is happening but i think it may be do-able like this. You'll just want to take care not to lose or forget the values you used or it could get ugly...

also, for bs= i used the filesystem block-size as reported by dumpe2fs for the partition i was working with the files on; not sure if it will actually matter or not but was used for consistency.

hope this helps.
 
1 members found this post helpful.
Old 02-22-2008, 07:49 PM   #4
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 377Reputation: 377Reputation: 377Reputation: 377
Kinda weird that you don't have split, no?

In any case, I made a dd example like rayfordj, except I put the pieces back together with cat. I created a 200MB file using random data, then broke it into 50MB chunks.
Code:
win32sux@candystore:/tmp$ dd if=/dev/urandom of=example.img bs=1024 count=200000
200000+0 records in
200000+0 records out
204800000 bytes (205 MB) copied, 67.3338 seconds, 3.0 MB/s
win32sux@candystore:/tmp$ md5sum example.img 
98bf11ac03b6de0c10d547d0f40e8eb9  example.img
win32sux@candystore:/tmp$ dd if=example.img of=example-p1.img bs=1024 count=50000
50000+0 records in
50000+0 records out
51200000 bytes (51 MB) copied, 0.477237 seconds, 107 MB/s
win32sux@candystore:/tmp$ dd if=example.img of=example-p2.img bs=1024 count=50000 skip=50000
50000+0 records in
50000+0 records out
51200000 bytes (51 MB) copied, 0.51539 seconds, 99.3 MB/s
win32sux@candystore:/tmp$ dd if=example.img of=example-p3.img bs=1024 count=50000 skip=100000
50000+0 records in
50000+0 records out
51200000 bytes (51 MB) copied, 0.489401 seconds, 105 MB/s
win32sux@candystore:/tmp$ dd if=example.img of=example-p4.img bs=1024 count=50000 skip=150000
50000+0 records in
50000+0 records out
51200000 bytes (51 MB) copied, 0.81478 seconds, 62.8 MB/s
win32sux@candystore:/tmp$ cat example-p* > example-new.img
win32sux@candystore:/tmp$ md5sum example-new.img 
98bf11ac03b6de0c10d547d0f40e8eb9  example-new.img
win32sux@candystore:/tmp$
 
Old 02-22-2008, 08:34 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
The split & dd commands are both supplied by the coreutils package. RH 7.3 is so old you might consider a fresh install of a newer distro. You are 10 major versions behind.
 
Old 02-23-2008, 05:04 AM   #6
xhimi
Member
 
Registered: Aug 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jschiwal View Post
The split & dd commands are both supplied by the coreutils package. RH 7.3 is so old you might consider a fresh install of a newer distro. You are 10 major versions behind.
yes jschiwal,you are right but I can not change my server right now,it has very services builded. actually I work with fedora 6 and RHEL5.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot tar a big size file shipon_97 Linux - Newbie 3 11-18-2007 11:26 PM
LXer: Linux certification costs take big cut LXer Syndicated Linux News 0 11-07-2007 01:50 AM
How to cut a big file into pieces of a certain size? kornerr Linux - General 9 12-31-2005 04:52 PM
How big a tar file that Linux can handle ? FrancisWong Linux - General 1 11-16-2005 03:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration