Difference between revisions of "Dd linux commands"

From Knowledge Center
Jump to: navigation, search
(Created page with "'''Create 2GB Swap Space:''' Create the space and format it to be swap: <pre> $ dd if=/dev/zero of=/root/2g.swap bs=2M count=1024 $ chmod 600 /root/2g.swap $ chown root:root...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
dd linux commands
 +
 
'''Create 2GB Swap Space:'''
 
'''Create 2GB Swap Space:'''
  
Line 39: Line 41:
 
<pre>
 
<pre>
 
$ echo '/dev/loop2  /new ext4  defaults  0 0' >> /etc/fstab
 
$ echo '/dev/loop2  /new ext4  defaults  0 0' >> /etc/fstab
 +
</pre>
 +
 +
'''Format a RaspberryPi with Hypriot:'''
 +
 +
<pre>
 +
$ lsblk
 +
$ sudo umount /dev/sdb1
 +
$ wget https://github.com/hypriot/image-builder-rpi/releases/download/v1.8.0/hypriotos-rpi-v1.8.0.img.zip
 +
$ unzip hypriotos-rpi-v1.8.0.img.zip
 +
$ sudo dd bs=4M if=hypriotos-rpi-v1.8.0.img of=/dev/sdb conv=fsync
 
</pre>
 
</pre>
  
Line 82: Line 94:
 
* http://www.techrepublic.com/blog/linux-and-open-source/create-encrypted-loopback-filesystems-on-linux/
 
* http://www.techrepublic.com/blog/linux-and-open-source/create-encrypted-loopback-filesystems-on-linux/
  
 +
[[Category:All]]
 
[[Category:Linux]]
 
[[Category:Linux]]
 
[[Category:Sysadmin]]
 
[[Category:Sysadmin]]

Latest revision as of 14:02, 16 April 2018

dd linux commands

Create 2GB Swap Space:

Create the space and format it to be swap:

$ dd if=/dev/zero of=/root/2g.swap bs=2M count=1024
$ chmod 600 /root/2g.swap
$ chown root:root /root/2g.swap
$ mkswap /root/2g.swap
$ swapon /root/2g.swap

Add to fstab:

$ echo '/root/2g.swap	none	swap	sw	0	0' >> /etc/fstab

Create a 1GB File for a Mountable Partition:

$ dd if=/dev/zero of=/opt/disk/1g.blob bs=1M count=1024
$ mkfs.ext4 /opt/disk/1g.blob
$ mkdir /new
$ mount /opt/disk/1g.blob /new

Verify that the disk is mounted:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1       20G   15G  4.8G  76% /
/dev/loop2      976M  1.3M  908M   1% /new

Add to fstab:

$ echo '/dev/loop2   /new ext4  defaults  0 0' >> /etc/fstab

Format a RaspberryPi with Hypriot:

$ lsblk
$ sudo umount /dev/sdb1
$ wget https://github.com/hypriot/image-builder-rpi/releases/download/v1.8.0/hypriotos-rpi-v1.8.0.img.zip
$ unzip hypriotos-rpi-v1.8.0.img.zip
$ sudo dd bs=4M if=hypriotos-rpi-v1.8.0.img of=/dev/sdb conv=fsync

Another Method using dd:

$ dd if=/dev/zero of=/opt/a.img bs=1024 count=0 seek=$[1000*1000]
$ losetup /dev/loop9 /opt/a.img

List the block devices:

$ lsblk
NAME                       MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda                       202:0    0    20G  0 disk
└─xvda1                    202:1    0    20G  0 part /
loop9                        7:9    0 976.6M  0 loop

Create the fs and mount:

$ mkfs.ext4 -L storage /dev/loop9
$ mkdir /mnt/data2
$ mount /dev/loop9 /mnt/data2

View block devices with mountpoint info

$ lsblk -o NAME,FSTYPE,LABEL,UUID,MOUNTPOINT
NAME                       FSTYPE LABEL   UUID                                 MOUNTPOINT
xvda
└─xvda1                    ext4   /       73947a77-ddbe-4dc7-bd8f-3fe0bc840778 /
loop9                      ext4   storage a97620b6-6f5e-4913-92d9-273ef610bb1a /mnt/data2


Related: