您的位置:首页 > 其它

Filesystem Formatting and Checking

2009-10-31 16:14 295 查看
Three basic toos are available to manage the filesystem on various partitions:fdisk,mkfs,and fsck.

They can help you configure partitions as well as create,and then check and repair,different filesystems.

fdisk:

The Linux fdisk utility is a lot more versatile than its Microsoft counterpart.But to open it,you need know the device file associated with the hard drive that you want change.Assuming you want to manage the partitions on the first SCSI hard disk,enter /sbin/fdisk /dev/sda.

mkfs:

To format a Linux partition,apply the mkfs command.It allows you to format a partition to a number of different filesystems.

To format a typical partition such as /dev/hda2 to the current Red Hat standard,the thrd extended filesystem,run the following command:

# mkfs -t ext3 /dev/hda2

The mkfs command also serves as a "front-end" ,depending on the filesystem format.For example,if you're formatting a Red Hat standard ext3 filesystem,mkfs by itself automatically calls the mkfs.ext3 command.Therefore,if you're reformatting an ext3 filesystem,the following command is sufficient:

# mkfs /dev/hda2

Be careful with mkfs.First,back up any data on the subject partition and computer.This command erases all data on the specified partition.

fsck:

The fsck command is analogous to the Microsoft chkdsk command.It performs an analysis of the specified filesystem and performs reparis as required.Assume you're having problems with files in the /var directory,which happens to be mounted on /dev/hda7.If you want to run fsck,unmount that filesystem first.In some cases,you may need to go into single-user mode with the init 1 command before you can unmount a filesystem.To unmount,analyze,then remount the filesystem noted in this section,run the following commands:

# umount /var

# fsck -t ext3 /dev/hda7

# mount /dev/hda7 /var

The fsck command also serves as a "front-end",depending on the filesystem format.For example,if you're formatting an ext2 or ext3 filesystem,fsck by itself automatically calls the e2fsck command(which works for bothe filesystems).Therefore, if you're checking an ext3 filesystem,the following command is sufficient:

# fsck /dev/hda7
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: