1.分区类型
主分区 :总共最多只能分四个
扩展分区:只能有一个,也算作主分区的一种,也就是说主分区加扩展分区最多有四个。但是扩展分区不能存储数据和格式化,必须再划分成逻辑分区才能使用。
逻辑分区:逻辑分区是在扩展分区中划分的,如果是IDE硬盘,Linux最多支持59个逻辑分区,如果是SCSI硬盘Linux最多支持11个逻辑分区
  主分区1 sda1 主分区2 sda2 主分区3 sda3 第四个分区分为扩展分区 sda4 逻辑分区 sda5 sda6 sda7
  逻辑分区确从5 6 7开始
因为 分区号1 2 3 4只能给主分区或者扩展分区使用
2.文件系统
 
目录结构
     linux 目录结构xmind 思维导图
inode 与 dentry

1)索引结点
索引结点(indexnode,简称ingde)的实质是一个结构体,主要功能是保存文件的属性信息(如所有者、所属区、权限、文件大小、时间戳等),Linux系统中的每个文件都会被分配一个innode,当有文件创建时,系统会在inode表中获取一个空闲的inode,分配给这个文件,inode存储在inode表中,inode表存储inode和inode的编号(inumber),inode表在文件系统创建之时便被创建,因此文件系统中可存储的文件数量也在文件系统创建时已确定
2)目录项
Linux文件系统中的索引结点保存着文件的诸多属性信息,但并未保存文件的文件名。实际上,Linux系统中文件的文件名并不保存在文件中,而是保存在存放该文件的目录中。 Linux系统中定义了一个被称为目录项(dentry) 的结构体,该结构体主要存储文件的文件名与inode编号,系统通过读取目录项中的文件名和文件的inumber,来判断文件是否存在于这个目录中。dentry中允许同一个inode对应不同的文件名,但不允许相同的文件名对应不同的inode.
文件系统查看命令 df
 
du 统计目录或文件大小
 
ll -h 只会统计文件名大小,不会统计目录下+子目录的大小
df 与 du 命令的区别
 
文件系统修复命令fsck
   
显示磁盘状态命令 dumpe2fs

创建文件系统命令 mkf2es
 
挂载命令

mount
1 查询与自动挂载

2 挂载命令格式
 -o 特殊选项  test   要是想要执行 要改回来 
挂载U盘与光盘ios
挂载光盘
 1。 创建一个空文件 挂载点  把光盘放入虚拟机

这里看见ios的文件已经显示出来
2.卸载命令   为空 卸载完成
挂载 U盘
 自动识别 查询设备文件名 fdisk- l
 看到分配的是 dev/sdb  找到挂载点后 用mnt 再创建一个挂载点, 挂载   
linux 文件系统
 

链接文件
  软链接和硬链接到底有啥作用和区别
设备文件
 
文件操作

文件描述符
  文件描述符了解一下
文件I/O

open函数
 
 
read函数

write函数
lseek 函数

close函数
 案例5-2:使用open()函数打开或创建一个文件,将文件清空,使用write()函数在文件中写人数据,并使用read()函数将数据读取并打印。
//案例2:
1
2
3
4
5
6 int main()
7 {
8 int fd=0;
9 //路径中的目录若不存在将导致文件创建失败
10 char filename[20]="/home/itheima/a.txt";
11 //打开文件
12 fd=open(filename,O_RDWR|O_EXCL|O_TRUNC,S_IRWXG);
13 if(fd==-1){ //判断文件是否成功打开
14 perror("file open error.\n");
15 exit(-1);
16 }
17 //写数据
18 int len=0;
19 char buf[100]={0};
20 scanf("%s",buf);
21 len=strlen(buf);
22 write(fd,buf,len);
23 close(fd); //关闭文件
24 printf("---------------------\n");
25 //读取文件
26 fd=open(filename,O_RDONLY); //再次打开文件
27 if(fd==-1){
28 perror("file open error.\n");
29 exit(-1);
30 }
31 off_t f_size=0;
32 f_size=lseek(fd,0,SEEK_END); //获取文件长度
33 lseek(fd,0,SEEK_SET); //设置文件读写位置
34 while(lseek(fd,0,SEEK_CUR)!=f_size) //读取文件
35 {
36 read(fd,buf,1024);
37 printf("%s\n",buf);
38 }
39 close(fd);
40 return 0;
41 }

 
stat()函数
  案例5-3:使用stat()函数获取文件属性,并且输出文件的大小
int main()
{
struct stat sbuf;
int ret = 2;
ret = stat("a.out", &sbuf);
if (ret == -1){
perror("stat error:");
exit(1);
}
printf("len=%ld\n", sbuf.st_size);
return 0;
}
 得到文件a.out的大小
 
access函数
 
chmod()函数
 
truncate()函数
 
|