[root@localhost beinan]# mkfs -t 文件系统 存储设备
[root@localhost beinan]# fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux
Disk /dev/sda: 1035 MB, 1035730944 bytes
256 heads, 63 sectors/track, 125 cylinders
Units = cylinders of 16128 * 512 = 8257536 bytes
Device Boot Start End Blocks Id System
/dev/sda1 1 25 201568+ 83 Linux
/dev/sda2 26 125 806400 5 Extended
/dev/sda5 26 50 201568+ 83 Linux
/dev/sda6 51 76 200781 83 Linux
[root@localhost beinan]# mkfs -t ext3 /dev/sda6
mke2fs 1.37 (21-Mar-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
50200 inodes, 200780 blocks
10039 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2008 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: 注:在这里直接回车;
done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost beinan]# mkdir /mnt/sda6
[root@localhost beinan]# chmod 777 /mnt/sda6
[root@localhost beinan]# mount /dev/sda6 /mnt/sda6
[root@localhost beinan]# mkfs -t ext3 /dev/sda6
[root@localhost beinan]# mkfs -t ext2 /dev/sda6
[root@localhost beinan]# mkfs -t reiserfs /dev/sda6
[root@localhost beinan]# mkfs -t fat32 /dev/sda6
[root@localhost beinan]# mkfs -t msdos /dev/sda6
... ...
[root@localhost beinan]# mkfs.ext3 /dev/sda6 注:把该设备格式化成ext3文件系统
[root@localhost beinan]# mke2fs -j /dev/sda6 注:把该设备格式化成ext3文件系统
[root@localhost beinan]# mkfs.ext2 /dev/sda6 注:把该设备格式化成ext2文件系统
root@localhost beinan]# mke2fs /dev/sda6 注:把该设备格式化成ext2文件系统
[root@localhost beinan]# mkfs.reiserfs /dev/sda6 注:把该设备格式化成reiserfs文件系统
[root@localhost beinan]# mkfs.vfat /dev/sda6 注:把该设备格式化成fat32文件系统
[root@localhost beinan]# mkfs.msdos /dev/sda6 注:把该设备格式化成fat16文件系统,msdos文件系统就是fat16;
[root@localhost beinan]# mkdosfs /dev/sda6 注:把该设备格式化成fat16文件系统,同mkfs.msdos
... ...
[root@localhost beinan]# mkswap /dev/sda6 注:创建此分区为swap 交换分区
[root@localhost beinan]# swapon /dev/sda6 注:加载交换分区;
[root@localhost beinan]# swapoff /dev/sda6 注:关闭交换分区;
[root@localhost beinan]# swapon /dev/sda6 注:加载交换分区;
[root@localhost beinan]# swapon -s
Filename Type Size Used Priority
/dev/hda7 partition 787144 0 -1
/dev/sda6 partition 225144 0 -3
为什么我的系统有两个交换分区?因为我用移动U盘做的实验,主要是为写教程之用;sda6是我在U盘上建的swap分区;
如果让swap开机就加载,应该改 /etc/fstab文件,加类似如下一行;
/dev/sda6 swap swap defaults 0 0 注:把此行中的/dev/hda7 改为您的交换分区就行;
swapon /dev/sda6
[root@localhost beinan]# dd if=/dev/zero of=/tmp/swap bs=1024 count=524288 注:创建一个大小为512M 的swap 文件,在/tmp目录中;您可以根据自己的需要的大小来创建swap 文件;
读入了 524288+0 个块
输出了 524288+0 个块
[root@localhost beinan]# mkswap /tmp/swap 注:把/tmp/swap 文件,创建成swap 交换区
Setting up swapspace version 1, size = 536866 kB
no label, UUID=d9d8645d-92cb-4d33-b36e-075bb0a2e278
[root@localhost beinan]# swapon /tmp/swap 注:挂载swap
[root@localhost beinan]# swapon -s
Filename Type Size Used Priority
/dev/hda7 partition 787144 888 -1
/tmp/swap file 524280 0 -2
[root@localhost beinan]# mount [-t 文件系统 ] [-o 选项] 设备 目录
[root@localhost beinan]# mount /dev/cdrom
[root@localhost beinan]# mount /dev/fd0
/dev/hdc /media/cdrecorder auto users,exec,noauto,managed 0 0
[root@localhost beinan]#mkdir /mnt/cdrom
[root@localhost beinan]# mount /dev/cdrom /mnt/cdrom
/dev/hdc /media/cdrecorder auto users,exec,noauto,managed 0 0
[root@localhost beinan]# ls -lh /dev/dvd*
lrwxrwxrwx 1 root root 3 2005-09-13 /dev/dvd -> hdc
[root@localhost beinan]# ls -lh /dev/cdrom
lrwxrwxrwx 1 root root 3 2005-09-13 /dev/cdrom -> hdc
[root@localhost beinan]# ls -lh /dev/cdwriter
lrwxrwxrwx 1 root root 3 2005-09-13 /dev/cdwriter -> hdc
[root@localhost beinan]# mkdir /mnt/cdrom
[root@localhost beinan]# mount /dev/hdc /mnt/cdrom
[root@localhost beinan]# fdisk -l /dev/hda
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 9729 55617030 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux
/dev/hda10 7752 9729 15888253+ 83 Linux
[root@localhost beinan]# mkdir /mnt/hda5/ 注:先创建一个挂载目录;
[root@localhost beinan]# chmod 777 /mnt/hda5/ 注:设置/mnt/hda5的权限为任何用户可写可读可执行;这样所有的用户都能在写入;
[root@localhost beinan]# mount -t reiserfs /dev/hda5 /mnt/hda5 注:通过-t reiserfs 来指定/dev/hda5是reiserfs 文件系统, 并且挂载到/mnt/hda5目录;
[root@localhost beinan]# mount -t auto /dev/hda5 /mnt/hda5 注:假如我们不知道hda5上reiserfs 文件系统,我们可以用 -t auto 让系统定夺,然后挂载到/mnt/hda5 ;
[root@localhost beinan]# mount /dev/hda5 /mnt/hda5 注:不加任何参数,直接 mount /dev/hda5 到/mnt/hda5;系统自动判断分区文件系统;
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.5G 1.9G 83% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
/dev/hda5 7.9G 5.8G 2.1G 74% /mnt/hda5
[root@localhost beinan]# umount 设备或挂载目录
[root@localhost beinan]# mount -t auto /dev/hda5 /mnt/hda5 注:挂载/dev/hda5;
[root@localhost beinan]# df -lh 注:查看/dev/hda5是否被挂载;
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.5G 1.9G 83% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
/dev/hda5 7.9G 5.8G 2.1G 74% /mnt/hda5
[root@localhost beinan]# umount /dev/hda5 注:卸载/dev/hda5
[root@localhost beinan]# df -lh 注:看是否卸载了/dev/hda5;
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.5G 1.9G 83% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
[root@localhost beinan]#umount /dev/cdrom 注:卸载cdrom ;
[root@localhost beinan]#umount /dev/fd0 注:卸载软驱;
[root@localhost beinan]# mount -s
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/1 / ext3 defaults 1 1
/dev/devpts /dev/pts devpts gid=5,mode=620 0 0
/dev/shm /dev/shm tmpfs defaults 0 0
/dev/proc /proc proc defaults 0 0
/dev/sys /sys sysfs defaults 0 0
LABEL=SWAP-hda7 swap swap defaults 0 0
/dev/hdc /media/cdrecorder auto users,exec,noauto,managed 0 0
[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 8.5G 1.9G 83% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda10 16G 6.9G 8.3G 46% /mnt/hda10
e2label device [newlabel]
[root@localhost beinan]# e2label /dev/hda5 /5
[root@localhost beinan]# mkdir /mnt/hda5 注:创建挂载/dev/hda5分区的目录;
[root@localhost beinan]# chmod 777 /mnt/hda5 注:打开权限,所有用户可读可写可执行;
/5 /mnt/hda5 ext3 defaults 0 0
[root@localhost beinan]# reiserfstune -l /10 /dev/hda10
/10 /mnt/hda10 reiserfs defaults 0 0
[root@localhost beinan]# mkdir /mnt/hda5/ 注:先创建一个挂载目录;
[root@localhost beinan]# chmod 777 /mnt/hda5/ 注:设置/mnt/hda5的权限为任何用户可写可读可执行;这样所有的用户都能在写入;
/dev/hda5 /mnt/hda5 reiserfs defaults 0 0
[root@localhost beinan]# fsck.reiserfs /dev/hda10
reiserfsck 3.6.19 (2003 www.namesys.com)
*************************************************************
** If you are using the latest reiserfsprogs and it fails **
** please email bug reports to [email protected], **
** providing as much information as possible -- your **
** hardware, kernel, patches, settings, all reiserfsck **
** messages (including version), the reiserfsck logfile, **
** check the syslog file for any related information. **
** If you would like advice on using this program, support **
** is available for $25 at www.namesys.com/support.html. **
*************************************************************
Will read-only check consistency of the filesystem on /dev/hda10
Will put log info to 'stdout'
Do you want to run this program?[N/Yes] (note need to type Yes if you do):Yes
###########
reiserfsck --check started at Wed Sep 14 08:54:17 2005
###########
Replaying journal..
Reiserfs journal '/dev/hda10' in blocks [18..8211]: 0 transactions replayed
Checking internal tree..finished
Comparing bitmaps..finished
Checking Semantic tree:
finished
No corruptions found 注:没有发现错误;
There are on the filesystem:
Leaves 2046
Internal nodes 15
Directories 130
Other files 2305
Data block pointers 1863657 (70565 of them are zero)
Safe links 0
###########
reiserfsck finished at Wed Sep 14 08:54:33 2005
###########
-p Automatic repair (no questions) 注:自动修复文件系统存在的问题;
-y Assume "yes" to all questions 注:如果文件系统有问题,会跳出提示是否修复,如果修复请按y;
-c Check for bad blocks and add them to the badblock list 注:对文件系统进行坏块检查;这是一个极为漫长的过程;
-n Make no changes to the filesystem 注:不对文件系统做任何改变,只要扫描,以检测是否有问题;
[root@localhost beinan]# fsck.ext3 -p /dev/hda6