linux的文件系统认识(1)

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

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

ro or rwRead only or read write
noautoDo not respond to mount -a. Used for external devices CDROMs ...
noexecExecutables cannot be started from the device
nosuidIgnore SUID bit throughout the filesystem
nodevSpecial device files such as block or character devices are ignored
noatimeDo not update atimes (performance gain)
ownerThe device can be mounted only by it's owner
userImplies noexec, nosuid and nodev. A single user's name is added to mtab so that other users may not unmount the devices
usersSame 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

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值