Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
create an empty file
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
SarahS93
Guru
Guru


Joined: 21 Nov 2013
Posts: 467

PostPosted: Sun May 05, 2019 9:52 am    Post subject: create an empty file Reply with quote

dd if=/dev/zero of=testfile bs=1024 count=16777216

dd if=/dev/zero of=testfile bs=1024M count=16

with both ways the file has the same size
are there any diffents with these two ways for creating an empty file?
(the second one is easyer to write, for me)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43178
Location: 56N 3W

PostPosted: Sun May 05, 2019 10:03 am    Post subject: Reply with quote

SarahS93,

Both produce the same results but the second way is faster.
You won't notice the difference using /dev/zero but you will with a HDD.
dd speeds up until the block size gets to about 1M
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7089
Location: Saint Amant, Acadiana

PostPosted: Sun May 05, 2019 10:05 am    Post subject: Reply with quote

Easiest yet: http://man7.org/linux/man-pages/man1/fallocate.1.html
Example:
Code:
fallocate -l 1G testfile

_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Sun May 05, 2019 11:48 am    Post subject: Reply with quote

It also depends why you create the file, /dev/zero for most fs means not creating the file content, but just allocating the space for it.
It's not clear what you seek, as a 1M byte fill of zeros is not an empty file, an empty file is a file with a 0 size.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 7089
Location: Saint Amant, Acadiana

PostPosted: Sun May 05, 2019 11:52 am    Post subject: Reply with quote

Right, to create an empty file use touch.
_________________
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum