shallow丿ovenode
dd if=/dev/zero of=/tmp/newdisk bs=1M count=100
dd命令是用於操做磁盤 if指定源設備 /dev/zero linux內核的造零器,是一個特殊設備,裏面有源源不斷的「0」 of指定目標設備(在這裏,咱們建立了一個文件,做爲一個模擬的設備) bs指定塊大小,1個塊爲1M count=100,100*1M=100Mlinux
[root@localhost mnt]# dd if=/dev/zero of=/tmp/newdisk bs=1M count=100 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 1.33107 s, 78.8 MB/s [root@localhost mnt]# du -sh /tmp/newdisk 100M /tmp/newdisk
[root@localhost mnt]# mkswap -f /tmp/newdisk Setting up swapspace version 1, size = 102396 KiB no label, UUID=7d807058-78e1-4b5f-af55-73f9ee19fe7a [root@localhost mnt]# free -m total used free shared buffers cached Mem: 1826 515 1311 8 126 189 -/+ buffers/cache: 199 1627 Swap: 2047 0 2047
[root@localhost mnt]# swapon /tmp/newdisk swapon: /tmp/newdisk: insecure permissions 0644, 0600 suggested. [root@localhost mnt]# free -m total used free shared buffers cached Mem: 1826 515 1311 8 126 189 -/+ buffers/cache: 199 1627 Swap: 2147 0 2147 [root@localhost mnt]# chmod 0600 /tmp/newdisk
[root@localhost mnt]# swapoff /tmp/newdisk [root@localhost mnt]# free -m total used free shared buffers cached Mem: 1826 515 1311 8 126 189 -/+ buffers/cache: 199 1627 Swap: 2047 0 2047 [root@localhost mnt]# rm -f /tmp/newdisk
[root@localhost ~]# dd if=/dev/zero of=/tmp/newdisk bs=1M count=1024 [root@localhost ~]# du -sh /tmp/newdisk [root@localhost ~]# ls -lh /tmp/newdisk [root@localhost ~]# mkfs.ext4 /tmp/newdisk mke2fs 1.42.9 (28-Dec-2013) /tmp/newdisk is not a block special device. Proceed anyway? (y,n) y Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 65536 inodes, 262144 blocks 13107 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=268435456 8 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done [root@localhost ~]# du -sh /tmp/newdisk [root@localhost ~]# ls -lh /tmp/newdisk