- 论坛徽章:
- 0
|
linux的内核采用了称之为虚拟文件系统(VFS)的技术。LINUX文件系统标准(Linux File System Standard,FSSTND)于1994年完成,它规划了存放在LINUX文件系统中的目录以及使用方法。目的是使开发者能编写LINUX通用程序,这些程序不必担心LINUX发布版本的更新。
要使用文件系统,一般要遵循如下的过程。
a.在硬盘上创建分区,可以使用fdisk命令进行;
b.在分区上建立文件系统,类似于在windows下进行格式化操作
c.挂装文件系统到系统中,在分区中创建好文件系统后就可以将该分区挂装到系统中的相应目录以便使用。挂装文件系统可以使用mount命令,如果需要系统每次启动时都自动挂装该文件系统则需要在文件“/etc/fstab”中添加相应的设置行。
d.卸装文件系统,对于可移动介质上的文件系统,使用完毕后需要使用umount命令实施卸装操作。
分区:linux 环境下通常使用fdisk工具对磁盘进行分区。fdisk命令的常用格式:#fdisk 进入fdisk的交互操作方式,对指定的硬盘进行分区操作。 #fdisk -l 在命令行方式下显示指定硬盘的分区表信息。
在fdisk的交互操作方式下可以使用若干子命令,如下:
a 调整硬盘的启动分区
d 删除一个硬盘分区
l 列出所有支持的分区类型
m 列出所有命令
n 创建一个新的分区
p 列出硬盘分区表
q 退出fdisk,不保存更改
t 更改分区类型
u 切换所显示的分区大小的单位
w 把设置写入硬盘分区表,然后退出
分区操作举例:
//对系统中第二块SCSI接口的硬盘进行分区
#fdisk /dev/sdb
//创建新的分区
Command (m for help):n
Command action
e extended
p primary partition (1-4)
p //输入p创建主分区
Partition number (1-4) :1 //输入分区编号1
First cylinder (1-522,default 1): //直接回车,从硬盘起始柱面创建分区
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522,default 522):
//直接回车,分区大小截至到最后一个柱面
Using default value 522
//显示当前分区表
Command (m for help):p
Disk /dev/sdb: 4294 MB,4294967296 bytes
255 heads, 63 sectors/track,522 cylinders
Units = cylinders of 16065 * 512 =8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 522 4192933+ 83 Linux
//删除已经存在的分区
Command (m for help):d
Selected partition 1
//由于当前只有一个分区,所以没有被删除分区的编号提示选择,直接将此分区删除
//若当前存在多个分区,将出现分区的编号提供选择
//显示当前分区表,分区已经被删除
Command (m for help):p
Disk /dev/sdb:4294 MB,4294967296 bytes
255 heads, 63 sectors /track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
//创建大小为500MB的1号主分区
Command (m for help) :n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):1
First cylinder (1-522, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-522, default 522):+500M
//对所有磁盘剩余空间创建编号为2的扩展分区
Command (m for help) :n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4) :2
Fisrt cylinder (63-522, default 63):
Using default value 63
Last cylinder or +size or +sizeM or +sizeK (63-522, default 522):
Using default value 522
//创建大小为400MB的逻辑分区
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (63-522, default 63):
Using default value 63
Last cylinder or +size or +sizeM or +sizeK (63-522, default 522): +400M
//创建大小为256MB的逻辑分区
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (113-522,default 113):
Using default value 113
Last cylinder or +size or +sizeM or +sizeK (113-522,default 522):+256M
//显示当前分区表
Command (m for help):p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders or 16065 * 512 =8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux
/dev/sdb2 63 522 3694950 5 Extended
/dev/sdb5 63 112 401593+ 83 Linux
/dev/sdb6 113 144 257008+ 83 Linux
//将5号分区更改为FAT32类型
Command (m for help):t
Partition number (1-6):5
Hex code (type L to list codes ):C
Changed system type of partition 5 to c (Win95 FAT32 (LBA))
//将6号分区更改为swap类型
Command (m for hekp):t
Partition number (1-6):6
Hex code (type L to list codes):82
Changed system type of partition 6 to 82 (Linux swap)
//显示当前分区表,类型已经更改
Command (m for help):p
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders or 16065 * 512 =8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux
/dev/sdb2 63 522 3694950 5 Extended
/dev/sdb5 63 112 401593+ c Win95 FAT32 (LBA)
/dev/sdb6 113 144 257008+ 82 Linux swap
//将当前的分区设置保存,并退出fdisk
Command (m for help):w
The partition table has ben altered!
Calling ioct1() to re-read partition table.
WARNING:Re-reading the partition table failed with error 16:Device or resource
busy.
The kernel still uses the old talbe.
The new table will be used at the net reboot.
WARNING: If you have created or modified any DOS 6.x
partitions,please see the fdisk manual page for additional
information.
Syncing disks.
//在非交互状态下显示当前的分区表信息
[root@rh9 root]# fdisk -l /dev /sdb
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders or 16065 * 512 =8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 62 497983+ 83 Linux
/dev/sdb2 63 522 3694950 5 Extended
/dev/sdb5 63 112 401593+ c Win95 FAT32 (LBA)
/dev/sdb6 113 144 257008+ 82 Linux swap
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/97501/showart_1988045.html |
|