ITPub博客

首页 > Linux操作系统 > Linux操作系统 > rh131笔记--unit6-filesystem managemen

rh131笔记--unit6-filesystem managemen

原创 Linux操作系统 作者:tonykorn97 时间:2008-07-16 18:45:29 0 删除 编辑
一,managing partitions
分区工具
fdisk
sfdisk
parted

更新一下分区表,避免重启
partprobe[@more@]


二,making filesystems
mkfs.ext3
mke2fs

三,filesystem labels
[root@server1 ~]# e2label /dev/sda5 backup
[root@server1 ~]# e2label /dev/sda5
backup
[root@server1 ~]# mount LABEL=backup /mnt

blkid can be used to see labels and filesystem type of all devices
例如:
[root@server1 ~]# blkid
/dev/mapper/VolGroup00-LogVol01: UUID="f10e321b-6fd2-47e6-8dee-4f58e63b1780" SEC_TYPE="ext2" TYPE="ext3"
/dev/mapper/VolGroup00-LogVol00: UUID="b396c898-17fd-478b-b38b-0648450f23b6" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda3: LABEL="SWAP-sda3" TYPE="swap"
/dev/sda1: LABEL="/boot" UUID="4a3d9fb3-7313-43eb-9c12-401132a89704" SEC_TYPE="ext2" TYPE="ext3"
/dev/hda: LABEL="RHEL/5.1 i386 DVD" TYPE="iso9660"
/dev/VolGroup00/LogVol00: UUID="b396c898-17fd-478b-b38b-0648450f23b6" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda5: LABEL="backup" UUID="3430068c-c097-4c72-90ae-c6dcb992a357" SEC_TYPE="ext2" TYPE="ext3"
[root@server1 ~]#


四,tune2fs
adjusts filesystem parameters
1,reserved blocks
2,default mount options
3,fsck frequency

view current setings with dumpe2fs

例子:
1,modify the percentage of reserved blocks
[root@server1 ~]# tune2fs -m 10 /dev/sda5
tune2fs 1.39 (29-May-2006)
Setting reserved blocks percentage to 10% (25100 blocks)
[root@server1 ~]#

2,set the default mount options
[root@server1 ~]# tune2fs -o acl,user_xattr /dev/sda5
tune2fs 1.39 (29-May-2006)
[root@server1 ~]#

3,disable mandatory filesystem checks
[root@server1 ~]# tune2fs -o acl,user_xattr /dev/sda5
tune2fs 1.39 (29-May-2006)
[root@server1 ~]#

五,/etc/fstab

六,mount
mount [-t fstype] [options] device mount_point

umounting filesystems
需要了解的命令:
fuser

显示那些进程占用这个文件系统
[root@server1 ~]# fuser -v /mnt

USER PID ACCESS COMMAND
/mnt: root 2466 ..c.. bash

杀掉占用挂载点的进程
[root@server1 ~]# fuser -km /mnt
/mnt: 2466c


mount by example

1,重新挂载
[root@server1 ~]# mount -o remount,rw /dev/sda5 /mnt

2,不能执行可执行程序
[root@server1 ~]# mount -t ext3 -o noexec /dev/sda5 /mnt
[root@server1 ~]# cd /mnt
[root@server1 mnt]# ll
总计 20
-rw-r--r-- 1 root root 15 06-06 01:49 1
drwx------ 2 root root 16384 06-06 01:20 lost+found
[root@server1 mnt]# chmod +x 1
[root@server1 mnt]# ./1
-bash: ./1: 权限不够

3,挂载iso文件
mount -t iso9660 -o loop /iso/documents.iso /mnt/cdimage

4,mount -t vfat -o uid=515,gid=520 /dev/sdc2 /mnt/proj

5,禁止更新文件读写时间变更
mount -t ext3 -o noatime /dev/sda5 /mnt

6,把已经挂载的文件系统重新挂载到其他位置
mount --bind /something /anotherthing


七,swap
hangling swap files and partition

swap space is a supplement to system RAM
basic setup involves:
1,create swap partition or file
2,write special signature using mkswap
3,add apporopriate entries to /etc/fstab
4,active swap space with swapon -a

setting up a swap partition
mkswap /dev/sda6
add an entry for the swap to /etc/fstab.it will look similar to the following:
/dev/sda6 swap swap defaults 0 0

activate the swap partition using swapon -a (which reads /etc/fstab and turns on all swap entries it lists).
check the swap partition's status using swapon -s

setup a swap file
dd if=/dev/zero of=swapfile bs=1024 count=X



八,mounting NFS filesystems

1,makes a remote NFS filesystem work as though it were a local filesystem
2,/etc/fstab can be used to specify persistent network mounts
3,NFS shares are mountted at boot time by /etc/init.d/netfs
4,Exports can be mounted manually with the mount command.
mkdir /mnt/server1
mount -f nfs server1:/var/ftp/pub /mnt/server1



九,Automounter

1,system administrator specifies mount points controlled by automounter daemon process in /etc/auto.master
2,the automounter monitors access to these directories and mounts the filesystem on demand
3,filesystems automatically unmounted after a specified interval of inactivity
4,enable the special map -host to "browse" all NFS exports on the network
5,supports wildcard directory names

例子 :
1,配置automounter把server1:/var/ftp/pub 挂载到 /misc/server1

a,edit the /etc/auto.master file .uncomment the first line for /misc
b,add a line to the /etc/auto.misc file that wil mount the /var/ftp/pub export form server1.example.com to your own /misc/server1 target:
server1 -ro,intr,hard server1:/var/ftp/pub
c,restart the autofs service:
#service autofs restart
d,try to access the /misc/server1 directory


2,use the automounter to mount the home directories for your NIS users from server1.example.com you can use getent passwd to see what home directories are assigned.server1.example.com exports /home/guests to your system.

a.begin by editing /etc/auto.master and and the following line:
/home/guests /etc/auto.guests --timeout=60

b,create and edit /etc/auto.guests so it contains the line
* -rw,soft,intr 192.168.0.254:/home/guests/&
this line specifies that access to any immediate subdirectory of /home/guests should make autofs mount a NFS export form 192.168.0.254 where the & is the same as the name of the local subdirectory.(so the automounter would mount 192.168.0.254:/home/guests/guest2001 on /home/guests/guest2001).the middle column specifies the mount options that will be used;read-writ,timeout eventually if the NFS server is not available,abd tuneiyt unneduatekt uf ab ubteryot us sebt.

c,Configure autofs to start in run levels 2,3,4,and 5, then restart it manually;
#chkconfig autofs on;services autofs restart

d,now try logging in again and see whether the home directory gets mounted automatically.it should.try logging into to your neighbors system once it is also configured you should be able to access your home environment from any system in the notexample domain.

域名:notexample
通过su - guest20xx 测试。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/312079/viewspace-1007368/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-05

  • 博文量
    1854
  • 访问量
    2088310