LINUX中的分区与文件系统

一.文件系统 1.ext2 and ext3 2.swap 3.vfat 4.NFS 5.ISO9660 6.日志文件系统 在Red Hat Linuxt 9中除了支持ext3文件系统外,还可以使用reiserfs and jfs文件系统,他们都是性能优越且应用广泛的日志文件系统。二.建立使用文件系统的一般方法 1.在硬盘中建立分区 就像在DOS下可以使用fdisk命令建立FAT分区一样,在LINUX中提供了fdisk和parted命令可以对硬盘进行分区 需要注意的是在LINUX中的fdisk和DOS中的fdisk命令是同名且功能类似的两个不同的命令,他们各自运行在不同的操作系统平台,且命令格式也各有不同。 在建立分区时需要确定分区类型(分区中文件系统类型)和分区大小,分区类型一旦确定将不能改变。 2.在分区上建立文件系统 硬盘中的分区建立好之后就需要建立文件系统了,即所谓的格式化分区,只有在分区中建立了相应的文件系统,分区才能够用于保存文件。命令名1命令名2命令名3说明mkfs.etx3mkfs.ext3mke2fs建立ext3文件系统mkfs.vfatmkfs.msdosmkdosfs建立vfat文件系统mkfs.reiserfsmkreiserfs建立reiser文件系统mkfs.jfs建立jfs文件系统mkswap建立swap文件系统 3.把分区挂载系统中 在分区中建立好文件系统后就可以把该分区挂载到系统中相应目录了,挂载点目录要求为空。 挂载文件系统可以使用mount命令,如果需要系统每次启动时都自动挂载该文件系统,则需要在文件”/etc/fsbat”中添加相应设置行。 三.磁盘分区命令 1.fdisk#fdiskUsage:fdisk [-l][-b SSZ][-u]device E.g:fdisk/dev/hda(for the first IDE disk)or:fdisk/dev/sdc(for the third SCSI disk)or:fdisk/dev/eda(for the first PS/2 ESDI drive)or:fdisk/dev/rd/c0d0 or:fdisk/dv/ida/c0d0 (for RAID devices)#fdisk /dev/hdaCommand(m for help):mCommangd action a toggel a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o creste a new enmty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition’s system id u change display/entry units v verify the partition table w write the partition table x extra runctionality(experts only)Command (m for help) 2.parted(parted命令用于对指定硬盘中的分区进行维护)parted 【硬盘设备文件全路经名】//如不在parted命令中指定硬盘设备文件,则使用系统当前硬盘#partedONU Parted 1.6.3Copyright(C)1998.1999.2000.2001.2002Free Software Foundation,Inc.This program is free software,covered by the GNU General Public License.This program is distributed in the hopr that it will be useful,but WITHOUT ANY WARRANTY;without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details.Using/dev/dsaInformation:The operating system thinks the geometry on/dev/sda si 522/255/63.(parted)help //输入”help”命令显示帮助信息check MINORdo a simple check on the filesystemcp[FROM-DEVICE]FROM-MINOR TO-MINOR copy filesystem to another partitionhelp[COMMAND]prints general help,or help on COMMANDmklabel LABEL-TYPEcreate a new disklabel(partiton table)mkfs MINOR FS-TYPEmake a filesystem FS-TYPE on partition MINORmkpart PART-TYPE[FS-TYPE]START ENDmake a partitionmkparfs PART-TYPE FS-TYPE START ENDmake a partition with a filesystemmove MINOR START END move partition MINORname MINOR NAMEname partition MINOR NAMEprint[MINOR]display the partition table,or a partitionquitexit programrescue START ENDrecue a lost partition near START and ENDresize MINOR START ENDresize filesystem on partition MINORrm MINORdelete partition MINORselect DEVICEchoose the device to editset MINOR FLAG STATE change a flag on partition MINOR(speed)print //输入print命令显示硬盘分区Disk geometry for /dev/sda:0.000-4096.000 megabytesDisk label type:msdosMinorStartEndTypeEilesystemFlags10.031101.975primaryext3boot2101.9753961.340primaryext333961.3404086.848primarylinux-swap(parted)quit //输入quit命令退出parted环境Information:Don’t forget to update /etc/fsbat.ifneccessary四.ext3文件系统的维护1.mke2fs 用于建立ext2/ext3文件系统#mke3fs /dev/hdb1mke2fs 1.32(09-Nov-2002)Filesystem label=OS type:LinuxBlock size=1024(log=0)Fragment size=1024(log=0)50200 inodes,200781 blocks10039 block(5.00%)reserved for the super userFirst data block=125 block groups8192 blocks per group,8192 fragments per group2008 inodes per groupSuperblock backups stored on blocks:8193,24577,40961,57345,73729Writing inode tables:doneWriting superblocks and filesystem accounting information:doneThis filesystem will be automatically checked every 32 mounts or 180days,whichever comes first. Use tune2fs -c or -i to override.2.e2label用于显示或设置指定ext2或ext3分区的卷标#e2label /dev/hdb1 /var/ftp//设置”/dev/dhb1″的卷标为”var/ftp”#et2label /dev/hdb1/var/ftp//显示”dev/dhb1″ 的卷标3.findfs用于在系统中查找指定卷标的文件系统#findfs LABEL=/var/ftp/dev/dhb14.e2fsck用于检测指定分区中的ext2/ext3文件并时行错误修复#e2fsck /dev/dhb1e2fsck 1.32(09-Nov-2002)/var/ftp:clean,11/50200files,6351/200781 blocks#e2fsck /dev/sda1e2fsck 1.32(09-Nov-2002)/dev/sda1 in mountedWARNINIG!!! Running e2fsck on a mounted filesystem may causeSEVERE filesystem damage.//e2fsck 命令不能用于检测系统中已装载的文件系统,否则会造成文件系统的损害Do you really want to continue(y/n)?nocheck aborted.五.设置系统启动时自动挂载文件系统文件系统的自动挂载是通过配置fstab文件实现的在LINUX启动过程中,init进程会自动读取文件/etc/fstab中的配置内容挂载相应的文件系统。#more /etc/fstabLABEL=//ext3defaults1 1LABEL=/boot/bootext3defaults1 2none/dev/ptsdevptsgid=5,mode=6200 0none/procprocdefaults0 0none/dev/shmtmpfsdefaults0 0/dev/sda3swapswapdefaults0 0/dev/fd0/mntfloppyautonoauto,nwner,kudzu0 0/dev/chrom/mnt/cdromudf,iso9600noauto,owner,kudzu,ro0 0

肆Σ毛” 博客,转载请与作者联系!

旅行,不要害怕错过什么,

LINUX中的分区与文件系统

相关文章:

你感兴趣的文章:

标签云: