LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cut up a big tar file (https://www.linuxquestions.org/questions/linux-newbie-8/cut-up-a-big-tar-file-623159/)

xhimi 02-22-2008 05:53 PM

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?

jschiwal 02-22-2008 06:23 PM

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

rayfordj 02-22-2008 06:40 PM

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.

win32sux 02-22-2008 06:49 PM

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$


jschiwal 02-22-2008 07:34 PM

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.

xhimi 02-23-2008 04:04 AM

Quote:

Originally Posted by jschiwal (Post 3066736)
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.


All times are GMT -5. The time now is 09:46 PM.