磁盘格式化,磁盘挂载,手动增加swap空间
生活随笔
收集整理的這篇文章主要介紹了
磁盘格式化,磁盘挂载,手动增加swap空间
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
磁盤格式化
-
首先看一下CentOS7支持那些磁盤格式:cat /etc/filesystems
-
xfs是centOS7的默認(rèn)文件系統(tǒng)。在centOS6以及以前的系統(tǒng)使用的是ext的文件系統(tǒng)
-
可以用 mount 命令查看目前磁盤的文件系統(tǒng)
-
磁盤格式化命令:mke2fs, mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.xfs
這幾個(gè)命令的作用都是一樣的。mke2fs -t ext2/3/4等于mkfs.ext2, mkfs.ext3, mkfs.ext4, 如果想格成xfs格式只能用mkfs.xfs來格,系統(tǒng)不支持mke2fs -t xfs。
-
mke2fs 用法
-t :指定文件系統(tǒng)類型。
-b :分區(qū)時(shí)設(shè)定塊大小。可以后面跟指定 1024B ,2048B,4096B
[root@localhost ~]# mke2fs -b 8192 /dev/sdb1 Warning: blocksize 8192 not usable on most systems. mke2fs 1.42.9 (28-Dec-2013) mke2fs: 8192-byte blocks too big for system (max 4096) 無論如何也要繼續(xù)? (y,n) y Warning: 8192-byte blocks too big for system (max 4096), forced to continue warning: 32 blocks unused.文件系統(tǒng)標(biāo)簽= OS type: Linux 塊大小=8192 (log=3) 分塊大小=8192 (log=3) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 262112 blocks 13105 blocks (5.00%) reserved for the super user 第一個(gè)數(shù)據(jù)塊=0 Maximum filesystem blocks=268402688 4 block groups 65528 blocks per group, 65528 fragments per group 32768 inodes per group Superblock backups stored on blocks: 65528, 196584Allocating group tables: 完成 正在寫入inode表: 完成 Writing superblocks and filesystem accounting information: 完成-m : 更改磁盤預(yù)留boot空間大小(一般默認(rèn)預(yù)留5%,磁盤空間越大,越浪費(fèi))
[root@localhost ~]# mke2fs -m 0.1 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) 文件系統(tǒng)標(biāo)簽= OS type: Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 131072 inodes, 524288 blocks 524 blocks (0.10%) reserved for the super user 第一個(gè)數(shù)據(jù)塊=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Allocating group tables: 完成 正在寫入inode表: 完成 Writing superblocks and filesystem accounting information: 完成 [root@localhost ~]#-i : 指定"字節(jié)/inode"的比例
[root@localhost ~]# mke2fs -i 8192 -t ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) 文件系統(tǒng)標(biāo)簽= OS type: Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 262144 inodes, 524288 blocks 26214 blocks (5.00%) reserved for the super user 第一個(gè)數(shù)據(jù)塊=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912Allocating group tables: 完成 正在寫入inode表: 完成 Creating journal (16384 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 [root@localhost ~]#-
mkfs.xfs 沒用什么特殊用法,后面直接跟分區(qū)就可以了。
-
blkid 查看還沒有掛載的磁盤,查看UUID
磁盤掛載
-
mount /dev/sdb 掛載點(diǎn)
[root@localhost ~]# df -h 文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn) /dev/sda3 18G 1.1G 17G 7% / devtmpfs 479M 0 479M 0% /dev tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 6.7M 482M 2% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 98M 0 98M 0% /run/user/0 [root@localhost ~]# mount /dev/sdb /mut/ mount: 掛載點(diǎn) /mut/ 不存在 [root@localhost ~]# mount /dev/sdb /mnt/ mount: /dev/sdb 寫保護(hù),將以只讀方式掛載 mount: 未知的文件系統(tǒng)類型“(null)” [root@localhost ~]# mount /dev/sdb1 /mnt/ [root@localhost ~]# df -h 文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn) /dev/sda3 18G 1.1G 17G 7% / devtmpfs 479M 0 479M 0% /dev tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 6.7M 482M 2% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 98M 0 98M 0% /run/user/0 /dev/sdb1 1.9G 6.0M 1.8G 1% /mnt [root@localhost ~]# [root@localhost ~]# mount sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel) proc on /proc type proc (rw,nosuid,nodev,noexec,relatime) devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=490164k,nr_inodes=122541,mode=755) securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel) devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000) tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755) tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,seclabel,mode=755) cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd) pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime) cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset) cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices) cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu) cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory) cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids) cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb) cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer) cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event) cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls) cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio) configfs on /sys/kernel/config type configfs (rw,relatime) /dev/sda3 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota) selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime) systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct) mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel) hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel) debugfs on /sys/kernel/debug type debugfs (rw,relatime) /dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota) tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,seclabel,size=99996k,mode=700) /dev/sdb1 on /mnt type ext4 (rw,relatime,seclabel,data=ordered) [root@localhost ~]# -
卸載掛載 umount
如果提示目標(biāo)忙,加 -l 參數(shù)
-
mount 選項(xiàng)
- mount -t 類型 -o 掛接方式 源路徑 目標(biāo)路徑
-
- ro : 表示按只讀掛在權(quán)限
-
- rw :表示按可讀可寫權(quán)限掛載
-
- async/sync : async表示與磁盤和內(nèi)存不同步,系統(tǒng)每隔一段時(shí)間就會(huì)把內(nèi)存數(shù)據(jù)寫入磁盤中,而sync則會(huì)時(shí)時(shí)同步內(nèi)存和磁盤中的數(shù)據(jù)。
-
- t : 指定分區(qū)類型
-
- user/nouser : 表示允許/不允許root外其他的用戶掛載分區(qū),為了安全,使用nouser。
-
vi /etc/fstab 這個(gè)文件是系統(tǒng)啟動(dòng)都掛載了那些磁盤,都寫在這個(gè)配置文件里里面。
可以自己添加。
手動(dòng)增加swap空間
- 首先虛擬一些空間
dd :是用來操作磁盤的
if :指定去哪里讀
/dev/zero :linux可以調(diào)用無限大的zero
of : 寫入到哪里去
bs : 塊大小
count=100 : 就是100個(gè)塊
[root@localhost ~]# du -sh /tmp/newdisk 100M /tmp/newdisk- 用mkswap格式化
- 之后把空間加到swap里面
先查看swap空間大小
swapon /tmp/newdisk 把空間加載到現(xiàn)有磁盤空間去
[root@localhost ~]# swapon /tmp/newdisk swapon: /tmp/newdisk:不安全的權(quán)限 0644,建議使用 0600。 [root@localhost ~]# free -mtotal used free shared buff/cache available Mem: 976 108 603 6 264 690 Swap: 2147 0 2147 [root@localhost ~]#swapoff /tmp/newdisk 把空間卸載掉
[root@localhost ~]# swapoff /tmp/newdisk [root@localhost ~]# free -mtotal used free shared buff/cache available Mem: 976 108 603 6 264 690 Swap: 2047 0 2047轉(zhuǎn)載于:https://blog.51cto.com/11751505/2096729
總結(jié)
以上是生活随笔為你收集整理的磁盘格式化,磁盘挂载,手动增加swap空间的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 搜索题目集合
- 下一篇: byte 和16进制关系