<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Dd</id>
	<title>Dd - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Dd"/>
	<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Dd&amp;action=history"/>
	<updated>2026-05-03T13:23:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://dikapediav2.com/wiki/index.php?title=Dd&amp;diff=51&amp;oldid=prev</id>
		<title>Ardika Sulistija: Created page with &quot;  &lt;b&gt;dd&lt;/b&gt; - convert and copy a file.   REALLY GOOD ARTICLE: https://www.computernetworkingnotes.com/linux-tutorials/generate-or-create-a-large-text-file-in-linux.html   ===How to use dd=== ----   This command will create a file of size &lt;b&gt;count*bs&lt;/b&gt;, in which the below will create a file of 1 MB:  dd if=/dev/zero of=file.txt count=1024 bs=1024  * &lt;b&gt;/dev/zero&lt;/b&gt; is a special file in Unix-like operating systems that provides as many null characters as are read from i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Dd&amp;diff=51&amp;oldid=prev"/>
		<updated>2024-08-21T14:46:48Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;  &amp;lt;b&amp;gt;dd&amp;lt;/b&amp;gt; - convert and copy a file.   REALLY GOOD ARTICLE: https://www.computernetworkingnotes.com/linux-tutorials/generate-or-create-a-large-text-file-in-linux.html   ===How to use dd=== ----   This command will create a file of size &amp;lt;b&amp;gt;count*bs&amp;lt;/b&amp;gt;, in which the below will create a file of 1 MB:  dd if=/dev/zero of=file.txt count=1024 bs=1024  * &amp;lt;b&amp;gt;/dev/zero&amp;lt;/b&amp;gt; is a special file in Unix-like operating systems that provides as many null characters as are read from i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;dd&amp;lt;/b&amp;gt; - convert and copy a file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
REALLY GOOD ARTICLE: https://www.computernetworkingnotes.com/linux-tutorials/generate-or-create-a-large-text-file-in-linux.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===How to use dd===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This command will create a file of size &amp;lt;b&amp;gt;count*bs&amp;lt;/b&amp;gt;, in which the below will create a file of 1 MB:&lt;br /&gt;
 dd if=/dev/zero of=file.txt count=1024 bs=1024&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;b&amp;gt;/dev/zero&amp;lt;/b&amp;gt; is a special file in Unix-like operating systems that provides as many null characters as are read from it. &lt;br /&gt;
* &amp;lt;b&amp;gt;if=FILE&amp;lt;/b&amp;gt; -- read from FILE instead of stdin&lt;br /&gt;
* &amp;lt;b&amp;gt;of=FILE&amp;lt;/b&amp;gt; -- write to FILE instead of stdout&lt;br /&gt;
* &amp;lt;b&amp;gt;count=N&amp;lt;/b&amp;gt; -- copy only N input blocks&lt;br /&gt;
* &amp;lt;b&amp;gt;bs=BYTES&amp;lt;/b&amp;gt; -- read and write up to BYTES bytes at a time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Generate FIles====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
This command will generate 1 GB file (where 1048576 bytes = 1MB): &lt;br /&gt;
 dd if=/dev/zero of=file.txt count=1024 bs=1048576&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When You Don’t Care About The Contents But Want Some Lines, as in, you don&amp;#039;t want it to just be full of nulls, you can use &amp;lt;b&amp;gt;/dev/urandom&amp;lt;/b&amp;gt;. This is a partner of /dev/random, which serves as a random number generator. Essentially /dev/random will eventually block unless your system has a lot of activity, &amp;lt;u&amp;gt;/dev/urandom in non-blocking&amp;lt;/u&amp;gt;. We don’t want blocking when we’re creating our files so we use /dev/urandom. The only real difference is that /dev/urandom is actually less random but for our purposes it is random enough.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This will create a file with bs*count random bytes, in our case 2048*10 = 20KB (20480 Bytes).&lt;br /&gt;
 dd if=/dev/urandom of=file.txt bs=2048 count=10&lt;br /&gt;
&lt;br /&gt;
To generate a 100Mb file we would do using /dev/urandom:&lt;br /&gt;
 dd if=/dev/urandom of=file.txt bs=1048576 count=100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====How to duplicate data from &amp;#039;source&amp;#039; to &amp;#039;destination&amp;#039; volume====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
(From k u m o 2666 Linux - Create HVM AMI from PV source instance)&lt;br /&gt;
2. Check the &amp;#039;source&amp;#039; volume and minimize the size of original filesystem to speed up the process. We do not want to copy free disk space in the next step.&lt;br /&gt;
 e2fsck -f /dev/xvdm&lt;br /&gt;
 resize2fs -M /dev/xvdm&lt;br /&gt;
 &lt;br /&gt;
 # Output from resize command:&lt;br /&gt;
 Resizing the filesystem on /dev/xvdm to 269020 (4k) blocks.&lt;br /&gt;
 The filesystem on /dev/xvdm is now 269020 blocks long.&lt;br /&gt;
&lt;br /&gt;
3. Duplicate &amp;#039;source&amp;#039; to &amp;#039;destination&amp;#039; volume.&lt;br /&gt;
 dd if=/dev/xvdm of=/dev/xvdo1 bs=4K count=269020&lt;br /&gt;
&lt;br /&gt;
4. Resize the filesystem on the &amp;#039;destination&amp;#039; volume after the transfer completed.&lt;br /&gt;
 resize2fs /dev/xvdo1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====How to initialize (or &amp;lt;b&amp;gt;pre-warm&amp;lt;/b&amp;gt;) an EBS volume restored from a snapshot====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;b&amp;gt;dd&amp;lt;/b&amp;gt; or &amp;lt;b&amp;gt;fio&amp;lt;/b&amp;gt; utilities to read all of the blocks on the device. The dd command is installed by default on Linux systems, but fio is considerably faster because it allows multi-threaded reads.&lt;br /&gt;
&lt;br /&gt;
* NOTE: This step may take several minutes up to several hours, depending on your EC2 instance bandwidth, the IOPS provisioned for the volume, and the size of the volume.&lt;br /&gt;
&lt;br /&gt;
# Run &amp;lt;b&amp;gt;lsblk&amp;lt;/b&amp;gt; to check the block device you want:&lt;br /&gt;
 $ lsblk&lt;br /&gt;
 NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINT&lt;br /&gt;
 nvme0n1       259:0    0  10G  0 disk&lt;br /&gt;
 ├─nvme0n1p1   259:1    0  10G  0 part /&lt;br /&gt;
 └─nvme0n1p128 259:2    0   1M  0 part&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;if (input file)&amp;lt;/b&amp;gt; parameter should be &amp;lt;u&amp;gt;set to the drive you wish to initialize&amp;lt;/u&amp;gt;. The of &amp;lt;b&amp;gt;(output file)&amp;lt;/b&amp;gt; parameter should be set to the Linux &amp;lt;b&amp;gt;null&amp;lt;/b&amp;gt; virtual device, &amp;lt;b&amp;gt;/dev/null&amp;lt;/b&amp;gt;. The &amp;lt;b&amp;gt;bs&amp;lt;/b&amp;gt; parameter sets the block size of the read operation; for optimal performance, this should be set to &amp;lt;b&amp;gt;1 MB&amp;lt;/b&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Incorrect use of dd can easily destroy a volume&amp;#039;s data. Be sure to follow precisely the example command below. Only the &amp;lt;b&amp;gt;if=/dev/xvdf&amp;lt;/b&amp;gt; parameter will vary depending on the name of the device you are reading.&lt;br /&gt;
 $ sudo dd if=/dev/xvdf of=/dev/null bs=1M&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the operation is finished, you will see a report of the read operation. Your volume is now ready for use. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Other methods besides DD====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
DD is not parallel, so there are other methods to create files much quicker than DD. Below is a process on how you can do so:&lt;br /&gt;
&lt;br /&gt;
1) Create ten thousand small files in your local storage on your instance.&lt;br /&gt;
 $ mkdir /tmp/efs; for each in $(seq 1 10000); do SUFFIX=$(mktemp -u EFS-XXXXXX); sudo dd if=/dev/zero of=/tmp/efs/${SUFFIX} bs=64k count=1; done&lt;br /&gt;
&lt;br /&gt;
2) To test copy the files from your instance to the EFS file system:&lt;br /&gt;
 Serial method: &lt;br /&gt;
 $ cd /tmp/efs; time sudo find -L . -maxdepth 1 -type f -exec rsync -aR &amp;#039;{}&amp;#039; /efs/ \;&lt;br /&gt;
 &lt;br /&gt;
 Parallel method: &lt;br /&gt;
 $ cd /tmp/efs; time find -L . -maxdepth 1 -type f | sudo parallel rsync -aR {} /efs/ &lt;br /&gt;
&lt;br /&gt;
3) To remove:&lt;br /&gt;
 Serial method: &lt;br /&gt;
 $ cd /mnt/efs; time sudo find -L . -maxdepth 1 -exec rm -rfv {} \;&lt;br /&gt;
 &lt;br /&gt;
 Parallel method: &lt;br /&gt;
 $ cd /mnt/efs; find -L . -maxdepth 1 -type f | sudo parallel rm -rfv {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
References:&amp;lt;/br&amp;gt;&lt;br /&gt;
[+] [https://skorks.com/2010/03/how-to-quickly-generate-a-large-file-on-the-command-line-with-linux/ How To Quickly Generate A Large File On The Command Line (With Linux)]&amp;lt;/br&amp;gt;&lt;br /&gt;
[+] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-initialize.html&lt;/div&gt;</summary>
		<author><name>Ardika Sulistija</name></author>
	</entry>
</feed>