Linux学习笔记-7. 文件系统管理

7.文件系统管理

 

 

7.1.分区和文件系统

 

 

1、 分区类型

a)    主分区:总共最多只能分4个。

b)    扩展分区:只能有一个,也算作主分区的一种,也就是说主分区加扩展分区最多有4个。但是扩展分区不能存储数据和格式化,必须再划分成逻辑分区才能使用。

c)   逻辑分区:逻辑分区是在扩展分区中划分的,如果IDE硬盘,Linux最多支持59个逻辑分区,如果是SCSI硬盘,Linux最多支持11个逻辑分区。

 

2、分区表示方法

 

 不能粘图片。。。

 

 

3、分区的设置文件名

 

分区

设备文件名

主分区1

/dev/sda1

主分区2

/dev/sda2

主分区3

/dev/sda3

扩展分区

/dev/sda4

逻辑分区1

/dev/sda5

逻辑分区2

/dev/sda6

逻辑分区3

/dev/sda7

 

 

 

 

 

 

通常情况,主分区只是1个,如下图所示:

 

不能粘图片。。。

 

 

分区

设备文件名

主分区1

/dev/sda1

扩展分区

/dev/sda2

逻辑分区1

/dev/sda5

逻辑分区2

/dev/sda6

逻辑分区3

/dev/sda7

 

 

1、文件系统

a)   ext2:是ext文件系统的升级版本,Red Hat Linux7.2版本以前的系统默认都是ext2文件系统。1993年发布,最大支持16TB的分区和最大2TB的文件。

b)    ext3ext3文件系统是ext2文件系统的升级版本,最大的区别就是带日志功能,以在系统突然停止时提高文件系统的可靠性。支持最大16TB的分区和最大2TB的文件。

c)  ext4ext4文件系统是ext3文件系统的升级版本。ext4在性能、伸缩性和可靠性方面进行了大量改进。ext4的变化可以说是翻天覆地的,比如向下兼容ext3、最大1EB文件系统和16TB的文件、无限数量子目录、Extents连续数据块概念、多块分配、延迟分配、持久预分配、书剑中FSCK、日志校验、无日志模式、在线碎片整理、inode增强、默认启用barrier等。是CentOS6.3的默认文件系统。

1EB=1024PB=1024*1024TB

 

 

 7.2.文件系统常用命令

 

7.2.1.df、du、fsck、dumpe2fs

 

 

 

1、  文件系统查看命令df

语法:

df [选项] [挂载点]

 

-a 显示所有的文件系统信息,包括特殊文件系统,如/proc/sysfs

-h 使用习惯单位显示容量,如KB,MB,GB

-T 显示文件系统类型

-m MB为单位显示容量

-k KB为单位显示容量。默认就是以KB为单位

 

 

2、统计目录或文件大小命令du

ls只能统计文件大小,只会统计目录下的文件名占用了多大空间,不是真正的空间大小。

 

语法:

du [选项] [目录或文件名]

 

-a 显示每个子文件的磁盘占用量。默认只统计子目录的磁盘占用量

-h 使用习惯单位显示容量,如KB,MB,GB

-s 统计总占用量,而不列出子目录和子文件的占用量。

 

 

3、du命令和df命令的区别

df命令看到的可用空间,才是真正可用的

a)   df命令是从文件系统考虑的,不光要考虑文件占用的空间,还要统计被命令或程序占用的空间,最常见的就是文件已经删除,但是程序并没有释放空间,导致空间被浪费了。

b)   du命令是面向文件的,只会计算文件或目录占用的空间。

 

 

4、文件修复系统命令fsck

语法:

fsck [选项] 分区设备文件名

 

-a 不用显示用户提示,自动修复文件系统

-y 自动修复。和-a使用一致,不过有些文件系统只支持-y

 

这个一般不需要手动执行,系统启动的时候会自动检测并修复。

手工修复一般会出问题,没修复之前可以用,修复之后又不能用了。慎用。

 

 

5、 显示磁盘状态命令dumpe2fs

dumpe2fs 分区设备文件

这个命令貌似只在ext文件系统中才有效,xfs文件系统貌似执行不了这个命令

 

 

 7.2.2.挂载命令

 

 

 

 

1、 查询与自动技巧

a)   查询系统中已经挂载的设备,-l会显示卷标名称

mount [-l]

b)      依据配置文件/etc/fstab内容,自动挂载

mount -a

2、 挂载命令格式

mount [-t 文件系统] [-L 卷标名] [-o 特殊选项] 设备文件名 挂载点

 

-t 文件系统:加入文件系统类型来指定挂载的类型,可以是ext3ext4iso9960等文件系统。

-L 卷标名:挂载指定卷标的分区,而不是安装设备文件名挂载

-o 特殊选项:可以指定挂载的额外选项

 

特殊选项表:

分区

设备文件名

atime/noatime

更新访问时间/不更新访问时间。访问分区文件时,是否更新文件的访问时间,默认为更新。

async/sync

异步/同步,默认为异步

auto/noauto

自动/手动,mount –a命令执行时,是否会自动安装/etc/fstab文件内容挂载,默认为自动

defaults

定义默认值,相当于rw,suid,dev,exec,auto,nouser,async这七个选项

exec/noexec

执行/不执行,设定是否允许在文件系统中执行可以执行文件,默认是exec允许

remount

重新挂载已经挂载的文件系统,一般用于指定修改特殊权限

rw/ro

读写/只读,文件系统挂载时,是否具有读写权限,默认是rw

suid/nosuid

具有/不具有SUID权限,设定文件系统是否具有SUIDSGID的权限,默认是具有

user/nouser

允许/不允许普通用户技巧,设定文件系统是否允许普通用户挂载,默认是不允许,只有root可以挂载分区

usrquota

写入代表 文件系统支持用户磁盘配额,默认不支持

grpquota

写入代表文件系统支持组磁盘配额,默认不支持

 

 

示例:

mount –o remount,noexec /home

重新挂载,不允许home分区执行可执行文件

 

通常情况下这些默认挂载参数不用修改的。

 

 

 

 7.2.3.挂载光盘与U盘

 

 

  

1、挂载光盘

a)     建立挂载点

mkdir /mnt/cdrom

b)    挂载光盘

mount –t iso9660 /dev/cdrom /mnt/cdrom

 

iso9660这个是固定的,可以省略;设备文件名/dev/cdrom,还有一个名字/dev/sr0,写哪个都可以

 

mount /dev/sr0 /mnt/cdrom

 

从如下命令可以看出,设备文件名/dev/cdrom是设备文件名/dev/sr0的软链接

[root@localhost ~]# ll /dev/cdrom

lrwxrwxrwx. 1 root root 3 May  1 18:41 /dev/cdrom -> sr0

 

 

2、卸载命令

umount 设备文件名或挂载点

 

卸载命令执行之前,当前目录不能在光盘目录下,否则卸载不了。

umount /dev/cdrom

 

3、 挂载U盘

a)        查看U盘的设备文件名

fdisk –l

 

b)  创建挂载点

mkdir /mnt/usb/

 

c)   挂载U

mount –t vfat /dev/sdb1 /mnt/usb/

 

Linux默认是不支持NTFS文件系统的,如果U盘是NTFS文件系统的,则识别不了

 

 

7.2.4.支持NTFS文件系统

 

 

  

1、下载NTFS-3G插件

 

2、  安装NTFS-3G插件

源码安装

 

3、挂载NTFS文件系统的设备

mount –t ntfs-3g 分区设备文件名 挂载点

 

 

 

 7.3.fdisk分区过程

 

 

 

 

1、添加新硬盘

方便做分区测试。

虚拟机,直接添加一块新的硬盘即可

2、查看新硬盘

fdisk –l

 

 

  

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0x000ad8e2

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200    41943039    19921920   8e  Linux LVM

 

Disk /dev/sdb: 10.7 GB, 1073741820 bytes, 2097152 sectors 

 Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

 

Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

 

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

 

 

 

1、 使用fdisk命令分区

fdisk /dev/sdb

 

[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0xba40d842.

 

The device presents a logical sector size that is smaller than

the physical sector size. Aligning to a physical sector (or optimal

I/O) size boundary is recommended, or performance may be impacted.

 

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   g   create a new empty GPT partition table

   G   create an IRIX (SGI) partition table

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

Command (m for help):

 

fdisk交互指令说明

命令

说明

a

设置可引导标记

b

编辑bsd磁盘标签

c

设置DOS操作系统兼容标记

d

删除一个分区

l

显示已知的文件系统类型。分区ID:82Linux swap分区,83Linux分区

m

显示帮助菜单

n

新建分区

o

建立空白DOS分区表

p

显示分区列表

q

不保存退出

s

新建空白SUN磁盘标签

t

改变一个分区的系统ID

u

改变显示记录单位

v

验证分区表

w

保存退出

x

附加功能,仅专家

 

 

不同的ID号代码的含义

Command (m for help): l

 

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris

 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-

 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-

 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-

 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx

 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data

 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .

 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility

 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt

 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access

 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O

 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor

 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs

 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT

 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/

10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b

11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor

12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor

14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary

16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS

17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE

18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep

1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT

1e  Hidden W95 FAT1 80  Old Minix

 

 

新建一个2G的主分区:

 

n命令表示新建分区:

Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

 

p是主分区,e代表选择扩展分区,分区号码请按照顺序指定

Select (default p): p

Partition number (1-4, default 1): 1

 

分区起始位置,默认值即可

First sector (2048-20971519, default 2048):

Using default value 2048

 

分区大小,2G

Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G

Partition 1 of type Linux and of size 2 GiB is set

 

p命令可以查看已经创建的分区

Command (m for help): p

 

Disk /dev/sdb: 10.7 GB, 1073741820 bytes, 2097152 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0xba40d842

 

     Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048     4196351     2097152   83  Linux

 

 

 

新建 一个扩展分区:

 

选择e命令,是扩展分区,后面走默认即可,剩余空间全部做为一个扩展分区。

 

Command (m for help): n

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): e

Partition number (2-4, default 2):

First sector (4196352-20971519, default 4196352):

Using default value 4196352

Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519):

Using default value 20971519

Partition 2 of type Extended and of size 8 GiB is set

 

Command (m for help): p

 

Disk /dev/sdb: 10.7 GB, 1073741824 bytes, 2097152 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0xba40d842

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048     4196351     2097152   83  Linux

/dev/sdb2         4196352    20971519     8387584    5  Extended

 

 

扩展分区的ID5

 

 

新建一个逻辑分区:

与扩展分区类似,通过l选择逻辑分区类型

基本都是默认值,大小指定为2G

 

Command (m for help): n

Partition type:

   p   primary (1 primary, 1 extended, 2 free)

   l   logical (numbered from 5)

Select (default p): l

Adding logical partition 5

First sector (4198400-20971519, default 4198400):

Using default value 4198400

Last sector, +sectors or +size{K,M,G} (4198400-20971519, default 20971519): +2G

Partition 5 of type Linux and of size 2 GiB is set

 

Command (m for help): p

 

Disk /dev/sdb: 10.7 GB, 1073741824 bytes, 2097152 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0xba40d842

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048     4196351     2097152   83  Linux

/dev/sdb2         4196352    20971519     8387584    5  Extended

/dev/sdb5         4198400     8392703     2097152   83  Linux

 

 

最后一步记得一定要保存分区结果,否则分区无效:

 

w保存分区并退出:

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]#

 

2、  重新读取分区表信息

命令:partprobe

保存分区结果时,如果分区没有人使用,可以正常保存;如果分区有人在使用,此时会提示:必须重启才能进行下一步,重启可以,还可以使用命令重新读取分区信息,而不用重启。

 

[root@localhost ~]# partprobe

Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

 

 

3、格式化分区

扩展分区,即不能格式化,也不能写入数据

mkfs –t ext4 /dev/sdb1

 

示例:

[root@localhost ~]# mkfs -t ext4 /dev/sdb1

mke2fs 1.42.9 (28-Dec-2013)

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

131072 inodes, 524288 blocks

26214 blocks (5.00%) reserved for the super user

First data block=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: done

Writing inode tables: done

Creating journal (16384 blocks): done

Writing superblocks and filesystem accounting information: done

 

4、挂载分区

 

 

从下面命令可以看出第1次挂载失败了,貌似好像是因为我在/mnt目录下,所以不能挂载?切换到根目录下后就可以正常挂载了。

[root@localhost mnt]# mkdir disk1 disk5

[root@localhost mnt]# ls

cdrom  disk1  disk5

[root@localhost mnt]# mount /dev/sdb1 mnt/disk1

mount: mount point mnt/disk1 does not exist

[root@localhost mnt]# cd /

[root@localhost /]# mount /dev/sdb1 mnt/disk1

[root@localhost /]# mount /dev/sdb5 mnt/disk5

 

 

通过df命令,可以看到已经挂载上去了,还有大小显示,也可以用mount命令查看挂载结果

[root@localhost /]# df -h

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root   17G  1.2G   16G   7% /

devtmpfs                 446M     0  446M   0% /dev

tmpfs                    456M     0  456M   0% /dev/shm

tmpfs                    456M  6.0M  450M   2% /run

tmpfs                    456M     0  456M   0% /sys/fs/cgroup

/dev/sda1               1014M  125M  890M  13% /boot

tmpfs                     92M     0   92M   0% /run/user/0

/dev/sdb1                2.0G  6.0M  1.8G   1% /mnt/disk1

/dev/sdb5                2.0G  6.0M  1.8G   1% /mnt/disk5

 

 

 

 

7.4.分区自动挂载与/etc/fstab文件修复

 

 

看的免费视频,这节看不了。

 

 

7.5.分配swap分区

 

 

1、查看内存与swap分区使用情况

 

[root@localhost ~]# free

              total        used        free      shared  buff/cache   available

Mem:         933808      560596      238976        6140      134236      216896

Swap:       2097148           0     2097148

 

-m通过M单位显示大小

[root@localhost ~]# free -m

              total        used        free      shared  buff/cache   available

Mem:            911         547         233           5         131         211

Swap:          2047           0        2047

 

交换分区2G

 

cached缓存:是指把讯取出来的数据保存在内存当中,当再次读取时,不用读取硬盘而直接从内存当中读书取,加速了数据的读取过程。

buffer缓冲:是指在写入数据时,先把分散的写入操作保存到内存当中,当达到一定程度时,再集中写入硬盘,减少了磁盘碎片和硬盘的反复寻道,加速了数据的写入过程。

 

 

交换分区一般很小就够用了,如果真的不够用时,我们可以加大swap分区。

 

 

 

2、新建swap分区

 

我们的磁盘/dev/sdb中还有6G未使用,可以分配给交换分区

 

命令:fdisk /dev/sdb

 

别忘记把分区ID改为82

 

 

新建一个逻辑为区,大小为3G,做为交换分区

 

 

 

[root@localhost ~]# fdisk /dev/sdb

 

The device presents a logical sector size that is smaller than

the physical sector size. Aligning to a physical sector (or optimal

I/O) size boundary is recommended, or performance may be impacted.

Welcome to fdisk (util-linux 2.23.2).

 

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

 

 

Command (m for help): n

Partition type:

   p   primary (1 primary, 1 extended, 2 free)

   l   logical (numbered from 5)

Select (default p): l

Adding logical partition 6

First sector (8394752-20971519, default 839472):

Using default value 8394752

Last sector, +sectors or +size{K,M,G} (8394752-20971519, default 20971519): +3G

Partition 6 of type Linux and of size 3 GiB is set

 

Command (m for help): p

 

Disk /dev/sdb: 10.7 GB, 107374182 bytes, 209715 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0xba40d842

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048     4196351     2097152   83  Linux

/dev/sdb2         4196352    20971519     8387584    5  Extended

/dev/sdb5         4198400     8392703     2097152   83  Linux

/dev/sdb6         8394752    14686207     3145728   83  Linux

 

Command (m for help):

 

 

可以看出新建的分区/dev/sdb6ID号是83,然而交换分区的ID号是82,所以要修改:

 

t命令表示修改ID号,6是我们新建的交换分区编号,82是要修改的目标ID号,修改完成后,再次查看,可以发现分区/dev/sdb6IDk与已经变成82了。

Command (m for help): t

Partition number (1,2,5,6, default 6): 6

Hex code (type L to list all codes): 82

Changed type of partition 'Linux' to 'Linux swap / Solaris'

 

Command (m for help): p

 

Disk /dev/sdb: 10.7 GB, 107374182 bytes, 209710 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk label type: dos

Disk identifier: 0xba40d842

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048     4196351     2097152   83  Linux

/dev/sdb2         4196352    20971519     8387584    5  Extended

/dev/sdb5         4198400     8392703     2097152   83  Linux

/dev/sdb6         8394752    14686207     3145728   82  Linux swap / Solaris

 

 

保存分区:

 

这里保存时就报错了,说设置忙,所以要使用partprobe命令重新读取分区信息

后来发现还是没有加载进来,所以必须重启电脑了。

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

[root@localhost ~]# partprobe

Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

[root@localhost ~]#

 

 

3、格式化swap分区

         mkswap /dev/sdb6

 

[root@localhost ~]# mkswap /dev/sdb6

Setting up swapspace version 1, size = 3145724 KiB

no label, UUID=f58d0ce7-4d17-4000-95b9-3454611ef281

[root@localhost ~]#

 

 

4、加入swap分区

 

加入swap分区

swapon /dev/sdb6

 

 

取消swap分区

swapoff /dev/sdb6

 

 

如下所示,加入分区后,重新查看swap分区,已经变成5G了。之前的是2G,刚才新建的交换分区是5G,刚好正确。

 

[root@localhost ~]# swapon /dev/sdb6

[root@localhost ~]# free -m

              total        used        free      shared  buff/cache   available

Mem:            911         548         241           6         122         215

Swap:          5119           0        5119

 

 

5swap分区开机自动挂载

 

以上分区挂载命令,只是临时的,重启以后就不见了,所以需要设置开机自动挂载

 

vi /etc/fstab

加入如下配置,然后保存即可

/dev/sdb6               swap                    swap    defaults        0 0

 

然后再执行一命令,没报错就正常了

[root@localhost ~]# mount -a

[root@localhost ~]#

 

 

 

 

 

 

 

 

 

猜你喜欢

转载自wlcacc.iteye.com/blog/2422741