LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how split file to multiple vol and how restore it with request of inserting next vol? (http://www.linuxquestions.org/questions/linux-newbie-8/how-split-file-to-multiple-vol-and-how-restore-it-with-request-of-inserting-next-vol-704520/)

digitalblade 02-13-2009 06:31 PM

how split file to multiple vol and how restore it with request of inserting next vol?
 
Hi,

I'm not so new to Linux but I've a (probably) silly question :)
i need to split a big file into some volume, this can be done with split command, but how can i request the next volume on restore when the user try to rebuild original file?
This is needed because the volumes are divided on some dvd and can't be copied all together when is need a restore.

sorry for my really bad English :) i hope that my request is sufficiently clear

TIA for all reply

servat78 02-13-2009 06:43 PM

The 'split' command will segment your file into smaller files that can be listed alphabetically in the correct order.
Running something like below (assuming 'splitfile' as the prefix when doing the split):
cat splitfile* > fullfile
will create file 'fullfile' with all the parts assembled.

Debian

i92guboj 02-13-2009 06:48 PM

Quote:

Originally Posted by digitalblade (Post 3442805)
This is needed because the volumes are divided on some dvd and can't be copied all together when is need a restore.

You only need to copy the first file. After that, you can use >> to append the rest of the files.

Code:

#insert first dvd, mount it
cp /mnt/dvd/part1 /path/to/dest
#umount dvd 1, insert dvd 2 and mount it
cat /mnt/dvd/part2 >> /path/to/dest
# and so on


digitalblade 02-13-2009 06:50 PM

Quote:

Originally Posted by servat78 (Post 3442813)
The 'split' command will segment your file into smaller files that can be listed alphabetically in the correct order.
Running something like below (assuming 'splitfile' as the prefix when doing the split):
cat splitfile* > fullfile
will create file 'fullfile' with all the parts assembled.

Thank you for your reply, but you solution can't be used if, as i explain, all volumes are divided on multiple supports that require support change (like dvd).
I've already tried the split command, but i can't understand how can i obtain a request for next volume when the file is rebuild.


Bye

P.s. i want use only open source / free solution. I already know that some apps ike winrar can build multiple volume but is not free/opensource

jschiwal 02-13-2009 06:52 PM

Because the person will be ejecting and inserting DVD's it can be tricky.

If you have an external drive you can copy the slices to, it would be easy. Copy them into a directory and then cat them together to the destination or piped into dd.

If you don't have the space on another filesystem, you need to use a fifo pipe. One gotcha is that writing to a device (e.g. cat slice | dd of=/dev/sdc1) you don't have a filelength because there is no inode for a partition, hence no filelength.
Also, you can't simply cat each slice to the fifo file because when the file is ended on the DVD in the sending shell, the receiving shell will get an EOF and the fifo pipe will be closed.

I found out that you need to create one fifo pipe for each slice (or alternate two of them).

Look at post #5 in this LQ link. I tested out a way of doing it. The subject came up again.
http://www.linuxquestions.org/questi...t=fifo+cat+DVD
http://www.linuxquestions.org/questi...light=fifo+DVD

I don't remember for certain whether I tested it on an actual device. I think I did on a loop device.

---

A multivolume tar backup would probably work better. Suppose that disc 4 of 12 was damaged. You could still restore from discs 1-3 and 5 on.

---

Another way of doing it is to save the slice name, the offset and length in a catalog text file. Then use dd to restore the image slice using the offset from the catalog file. You could even include the offset and block count in the filename instead and then get the count and offset information from the filename. See the manpage for dd. There are options for blocksize, count and skip.

---

ps. I'm not home right now so I couldn't retest my idea. The posts I linked to originally were about assembling tar slices from DVD.

michaelk 02-13-2009 07:29 PM

How about the tar command? Here is an example:
http://www.base64.co.uk/splitting-large-files/

jschiwal 02-14-2009 02:29 AM

Update:
 
Update. I did test it out.

The trick is to pipe the stream to dd on the recieving end:
for file in fifo-00{0..7}; do
cat "$file"
done | dd of=/dev/loop2

You might try it with only one fifo device in a loop. That should work. In the past I was cat'ing to a file.
I was able to attach another loop device with a 63*512 offset and mount it as I did the original.

---

I kind of like my idea of using dd to write each slice at different offsets. You wouldn't need to use named pipes and could even restore the slices on the DVDs in any order. That would be less error prone.

digitalblade 02-14-2009 01:04 PM

thanks for all suggestion, i will try soon as possible and post my result!


thank you


All times are GMT -5. The time now is 06:40 PM.