格式化挂载手动增加swap
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了格式化挂载手动增加swap相关的知识,希望对你有一定的参考价值。
4.5 磁盘格式化
[[email protected] ~]# cat /etc/filesystems //查看分区支持的文件系统格式
ext4
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus
[[email protected] ~]# mount //查看分区的文件系统是什么(挂载之后才能看到)
/dev/sda3 on / type xfs (rw,relatime,attr2,inode64,noquota
/dev/sda1 on /boot type xfs
mke2fs
-t 表示你要格式化成什么系统()
-b 指定块大小
-m 预留空间给root
-i 多少字节对应一个inode
mkfs.ext4=====mke2fs -t ext4
[[email protected] ~]# mke2fs -t xfs -b 2048 /dev/sdb1 //还不支持xfs系统
mke2fs 1.42.9 (28-Dec-2013)
Your mke2fs.conf file does not define the xfs filesystem type.
Aborting...
[[email protected] ~]# mke2fs -t ext4 -b 2048 /dev/sdb1 //格式化成ext4文件系统 每块2k
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=2048 (log=1)
分块大小=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 1572864 blocks
78643 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=270008320
96 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[[email protected] ~]# mkfs.ext4 -b 2048 /dev/sdb1 //当系统存档的是比较大的文件、视频、音乐可以使用大点8kb
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=2048 (log=1)
分块大小=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 1572864 blocks
78643 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=270008320
96 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[[email protected] ~]# mkfs.xfs /dev/sdb1 //
mkfs.xfs: /dev/sdb1 appears to contain an existing filesystem (ext4).
mkfs.xfs: Use the -f option to force overwrite.
[[email protected] ~]# mkfs.xfs -f /dev/sdb1 //强制覆盖(前面已经格式化过了)
meta-data=/dev/sdb1 isize=256 agcount=4, agsize=196608 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=786432, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[[email protected] ~]# blkid /dev/sdb1 //查看一个未挂载的分区文件系统(UUID)
/dev/sdb1: UUID="ac545dff-22fb-4fd6-8f76-d238fc6c1b72" TYPE="xfs"
[[email protected] ~]# mke2fs -t ext4 -b 2046 -m 1 /dev/sdb1 ///===mkfs.ext4 -m 1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=1024 (log=0)
分块大小=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 3145728 blocks
31457 blocks (1.00%) reserved for the super user
[[email protected] ~]# mke2fs -t ext4 -i 8192 -m 1 /dev/sdb1 //多少字节对应一个inode
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
393216 inodes, 786432 blocks //2块对应一个inode 1:2
7864 blocks (1.00%) reserved for the super user
第一个数据块=0
没有分区也可以直接格式化
4.7 磁盘挂载
[[email protected] ~]# fdisk -l
[[email protected] ~]# blkid /dev/sdb1
/dev/sdb1: UUID="46ff014e-bb84-4d45-8c1f-a578e41cdea7" TYPE="ext4"
[[email protected] ~]# mount UUID="46ff014e-bb84-4d45-8c1f-a578e41cdea7" /mnt
[[email protected] ~]# mount /dev/sdb1 /mnt/ //挂载
[[email protected] ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda3 11G 916M 9.8G 9% /
devtmpfs 260M 0 260M 0% /dev
tmpfs 265M 0 265M 0% /dev/shm
tmpfs 265M 4.4M 261M 2% /run
tmpfs 265M 0 265M 0% /sys/fs/cgroup
/dev/sda1 197M 75M 123M 38% /boot
/dev/sdb1 2.9G 9.0M 2.8G 1% /mnt
[[email protected] ~]# mount
/dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota)
/dev/sdb1 on /mnt type ext4 (rw,relatime,data=ordered)
[[email protected] mnt]# umount -l /dev/sdb1 //懒人卸载
Mount常用选项:不加选项默认defaults
Use default options: rw, suid, dev, exec, auto, nouser,and async.
Rw:可读写、
Suid:可设置uid权限、
Dev:省略
Exec:可执行权限
Auto:自动挂载
Nouser:不允许普通用户挂载
Async:不会实时同步
[[email protected] ~]# vi /etc/fstab //设置之后开机自动挂载
# /etc/fstab
# Created by anaconda on Sun Oct 15 14:36:08 2017
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#//第五列是否备份 0不备份 1备份 第六列设置自检 0不检测 1/2检测1比2优先级高些,1检测完在检测2
UUID=c54d7936-0b37-40bc-980f-7a4469bbe822 / xfs defaults 1 1
UUID=540025a9-8958-498f-98d6-35ac2a63b730 /boot xfs defaults 1 2
UUID=ca3fdb3f-6a65-4a04-ba4f-7e4c35c724c3 swap swap defaults 0 0
/dev/sdb1 /mnt ext4 defaults
[[email protected] ~]# man fstab
4.9 手动增加swap空间
dd操作磁盘的命令 if指定从哪里读 /dev/zero造零器 of将这些零写入到哪里去 count执行多少次
[[email protected] ~]# dd if=/dev/zero of=/tmp/newdisk bs=1M count=100
记录了100+0 的读入
记录了100+0 的写出
104857600字节(105 MB)已复制,5.9509 秒,17.6 MB/秒
[[email protected] ~]# du -sh /tmp/newdisk
100M/tmp/newdisk
[[email protected] ~]# mkswap -f /tmp/newdisk //格式化
正在设置交换空间版本 1,大小 = 102396 KiB
无标签,UUID=01555cf3-52eb-4aaf-afb4-5b5a0b88fcd9
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 529 306 223 4 0 173
-/+ buffers/cache: 131 397
Swap: 1199 0 1199
[[email protected] ~]# swapon /tmp/newdisk //挂载
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 529 306 223 4 0 173
-/+ buffers/cache: 131 397
Swap: 1299 0 1299
[[email protected] ~]# chmod 0600 /tmp/newdisk
[[email protected] ~]# swapoff /tmp/newdisk //卸载
[[email protected] ~]# free -m
total used free shared buffers cached
Mem: 529 306 223 4 0 173
-/+ buffers/cache: 131 397
Swap: 1199 0 1199
本文出自 “帕多克的痴迷” 博客,请务必保留此出处http://lsxme.blog.51cto.com/12400127/1978645
以上是关于格式化挂载手动增加swap的主要内容,如果未能解决你的问题,请参考以下文章