LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-27-2018, 07:09 AM   #1
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,061

Rep: Reputation: 47
dd to sparse file?


I'd like to copy a part of normal fileA to a (already) sparse fileB :

Code:
dd if="fileA" of="fileB" bs=2k count=3 skip=2 seek=2
however, fileB looses its 'sparsity'. is there a way to do it?
thanks.

edit:
nevermind, I probably should have used 'oflag=append conv=notrunc'
anyway, ignore.

Last edited by qrange; 06-27-2018 at 07:23 AM.
 
Old 06-27-2018, 08:02 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,846

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
that will append to the [sparse] fileB, regardless of its original size and content. You cannot write into it this way. To write into that "sparse" area is another thing.
 
Old 06-27-2018, 09:36 AM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Include the "conv=sparse" option. That will cause dd to just seek over any all-zero blocks rather than copying the zeros, though I'm not sure what happens if fileA has an all-zero block at an offset where fileB has existing non-zero data. A literal reading of the dd manpage suggests that the non-zero data in fileB would remain. (I'm not quite motivated enough to test that.)

And BTW, you'll also need the "conv=notrunc" option if you want to preserve any existing part of fileB.

Last edited by rknichols; 06-27-2018 at 09:45 AM. Reason: add, "though I'm not sure..." and "BTW..."
 
1 members found this post helpful.
  


Reply



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
Sparse file issue with KVM david888 Linux - Software 7 11-09-2017 08:33 AM
Sparse file - convert it to normal tranphat Linux - Server 9 05-15-2017 02:55 AM
How to Create sparse file with alternate data and hole. mango7 Programming 4 10-13-2011 08:02 AM
sparse file vs. ramfs Skaperen Linux - Kernel 0 05-17-2011 05:02 PM
How to remove some blocks from a sparse file hpsmouse Programming 10 08-16-2009 08:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01: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
Open Source Consulting | Domain Registration