【CentOS 7笔记22】,手动增长Swap空间#171104

hellpasswdnode


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

mkswap格式化swap

[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

swapon挂载swap

[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

swapoff卸载swap

[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

【CentOS 7基础笔记20】,磁盘格式化
【CentOS 7基础笔记21】,磁盘挂载
【CentOS 7基础笔记22】,手动增长Swap空间
【CentOS 7基础笔记23】, Logical Volume Manager逻辑卷管理
【CentOS 7基础笔记24】,实验中发生的磁盘小故障ide

修改于 171104spa

相关文章
相关标签/搜索