rh131筆記--unit6-filesystem managemen

tonykorn97發表於2008-07-16
一,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部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-1007368/,如需轉載,請註明出處,否則將追究法律責任。