linux的文件系统认识(1)

来源:互联网 发布:linux expect bash结合 编辑:程序博客网 时间:2024/05/02 04:35

1.谈到linux的文件系统,我们必须关注/etc/fstab文件的内容;在linux中的所有挂载分区和设备都在fstab表格中。

/etc/fstab表格中的选择项参数定义如下:

ro or rwRead only or read writenoautoDo not respond to mount -a. Used for external devices CDROMs ...noexecExecutables cannot be started from the devicenosuidIgnore SUID bit throughout the filesystemnodevSpecial device files such as block or character devices are ignorednoatimeDo not update atimes (performance gain)ownerThe device can be mounted only by it's owneruserImplies noexec, nosuid and nodev. A single user's name is added to mtab so that other users may not unmount the devicesusersSame as user but the device may be unmounted by any other user

谈到文件系统我们必须要了解linux文件系统中的mount命令,它可以实现挂载一个新的设备或分区到我们的linux系统中,mount命令的所有操作都会更新到/etc/mtab文件中,还有一个与此文件相似的文件时/proc/mounts。

2.当系统启动后在rc.sysinit脚本(也就系统启动后自动运行的一个脚本,但不是在所有的linux系统中都能找到它,也许别人把它改名了)中,mount命令会挂载/etc/fstab文件中的所有分区或设备。

mount命令功能非常强大,除了简单挂载设备以外还提供很多其他功能,比如:移动挂载点,标志挂载设备的属性,共享、私有、继承...,如果你有兴趣请在linux命令行下man mount。

3.新建一个交换分区

我们可以通过命令swapon -a来开启已经有的交换分区;

如果没有交换分区,我们还可以通过下面的几条命令组合新建一个交换分区并打开它;

 

a. dd if=/dev/zero of=/tmp/SWAPFILE bs=1k count=10240 #此处dd命令的具体参数请自行学习

b. mkswap /tmp/SWAPFILE #此处mkswap参数简单就是建立一个交换分区

c. swapon /tmp/SWAPFILE #此处使用swapon打开新建的交换分区

d. cat /proc/swaps #此处cat为一个简单的阅读器,查看你新建的交换分区
Filename                  Type            Size    Used    Priority
/dev/hda6                 partition       522072  39744   -1
/tmp/SWAPFILE             file            10232   0       -2

 

我们也可以通过下面的操作新建一个交换分区

a. Make a new partition (e.g /dev/hda16) of type swap (82) and size 16MB. Reboot.

b. Make a swap filesystem on the devices

c.  mkswap /dev/hda16

d. Add the following to /etc/fstab

e. /dev/hda16 swap swap  pri=-1 0 0

f.  Make the swap partition available with swapon -a

Notice that if two swap partition are defined the kernel will automatically access them in stripedmode, provided they have been mounted with the same priority determined by the pri= option in /etc/fstab

 

 

原创粉丝点击