Format a disk
cat /etc/filesystems View the file systems supported by centos7
[root@glinux-01 ~]# cat /etc/filesystems
xfs //根和boot都是xfs
ext4
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus
*
Use the monut command to view the file system of the partition, mainly to see /dev
Formatting command - mke2fs
Options
-t specifies the format type mke2fs -t xfs (specifies the format as xfs)
-b specifies the block size (the default is 4K) -b 1024 or 2048 exponential growth (the block size is set according to the purpose of the file system, if it is a small file, set a small block, and if the file is large, set a large block)
-m reserve space (-m 1)
-i Set the size of the inode, how many blocks correspond to 1 inode, the default is 4 blocks, 16k
mke2fs -t xfs /dev/sdb1 can not format the partition as xfs need to use mkfs.ext4 === mke2fs -t ext4 this method
mkfs.ext4 supports mke2fs options, but mkfs.xfs does not
Question: How to set the options of mkfs.xfs? ? ?
[root@glinux-01 ~]# mke2fs -t xfs /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Your mke2fs.conf file does not define the xfs filesystem type.
Aborting...
[root@glinux-01 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
第一个数据块=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, 294912
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
mkfs.xfs -f /dev/sdb1 format the partition as xfs
[root@glinux-01 ~]# mkfs.xfs -f /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
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
At this time, if you want to view the partition format, you cannot use mount, because it has not been mounted yet, you can use blkid to view it.
[root@glinux-01 ~]# blkid /dev/sdb1
/dev/sdb1: UUID="9dd8655a-2f00-4203-83ca-15fadc0e1601" TYPE="xfs"
Two disk mounts
To be able to write data to the disk, it must be mounted first (equivalent to setting a directory for the disk)
Disk mount command mount [partition] [mount point]
Usage: mount /dev/sdb1 /mnt
[root@glinux-01 ~]# mount /dev/sdb1/ /mnt
[root@glinux-01 ~]# df
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda3 23899752 1027544 22872208 5% /
devtmpfs 365196 0 365196 0% /dev
tmpfs 375052 0 375052 0% /dev/shm
tmpfs 375052 5324 369728 2% /run
tmpfs 375052 0 375052 0% /sys/fs/cgroup
/dev/sda1 201380 99180 102200 50% /boot
tmpfs 75012 0 75012 0% /run/user/0
/dev/sdb1 2086912 32944 2053968 2% /mnt //挂在成功
Unmount umount (umount /dev/sdb1 or umount /mnt)
[root@glinux-01 ~]# umount /dev/sdb1
[root@glinux-01 ~]# df
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda3 23899752 1027544 22872208 5% /
devtmpfs 365196 0 365196 0% /dev
tmpfs 375052 0 375052 0% /dev/shm
tmpfs 375052 5324 369728 2% /run
tmpfs 375052 0 375052 0% /sys/fs/cgroup
/dev/sda1 201380 99180 102200 50% /boot
tmpfs 75012 0 75012 0% /run/user/0
Remount mount -o remonut,rw /dev/foo /dir
The first method: vim /etc/fstab directly writes the relevant mount information directly into the file mount -a will automatically
load all the configurations of the configuration file
mount -o noatime,rw /dev/sdb1 /mnt use -o specifies some options, if not specified, it is defaults
mount to see which related options are loaded
# /etc/fstab
# Created by anaconda on Tue Jul 26 20:11:16 2016
#
# 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
#第一段 第二段 第三段 第四段 第5段 第六段
#设备分区名或UUID 挂载点 系统文件类型 挂在选项 是否数据备份 开机是否检测磁盘
#defaults=rw,suid,dev,exec,auto,nouser,asyc
UUID=72cb5a39-c73a-466d-9207-5ef7ece5fd0d / ext4 defaults 1 1
UUID=51abe72d-14e4-4ab6-86df-fe446bb58487 /boot ext4 defaults 1 2
UUID=ed7b2cfc-cfa3-4993-b8a6-b04eb14f74f6 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
After writing the configuration file /etc/fstab, mount -a
-a will mount all partitions in /etc/fstab
The second method: vim /etc/rc.local What settings will be loaded at other startups?
You can directly write the mount /dev/sdb5 /mnt/ command to the /etc/rc.local file, and the file will automatically execute the command to mount when the system is restarted .
blkid gets the uuid and table of the partition
3. Manually increase the swap space
If the virtual memory is not enough, you must add a virtual disk. The basic idea of adding a virtual disk:
Create swap space -> format as swap -> enable the virtual disk
-
Create swap space
dd if=/dev/zero of=/tmp/newdisk bs=1M count=100
dd command: operate the disk; if specifies the source (usually writing /dev/zero, which is a file unique to UNIX systems, it can provide "0" continuously) of specifies the target file, bs defines the block size, and count defines the block The two parameters, bs and count, determine the size of the target file, and the size of the target file = bs*count.
[root@glinux-01 ~]# dd if=/dev/zero of=/tmp/newdisk bs=1M count=100
记录了100+0 的读入
记录了100+0 的写出
104857600字节(105 MB)已复制,4.11626 秒,25.5 MB/秒
- formatted as swap
mkswap -f /tmp/newdisk
[root@glinux-01 ~]# mkswap -f /tmp/newdisk
正在设置交换空间版本 1,大小 = 102396 KiB
无标签,UUID=f23d59a3-0dd6-45ef-bd71-64e42cbb23a3
- enable the virtual disk
swapon /tmp/newdisk
Check the swap space with the free -m command
Uninstall swap with swapoff /tmp/newdisk