Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Linux / UNIX: Use the dd command to create a 1GB size binary     - Linux Routine Task Scheduler (Linux)

- Linux excellent text editor (Markdown, LaTeX, MathJax) (Linux)

- Docker commonly used commands Description (Linux)

- Remote installation of Net-SNMP whole process (Linux)

- Linux Desktop allows exceptionally different launch applications (Linux)

- MongoDB Study Notes (1) - Install MongoDB on Windows systems (Database)

- Oriented C ++ test-driven development (Programming)

- Build a Linux development environment under STC89C52RC (Linux)

- Python extension module Ganglia 3.1.x (Linux)

- How to Install Xombrero 1.6.4 (minimalist Web browser) on Ubuntu and Archlinux (Linux)

- Customize own small private Linux system (Linux)

- Comparison of sorting algorithms (Programming)

- Linux process or thread is bound to a CPU (Programming)

- Linux command Detailed chpasswd bulk edit user password (Linux)

- Preview function to confirm the stop resource Oracle 12c new feature crsctl (Database)

- Linux (Debian) install software, missing dynamic link libraries .so (Linux)

- A key installation Gitlab 7 on RHEL6.4 and Setup Mail TX (Linux)

- MySQL backup tool to back up mydumper (Database)

- Denyhosts prevent hackers using SSH scanning (Linux)

- Use HttpClient remote interface testing (Programming)

 
         
  Linux / UNIX: Use the dd command to create a 1GB size binary
     
  Add Date : 2017-08-31      
         
         
         
  How do I use the Shell command to create a 1GB or 10GB image file using the dd command on UNIX / Linux / BSD systems?

You can use the dd command to generate the image file, used to test network or file system.

You need to use the following command:

fallocate - pre-assigned blank documents;
truncate - narrow or expand the size of the file;
dd - convert and copy a file, such as cloning, new, covering the mirror;
df - View disk space;
du - disk usage statistics;
ls - list the file size;
fallocate command syntax

The basic syntax is:

fallocate -l Image_Size_Here /path/to/image.img

Use fallocate command to create large files on Linux

Create a 1GB file with the following command:
fallocate -l 1G test.img

Use the ls command to view File Size:

$ Ls -lh test.img

Sample output:
-rw-r - r-- 1 root root 1.0G Nov 27 03:42 test.img.

You can use the stat command to view or du block allocation information:
stat test.img
  File: `test.img '
  Size: 1073741824 Blocks: 2097160 IO Block: 4096 regular file
Device: 805h / 2053d Inode: 9043983 Links: 1
Access: (0644 / -rw-r - r--) Uid: (0 / root) Gid: (0 / root)
Access: 2013-11-27 03: 42: 27.575841698 -0600
Modify: 2013-11-27 03: 42: 27.575841698 -0600
Change: 2013-11-27 03: 51: 06.108962462 -0600
du -h test.img
1048580 test.img

Create 100M size of the file, press Return:

fallocate -l 100M file.out

-l parameter to specify when the back of the file size in bytes, such as k, m, g, t, p, e, respectively KiB, MiB, GiB, TiB, PiB, EiB.

dd command syntax

Note: The following information exists only on older versions of Linux commands are not available or when fallocate system. If possible, try to use fallocate command to create a binary image file. dd command is considered to be old and not recommended, but here only for historical reasons.

The basic syntax:

dd if = / path / to / input of = / path / to / output [options]
 OR
dd if = / dev / zero of = / path / to / output.img [options]
 OR
dd if = / dev / zero of = YOUR-IMAGE-FILE-NAME-HERE bs = 1 count = 0 seek = Size-HERE

Create a mirror using the dd command:

First, make sure there is enough disk space to store the file dd created:

$ Df -H

Create a 1MB file, and press Enter:

$ Dd if = / dev / zero of = test.img bs = 1024 count = 0 seek = 1024

You will get an empty file (also known as "sparse files"). Create a 10M file, press Enter:

$ Dd if = / dev / zero of = test.img bs = 1024 count = 0 seek = $ [1024 * 10]

Create a 100M file, press Enter:

$ Dd if = / dev / zero of = test.img bs = 1024 count = 0 seek = $ [1024 * 100]
 $ Ls -lh test.img

Create a 1GB file:

$ Dd if = / dev / zero of = 1g.img bs = 1 count = 0 seek = 1G
Sample output: 0 + 0 records in
0 + 0 records out
0 bytes (0 B) copied, 0.000235686 s, 0.0 kB / s

Verify that the file size (the role of attention bs parameter):

$ Ls -lh 1g.img
 $ Stat 1g.img
 $ Du -h 1g.im

dd Tip: Unix or Linux to specify the size of the new file

If truncate command is unavailable, try the following syntax:
dd if = / dev / zero of = / path / to / fiie.img bs = YOUR-FILE-SIZE-HERE count = 1

In this example, create a 1GB file size (1g in use * BSD / OS X):

$ Dd if = / dev / zero of = 1g.bin bs = 1G count = 1
Sample output: 1 + 0 records in
1 + 0 records out
1073741824 bytes (1.1 GB) copied, 8.12307 s, 132 MB / s

Confirm File size:

$ Stat 1g.bin

Sample output: File: `1g.bin '
  Size: 1073741824 Blocks: 2097152 IO Block: 4096 regular file
Device: 805h / 2053d Inode: 9043988 Links: 1
Access: (0644 / -rw-r - r--) Uid: (0 / root) Gid: (0 / root)
Access: 2013-11-27 04: 15: 02.962662890 -0600
Modify: 2013-11-27 04: 15: 03.769673943 -0600
Change: 2013-11-27 04: 15: 03.769673943 -0600
     
         
         
         
  More:      
 
- Using Linux command line and execute PHP code (Programming)
- Linux System Getting Started Tutorial: How to update outdated version of Ubuntu (Linux)
- HTTPS Encryption Algorithm (Linux)
- How LUKS encrypted disk / partition to perform remote incremental backup (Linux)
- Memcached and Redis (Linux)
- Zorin OS: Linux novice most personal desktop system should be used (Linux)
- To remove those IP is prohibited Fail2ban on CentOS 6/7 (Server)
- CentOS 6.5 Linux System Customization and Packaging Quick Implementation Script (Linux)
- ORA-04091 and Compound Trigger (Oracle 11g) (Database)
- Getting Started with Linux system to learn: how to use tcpdump to capture TCP SYN, ACK and FIN packets (Linux)
- OpenStack image production in the CentOS 6.2 (Linux)
- CentOS 6.5 installation using a data recovery software extundelete (Linux)
- Ubuntu 14.04 Nvidia proprietary drivers for install two graphic cards (Linux)
- 10 important Linux ps command combat (Linux)
- Easy to install Ubuntu 15.04 and Ubuntu 15.04 GNOME on Wayland trial (Linux)
- CoreOS quick installation to get started on a PC (Linux)
- Git delete files (Linux)
- Win7 used Eclipse to connect the virtual machine in Ubuntu Hadoop2.4 (Server)
- Install Java JDK 8 in CentOS 7 / 6.5 / 6.4 (Linux)
- RedHat virtual machine to install VMware Tools (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.