fstab释疑

文件/etc/fstab存放的是系统中的文件系统信息。每行中的字段都由空格或tab键分开。以下是每行的说明:

   fs_spec: 设备或远程文件系统
   fs_file: 挂载点,SWAP分区的字段则为SWAP
   fs_type: 文件系统类型
fs_options: 文件系统参数,一般选default,具体参数说明见下表
   fs_dump: 文件系统应该以多快频率进行转储,不需要转储就设置该字段为0
   fs_pass: 启动时需要被扫描的文件系统的顺序,若该文件系统无需在启动时扫描则设置
该字段为0,扫描文件系统的命令是fsck(用来检查与修正硬盘错误的指令)。

    ro: 以只读模式加载该文件系统
  sync: 不对该设备的写操作进行缓冲处理,这可以防止在非正常关机时情况下破坏文件系
统,但是却降低了计算机速度
  user: 允许普通用户加载该文件系统
 quota: 强制在该文件系统上进行磁盘定额限制
noauto: 不再使用mount -a命令(例如系统启动时)加载该文件系统

an example of fstab:

/dev/mapper/vg_hzaumycology-lv_root /                       ext4    defaults        1 1
UUID=081751dd-cd3f-4e42-8265-ca860fcb56b5 /boot                   ext4    defaults        1 2
/dev/mapper/vg_hzaumycology-lv_home /home                   ext4    defaults        1 2
/dev/mapper/vg_hzaumycology-lv_swap 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
//122.205.95.76/Archive /remoteserver/Archive   cifs    username=chenlianfu,passwd=123456      0 0
//122.205.95.76/Blog    /remoteserver/Blog      cifs    username=chenlianfu,passwd=123456      0 0

How do I forcefully unmount a Linux disk partition?

It happens many times you try to unmount a disk partition or mounted CD/DVD disk and if you try to unmount device, which is accessed by other users, then you will get error umount: /xxx: device is busy.

What happens basically, is that Linux / UNIX will not allow you to unmount a device that is busy. There are many reasons for this (such as program accessing partition or open file) ,but the most important one is to prevent data loss.

1 the first method

Try the following command to find out what processes have activities on the device/partition. If your device name is /dev/sdb1, enter the following command as root user:

# lsof | grep '/dev/sda1' 
Output: vi 4453 vivek 3u BLK 8,1 8167 /dev/sda1

Above output tells that user vivek has a vi process running that is using /dev/sda1. All you have to do is stop vi process and run umount again. As soon as that program terminates its task, the device will no longer be busy and you can unmount it with the following command:

# kill 4453
# umount /dev/sda1

 2 the second method

Linux fuser command to forcefully unmount a disk partition

Suppose you have /dev/sda1 mounted on /mnt directory then you can use fuser command as follows:Type the command to unmount /mnt forcefully:

# fuser -km /mnt 

Where, 
    -k : Kill processes accessing the file. 
    -m : Name specifies a file on a mounted file system or a block 
device that is mounted. In above example you are using /mnt

 3 the third method

# umount -l /mnt

Where,
    -l : Also known as Lazy unmount. Detach the filesystem from 
the filesystem hierarchy now, and cleanup all references to the 
filesystem as soon as it is not busy anymore. This option works 
with kernel version 2.4.11+ and above only.

4 the fourth method

# umount -f /mnt

Where,

    -f: Force unmount in case of an unreachable NFS system

Caution: Using these commands or option can cause data loss for open files;      programs which access files after the file system has been unmounted will get an error.

关于amd64和ia64的理解

现在买的PC或者服务器都有64位的机器,而有时我们安装系统,不管是Windows还是Linux系统,要发挥机器的最高性能,必须也要安装64位的OS,否则,就达不到最好的性能。

比如:32位操作系统,配合32位CPU,寻址空间位2^32次方,计算出来是4294967296字节,就是4G,32位系统最大支持4G空间,如果想要32位

系统支持4G以上空间的话,就要用PAE的特殊内核,采用特殊方式访问,但是系统效率会比原生的64位系统低。当然有时有的Linux只能识别到3G多,因为据说是当初在设计上的缺陷。这里不做详解。

而64位操作系统配合64位CPU,寻址空间是2^64次方,计算出来是18446744073709551616字节,换算一下4G个G,太大了,反正是N多G,一辈子也用不完。当然这是64位系统的理论最大内存支持,实际上谁也用不了这么大内存.

等等…

因此我们要下载64的操作系统,而我们看到有64的操作系统最经常见到的有ia64/amd64,它们如何区分呢,哪些CPU是属于AMD64,哪些是属于IA64呢?

其实很多人从字面上,都以为AMD64就是针对AMD CPU的,IA64是针对INTEL CPU,其实是错的,我最初也是这样认为,其实不然:

你在市面上买的到的intel 64位 CPU都属于amd64范畴这个架构应该称为 x86_64,因此不管是AMD的64位CPU,还是INTEL的64位CPU,都是属于AMD64范畴.

而IA64指的是Intel安腾系列CPU,不是X86架构的。ia64主要用在服务器上面,而不是我们平常使用的桌面,通常这些cpu很贵,相关的内存以及硬盘同样很贵!

因此你以后你PC的CPU是64位的[有Intel,也有AMD],非安腾的CPU的话,你就下载AMD64的OS进行安装即可.

使用inode来重命名或删除文件

最近通过服务器下载了一部电影,存放在服务器的家目录下。但是电影的文件名是乱码,表现为一大堆乱码和无意义字符。无法通过文件名来对文件名进行重命名,删除和复制。面对这种情况,解决方法为:

1 首先通过命令查看该文件的inode。

#ls -ilh

 2 通过命令来对文件进行重命名或删除。

例如,我下载的电影原本名称为《龙门飞甲.rmvb》,但下载下来后名称为乱码《???ŷɼ?(?????ſ?ջ)HD??????????????.rmvb》,其inode号码为7077900。

#mv -i `find . -maxdepth 1 -inum 7077900 -print` 龙门飞甲.rmvb。
#rm -i `find . -maxdepth 1 -inum 7077900 -print`

 

递归更改目录权限为775,常规文件权限为644

在windows系统上copy文件到linux系统上后,肯定是权限放到了最大了,全部为777的权限。当然,肯定要限制权限了。我们的目的是要把目录权限全部设定为775,文件权限全部设定为664。这两者被设定的权限不一致,应以如下方式解决。

$chmod 775 -R the_file_you_just_coped/

#-R的参数表示递归处理,将所有的文件目录和文件都设为775的权限。

$find the_file_you_just_coped/ -type f -exec chmod a-x {} \;

#-type参数表示查找文件类型,f代表一般正规文件;-exec参数表示对查找结果进行其它命令处理,在此对查找结果进行的处理是chmod a-x {},即删除x权限;\;是必须带的。