第七章:文件系统管理

1.磁盘分区(fdisk)

命令:

fdisk

常用参数:

-l:查看分区详细信息

例:把/dev/sda进行分区,划分出一个/dev/sda3


[[email protected] ~]# fdisk /dev/sda

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until  you decide to write them.

Be careful before using the write  command.

Command (m for help):

//此处可以根据参数的不同,查看相应的信息。常用参数如下:

------------------------------------------常用参数-----------------------------------------------------

m:帮助

p: 显示分区表

n:添加新分区

t: 改变分区文件系统类型

d: 删除分区

w: 保存分区并退出

q: 不保存退出

-------------------------------------------分区操作------------------------------------------------------------

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400  bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes  / 512 bytes

I/O size (minimum/optimal): 512 bytes /  512 bytes

Disk label type: dos

Disk identifier: 0x000b2b59

Device Boot      Start         End      Blocks    Id  System

/dev/sda1   *         2048      411647      204800    83  Linux

/dev/sda2          411648   127502335    63545344    8e  Linux LVM

//查看/dev/sda现有的分区信息

Command (m for help): n

//输入n进行分区

Partition type:

p   primary (2 primary, 0  extended, 2 free)

e   extended

//分区类型,p为主分区,最多4个。e为逻辑分区。

Select (default p): p

Partition number (3,4, default 3): 3

//划分第三个主分区

First sector (127502336-209715199,  default 127502336):

Using default value 127502336

Last sector, +sectors or +size{K,M,G}  (127502336-209715199, default 209715199): +200M

//大小为200M

Partition 3 of type Linux and of size 200  MiB is set

Command (m for help): p

Disk /dev/sda: 107.4 GB, 107374182400  bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes  / 512 bytes

I/O size (minimum/optimal): 512 bytes /  512 bytes

Disk label type: dos

Disk identifier: 0x000b2b59

Device Boot      Start         End      Blocks    Id  System

/dev/sda1   *         2048      411647      204800    83  Linux

/dev/sda2          411648   127502335    63545344    8e  Linux LVM

/dev/sda3       127502336   127911935      204800    83  Linux

Command (m for help): w

//保存退出

The partition table has been altered!

Calling ioctl() 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 table. The  new table will be used at

the next reboot or after you run  partprobe(8) or kpartx(8)

Syncing disks.

划分完毕后,使用参数再次查看划分的分区


[[email protected] ~]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400  bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes  / 512 bytes

I/O size (minimum/optimal): 512 bytes /  512 bytes

Disk label type: dos

Disk identifier: 0x000b2b59

Device Boot      Start         End      Blocks    Id  System

/dev/sda1   *         2048      411647      204800    83  Linux

/dev/sda2          411648   127502335    63545344    8e  Linux LVM

/dev/sda3       127502336   127911935      204800    83  Linux

格式化分区/dev/sda3


[[email protected] ~]# mkfs.ext4 /dev/sda3

mke2fs 1.42.9 (28-Dec-2013)

Could not stat /dev/sda3 --- No such file  or directory

The  device apparently does not exist; did you specify it correctly?

----------------------------------------------查看分区是否成功-------------------------------------------------

[[email protected] ~]# cat /proc/partitions

major minor  #blocks   name

2        0          4 fd0

11        0    4139008 sr0

8        0  104857600 sda

8        1     204800 sda1

8        2   63545344 sda2

如上:进行格式化时,提示设备分区不存在。查看分区表,也没有此分区信息。这是为什么呢?

这是因为在Linux中,虽然分区已经划分完毕,但是新分区信息还没有写进内核,所以内核不能识别,也就不能使用。要让内核识别此分区,有两种办法:

  • 重启
  • 使用partprobe 命令

以上两种方法都能把分区信息写进系统内核,让系统识别。但是我们推荐使用第二种,不用重启系统。更快、更便捷,同时也迎合Linux的一大优势,做到基本不用重启系统。


[[email protected] ~]# partprobe  /dev/sda

[[email protected] ~]# cat /proc/partitions

major minor  #blocks   name

2        0          4 fd0

11        0    4139008 sr0

8        0  104857600 sda

8        1     204800 sda1

8        2   63545344 sda2

8         3     204800 sda3

//分区表中出现sda3

[[email protected] ~]# mkfs.ext4 /dev/sda3

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

51200 inodes, 204800 blocks

10240 blocks (5.00%) reserved for the  super user

First data block=1

Maximum filesystem blocks=33816576

25 block groups

8192 blocks per group, 8192 fragments per  group

2048 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729

Allocating group tables: done

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem  accounting information: done

分区完毕之后,如何使用呢?下个实验,将介绍到如何挂载使用。

2.文件系统的挂载

Linux中的文件使用与windows不同,文件(或设备)的使用要先挂载。所以,本章我们详细介绍文件的挂载。

2.1.mount直接挂载

这个是最简单的挂载,也是直接挂载,仅需简单的一条命令即可挂载使用。

例:把/dev/sda3挂载到/share


-----------------------------------------挂载前查看挂载信息----------------------------------------

[[email protected] ~]# df

Filesystem            1K-blocks    Used Available Use% Mounted on

/dev/mapper/rhel-root  61410000 3019196  58390804    5% /

devtmpfs                 496084       0     496084   0% /dev

tmpfs                    505392       0     505392   0% /dev/shm

tmpfs                    505392    7136     498256   2% /run

tmpfs                    505392       0     505392   0% /sys/fs/cgroup

/dev/sda1                201388  106044      95344  53% /boot

//   /dev/sda3没有挂载

-------------------------------------------挂载/dev/sda3到/share------------------------------------

[[email protected] ~]# mkdir /share

//创建挂载点

[[email protected] ~]#  mount /dev/sda3 /share/

[[email protected] ~]#  df

Filesystem            1K-blocks    Used Available Use% Mounted on

/dev/mapper/rhel-root  61410000 3018988  58391012    5% /

devtmpfs                 496084       0     496084   0% /dev

tmpfs                    505392       0     505392   0% /dev/shm

tmpfs                    505392    7140     498252   2% /run

tmpfs                    505392       0     505392   0% /sys/fs/cgroup

/dev/sda1                201388  106044      95344  53% /boot

/dev/sda3                 95054    1550      86336   2% /share

注:

  • 此挂载只是暂时的,系统重启后失效
  • 如要卸载挂载的设备,用umount以同样的方法卸载。

2.2./etc/fstab自动挂载

鉴于mount命令的直接挂载为临时挂载,所以引进了/etc/fstab文件,/etc/fstab可以实现系统重启后自动挂载。系统在重启后,会检查此文件中需要挂载的设备,在重启过程中进行自动挂载,实现开机自动挂载功能。

此文件中默认有系统的几个必须挂载项,如下:


[[email protected] ~]# cat /etc/fstab

#

# /etc/fstab

# Created by anaconda on Thu Dec 11  14:38:57 2014

#

# Accessible filesystems, by reference,  are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8),  mount(8) and/or blkid(8) for more info

#

/dev/mapper/rhel-root   /                       xfs     defaults        1 1

UUID=469e7785-f327-4d93-abd4-62d408e45b8a  /boot                   xfs     defaults        1 2

/dev/mapper/rhel-swap   swap                    swap    defaults        0 0

说明:

  • /dev/mapper/rhel-root:为物理挂载设备
  • /                  :挂载点
  • xfs                :文件系统格式
  • defaults            :缺省设置
  • 1:是否检测,1为检测,0为不检测.该选项被“dump”命令用来检查一个文件系统应该以多块频率进行转储,若不需要转储就设置该字段为0;
  • 1:检测顺序,优先检测数字大的(0/1/2)。该字段被fsck命令用来决定在启动时需要被扫描的文件系统的顺序,根文件系统“/”对应该字段的值应该为1,其它文件系统应该为2.若该文件系统无需在启动时扫描,则设置该字段为0.

现在,继续1.1实验的后续,设置开机自动挂载


#

# /etc/fstab

# Created by anaconda on Thu Dec 11  14:38:57 2014

#

# Accessible filesystems, by reference,  are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8),  mount(8) and/or blkid(8) for more in

fo

#

/dev/mapper/rhel-root   /                       xfs     defaults        1

1

UUID=469e7785-f327-4d93-abd4-62d408e45b8a  /boot                   xfs

defaults        1 2

/dev/mapper/rhel-swap   swap                    swap    defaults        0

0

/dev/sda3/      /share          ext4  defaults   0 0

如上,写进文件之后就可以实现开机自动挂载了。

2.3.autofs挂载

Autofs与mount/Umount的不同之处在于,它是一种看守程序。如果它检测到用户正试图访问一个尚未挂载的文件系统,它就会自动检测该文件系统,如果存在,那么Autofs会自动将其挂载。另一方面,如果它检测到某个已挂载的文件系统在一段时间内没有被使用,那么Autofs会自动将其卸载。因此一旦运行了Autofs后,用户就不再需要手动完成文件系统的挂载和卸载。

2.3.1.autofs的安装

RHEL7之前的系统,缺省已安装autofs服务的,但是RHEL7缺省未安装。


[[email protected]  ~]# rpm -q autofs

package autofs  is not installed

---------------------------------------------yum安装autofs----------------------------------------

<yum仓库的配置见【软件包的安装与管理章节】>

[[email protected]  ~]# yum -y install autofs

Loaded plugins:  langpacks, product-id, subscription-manager

This system is  not registered to Red Hat Subscription Management. You can use  subscription-manager to register.

base                                               | 4.1 kB     00:00

(1/2):  base/group_gz                                 | 134 kB   00:00

(2/2):  base/primary_db                               | 3.4 MB   00:00

Resolving  Dependencies

--> Running  transaction check

---> Package  autofs.x86_64 1:5.0.7-40.el7 will be installed

-->  Processing Dependency: libhesiod.so.0()(64bit) for package:  1:autofs-5.0.7-40.el7.x86_64

--> Running  transaction check

---> Package  hesiod.x86_64 0:3.2.1-3.el7 will be installed

--> Finished  Dependency Resolution

Dependencies  Resolved

=========================================================================

Package        Arch           Version                Repository    Size

=========================================================================

Installing:

autofs         x86_64         1:5.0.7-40.el7         base         550 k

Installing for  dependencies:

hesiod         x86_64         3.2.1-3.el7            base          30 k

Transaction  Summary

=========================================================================

Install  1 Package (+1 Dependent package)

Total download  size: 579 k

Installed size:  3.6 M

Downloading  packages:

-------------------------------------------------------------------------

Total                                       7.7  MB/s | 579 kB  00:00

Running transaction  check

Running  transaction test

Transaction  test succeeded

Running  transaction

Installing : hesiod-3.2.1-3.el7.x86_64                             1/2

Installing :  1:autofs-5.0.7-40.el7.x86_64                          2/2

base/productid                                    | 1.6 kB     00:00

Verifying   : hesiod-3.2.1-3.el7.x86_64                             1/2

Verifying   : 1:autofs-5.0.7-40.el7.x86_64                          2/2

Installed:

autofs.x86_64 1:5.0.7-40.el7

Dependency  Installed:

hesiod.x86_64 0:3.2.1-3.el7

Complete!

Autofs是一个服务,有两个配置文件,都在/etc下,分别为auto.master、auto.misc


[[email protected] ~]# ls /etc/auto

autofs_ldap_auth.conf  auto.master.d/         auto.net

auto.master             auto.misc              auto.smb

2.3.2.RHEL7之前系统的autofs挂载

首先查看第一个配置文件auto.master


#

# Sample auto.master file

# This is an automounter map and it has  the following format

# key [ -mount-options-separated-by-comma  ] location

# For details of the format look at  autofs(5).

#

/misc          /etc/auto.misc

   |               |

挂载点主目录     挂载点的配置文件

/share        /etc/auto.share

#

# NOTE: mounts done from a hosts map will  be mounted with the

#        "nosuid" and "nodev" options unless the  "suid" and "dev"

#        options are explicitly given.

#

/net     -hosts

#

+dir:/etc/auto.master.d

#

# Include central master map if it can be  found using

# nsswitch sources.

#

# Note that if there are entries for /net  or /misc (as

# above) in the included master map any  keys that are the

# same will not be seen as the first read  key seen takes

# precedence.

#

+auto.master

如上:挂载点主目录可以自己手动创建,也可以不创建,重启autofs服务后会自动创建。挂载点配置文件可以与默认的一样,也可以自己创建。如下,为我们自己创建的第二个配置文件auto.share:


[[email protected] ~]# cp -p /etc/auto.misc  /etc/auto.share

//直接复制默认的配置文件即可,然后根据自己的需要更改

[[email protected] ~]# vim /etc/auto.share

#

# This is an automounter map and it has  the following format

# key [ -mount-options-separated-by-comma  ] location

# Details may be found in the autofs(5)  manpage

# the following entries are samples to  pique your imagination

#linux          -ro,soft,intr           ftp.example.org:/pub/linux

#boot           -fstype=ext2            :/dev/hda1

#floppy         -fstype=auto            :/dev/fd0

#floppy         -fstype=ext2            :/dev/fd0

#e2floppy       -fstype=ext2            :/dev/fd0

#jaz            -fstype=ext2            :/dev/sdc1

#removable      -fstype=ext2            :/dev/hdd

<下面一行为自己添加的>

server          -fstype=ext4,rw         :/dev/sda3

  |                |       |            |

真实挂载点    文件系统类型 权限       要挂载的物理设备

<真实挂载点不需要自己手动创建,当需要用到时系统会自动创建>

------------------------------------------重启服务并验证挂载------------------------------------------

[[email protected] ~]# service autofs restart

Stopping automount:                                         [  OK  ]

Starting automount:                                         [  OK  ]

[[email protected] ~]# ls /share/

[[email protected] ~]#

//查看挂载主目录,什么也没有,接下来查看挂载信息

[[email protected] ~]# df

Filesystem            1K-blocks    Used Available Use% Mounted on

/dev/mapper/rhel-root  61410000 3049104  58360896    5% /

devtmpfs                 496084       0     496084   0% /dev

tmpfs                    505392       0     505392   0% /dev/shm

tmpfs                    505392    7148     498244   2% /run

tmpfs                    505392       0     505392   0% /sys/fs/cgroup

/dev/sda1                201388  106044      95344  53% /boot

/dev/sr0                4138442 4138442         0 100% /mnt

//此时设备没有挂载。接下来直接查看真实挂载点目录

[[email protected] ~]# ls /share/server

lost+found

//查看真实挂载点,此时,有内容显示,再查看挂载设备信息

[[email protected] ~]# df

Filesystem            1K-blocks    Used Available Use% Mounted on

/dev/mapper/rhel-root  61410000 3049104  58360896    5% /

devtmpfs                 496084       0     496084   0% /dev

tmpfs                    505392       0     505392   0% /dev/shm

tmpfs                    505392    7148     498244   2% /run

tmpfs                    505392       0     505392   0% /sys/fs/cgroup

/dev/sda1                201388  106044      95344  53% /boot

/dev/sr0                4138442 4138442         0 100% /mnt

/dev/sda3                 95054    1550      86336   2% /share/server

//设备已经挂载

注:autofs的挂载,当需要的时候才会挂载,不需要时,默认300s自动卸载。

2.3.3.RHEL7系统的autofs挂载

RHEL7的autofs的挂载,方法可以与之前系统的挂载方法一样,但是也有另一种方法,那就是第一个配置文件的不同,如下:


------------------------------------------------查看auto.master文件--------------------------------------

[[email protected] ~]# vim /etc/auto.master

# Sample auto.master file

# This is an automounter map and it has  the following format

# key [ -mount-options-separated-by-comma  ] location

# For details of the format look at  autofs(5).

#

/misc    /etc/auto.misc

#

# NOTE: mounts done from a hosts map will  be mounted with the

#        "nosuid" and "nodev" options unless the "suid"  and "dev"

#        options are explicitly given.

#

/net     -hosts

#

#  Include /etc/auto.master.d/*.autofs

#

+dir:/etc/auto.master.d

#

# Include central master map if it can be  found using

# nsswitch sources.

#

# Note that if there are entries for /net  or /misc (as

# above) in the included master map any  keys that are the

# same will not be seen as the first read  key seen takes

# precedence.

#

+auto.master

注意到上面的加粗字体。第一个配置文件的设置也可以是/etc/ auto.master.d下以.autofs结尾的文件。那么/etc/ auto.master.d到底有什么呢?


[[email protected] ~]# cd /etc/auto.master.d/

[[email protected] auto.master.d]# ls

[[email protected] auto.master.d]#

如上,此文件下什么也没有,也就是说,如果要使用这种方式,需自己创建。

创建所需配置文件


[[email protected] auto.master.d]# pwd

/etc/auto.master.d

[[email protected] auto.master.d]# vim  share.autofs

/share         /etc/auto.share

|               |

挂载主目录      挂载点配置文件

~

~

~

//wq!保存退出

接下来创建另一个配置文件/etc/auto.share


[[email protected] etc]# cp -p auto.misc  auto.share

[[email protected] etc]# vim auto.share

#

# This is an automounter map and it has  the following format

# key [ -mount-options-separated-by-comma  ] location

# Details may be found in the autofs(5)  manpage

# the following entries are samples to  pique your imagination

#linux          -ro,soft,intr           ftp.example.org:/pub/linux

#boot           -fstype=ext2            :/dev/hda1

#floppy         -fstype=auto            :/dev/fd0

#floppy         -fstype=ext2            :/dev/fd0

#e2floppy       -fstype=ext2            :/dev/fd0

#jaz            -fstype=ext2            :/dev/sdc1

#removable      -fstype=ext2            :/dev/hdd

server          -fstype=ext4,rw         :/dev/sda3

接下来,重启服务,验证挂载


[[email protected] etc]# systemctl restart  autofs.service

[[email protected] etc]#

[[email protected] etc]# ls /share/server

lost+found

[[email protected] etc]# df

Filesystem            1K-blocks    Used Available Use% Mounted on

/dev/mapper/rhel-root  61410000 3049376  58360624    5% /

devtmpfs                 496084       0     496084   0% /dev

tmpfs                    505392       0     505392   0% /dev/shm

tmpfs                    505392    7148     498244   2% /run

tmpfs                    505392       0     505392   0% /sys/fs/cgroup

/dev/sda1                201388  106044      95344  53% /boot

/dev/sr0                4138442 4138442         0 100% /mnt

/dev/sda3                 95054    1550      86336   2% /share/server

//挂载成功。

3.文件系统的acl设置

Linux系统中,不仅文件可以设置acl权限,而且分区也可以acl权限。但是,缺省情况下,分区的acl功能是没有开启的(RHEL7之前的系统),如果要设置acl权限,需要为分区开启acl功能。开启方式如下:


[[email protected] ~]# vim /etc/fstab

/dev/sda3              /mnt                    iso9660 defaults,acl     0 0

//在defaults后加上”,”+”acl“

[[email protected] ~]# mount -o remount /dev/cdrom

//重新挂载文件系统

这样,文件系统的acl权限就打开了,可以通过以下命令查看


[[email protected] etc]# tune2fs -l /dev/sda3

//查看分区详细信息

tune2fs 1.42.9 (28-Dec-2013)

Filesystem volume name:   <none>

Last mounted on:          <not available>

Filesystem UUID:          3fa9fa6b-e967-4748-9229-206a3ae590f2

Filesystem magic number:  0xEF53

Filesystem revision #:    1 (dynamic)

Filesystem features:      has_journal ext_attr resize_inode  dir_index filetype needs_recovery extent 64bit flex_bg sparse_super huge_file  uninit_bg dir_nlink extra_isize

Filesystem flags:         signed_directory_hash

Default  mount options:    user_xattr acl

//acl功能打开

Filesystem state:         clean

…………………..

Acl权限打开之后,即可以通过setacl命令设置(设置方式见权限管理--ACL)。

4.用户迁移

现实生产环境中,可能遇到这样的情况:一台Linux上存储着公司的员工账户(有可能上万个甚至更多)。现在,由于发展需要,要升级硬件。此时问题就来了,上万个用户在新的机器上重新创建,显然是个体力活,不太可能,那么有什么方式来实现简单快捷的迁移呢?

下面就来介绍一个命令:newusers,通过此命令来实现用户迁移功能

假设现在有两台机子,192.168.10.10&192.168.10.250,前者为升级的硬件(新设备),后者为需要迁移的设备(待升级设备,即旧设备),如何实现呢?如下:


-------------------------------------先在250设备上创建几个实验用户---------------------------------

[[email protected] ~]# useradd user1

[[email protected] ~]# useradd user2

[[email protected] ~]# useradd user3

[[email protected] ~]# id user1

uid=501(user1) gid=501(user1)  groups=501(user1)

[[email protected] ~]# id user2

uid=502(user2) gid=502(user2)  groups=502(user2)

[[email protected] ~]# id user3

uid=503(user3) gid=503(user3)  groups=503(user3)

-----------------------------------从250设备复制用户配置文件到10设备------------------------------

[[email protected] ~]# scp  [email protected]:/etc/passwd   /tmp/

//使用scp命令,在10设备上把250上的用户配置文件“拉”过来

The authenticity of host ‘192.168.10.250  (192.168.10.250)‘ can‘t be established.

RSA key fingerprint is  af:63:d5:cf:76:af:71:02:22:3f:0d:7c:7e:eb:73:5e.

Are you sure you want to continue  connecting (yes/no)? yes

Warning: Permanently added  ‘192.168.10.250‘ (RSA) to the list of known hosts.

[email protected]‘s password:

passwd                                 100%  2029     2.0KB/s   00:00

[[email protected] ~]# scp  [email protected]:/etc/shadow /tmp/

[email protected]‘s password:

shadow                                 100%  1131     1.1KB/s   00:00

[[email protected] ~]# scp  [email protected]:/etc/gshadow /tmp/

[email protected]‘s password:

gshadow                                100%  769      0.8KB/s   00:00

[[email protected] ~]# scp  [email protected]:/etc/group /tmp/

[email protected]‘s password:

group                                  100%  941      0.9KB/s   00:00

[[email protected] ~]# ls /tmp/

group   gshadow  passwd  shadow

---------------------------------------验证此时能够使用迁移过来的用户-----------------------------

[[email protected] ~]# id user1

id: user1: no such user

[[email protected] ~]# id user2

id: user2: no such user

[[email protected] ~]# id user3

id: user3: no such user

//很明显,不能使用

--------------------------------------------使用newusers命令---------------------------------------

[[email protected] ~]# cd /tmp/

[[email protected] tmp]# newusers passwd

[[email protected] tmp]# id user1

uid=501(user1) gid=501(user1)  groups=501(user1)

[[email protected] tmp]# id user2

uid=502(user2) gid=502(user2)  groups=502(user2)

[[email protected] tmp]# id user3

uid=503(user3) gid=503(user3)  groups=503(user3)

//如上,现在用户可以使用了

-----------------------------------------登录用户验证--------------------------------------------------

[[email protected] tmp]# su - user1

-bash-4.2$

//虽然可以使用,但是很明显,此时的用户没有shell环境

--------------------------------------为用户提供本地shell环境------------------------------------

-bash-4.2$ cp -p /etc/skel/.*   .

cp: omitting directory ‘/etc/skel/.’

cp: omitting directory ‘/etc/skel/..’

cp: omitting directory  ‘/etc/skel/.mozilla’

//复制本地的用户shell环境到新用户的家目录

-------------------------------------退出,重登验证----------------------------------------------------------

[[email protected] tmp]# su - user1

Last login: Tue May  5 19:16:34 CST 2015 on pts/0

[[email protected] ~]$

//shell环境调用成功。

时间: 2024-08-02 09:17:43

第七章:文件系统管理的相关文章

第8章 文件系统管理(1)_文件系统和常用命令

1. 文件系统 (1)ext2文件系统 ext2是ext文件系统的升级版本,RedHat Linux7.2版本以前的系统默认都是ext2文件系统.1993年发布,最大支持16TB的分区和最大2TB的文件(1TB=1024GB=1024*1024KB) (2)ext3文件系统 ext3文件系统是ext2文件系统的升级版本,最大的区别就是带日志功能,以在系统突然停止时提高文件系统的可靠性.支持最大16TB的分区和最大2TB的文件. (3)ext4文件系统 它是ext3文件的升级版.ext4在性能.伸

网络操作系统 第五章 文件系统管理

本章小结 本章主要介绍了Windows和Linux所支持的文件系统.介绍了Windows系统中使用的FAT和NTFS的特点和性能. 习题 1.比较说明FAT文件系统和NTFS文件系统的特点. FAT是文件分配表是用来记录文件所在位置的表格,存储的数量卷: 簇大小X最大簇数量=最大卷大小 缺点: (1)容易受损害 (2)单用户 (3)费最佳更新的策略 (4)没有防止碎片的措施. NTFS文件系统是个非常严格的系统,它的特性为: 提供文件和文件夹的安全性. 可用长文件名 支持加密 高可靠性 坏簇射

第8章 文件系统管理(2)_挂载、fdisk分区及分配swap

3. fdisk分区 3.1 fdisk命令分区过程 (1)添加新硬盘 (2)查看新硬盘#fdisk –l (3)使用fdisk命令分区:#fdisk /dev/sdb Fdisk交互指令说明 命令 说明 a 设置可引导标记 b 编辑bsd磁盘标签 c 设置DOS操作系统兼容标记 d 删除一个分区 l 显示己知的文件系统类型.82为linux swap,83为linux分区 m 显示帮助菜单 n 新建分区 o 建立空白DOS分区表 p 显示分区列表 q 不保存退出 s 新建空白SUN磁盘标签 t

第七章 文件与I/O(4)

文件共享 打开文件内核数据结构 一个进程两次打开同一个文件 一个进程能打开1024个文件描述符,没打开一个文件,内核会生成一个文件表,文件表中的v节点指针指向v节点表,v节点部分信息就是stat函数返回的信息,i节点信息,当我们打开一个文件的时候,会将文件系统中i节点信息拷贝到v节点信息对应的i节点信息中(i节点号,文件存在那一块中,) ? #include <stdlib.h> #include <stdio.h> #include <unistd.h> #inclu

第七章 文件的操作

@文件文档操作 用open()打开. open(“文件”,格式) 格式有只读(r),只写(w),读写(r+),或者写读(w+):r+是读写,是文件中比较常用的类型. 创建并写入文件. 或者直接写入文件. 读取文件全部内容:文件.read() 读取每一行:文件.readline() 读取所有行数:文件.readlines() 文件在写入过程中,所写入的数据没有保存的话是读取不出来的:所以需要close()关闭或者flush()刷新操作,才能正常读取所写入的数据. 模块pickle的用法: 在读取文

Linux 磁盘、文件系统管理

2016-08-25 本章内容 □磁盘结构 分区类型 管理分区 管理文件系统 挂载设备 管理虚拟内存 第一篇:Linux磁盘管理 概述: 计算机的五大组成部件:输入设备.输出设备.存储器.运算器.控制器,其中,输入.输出设备称之为I/O设备,运算器和控制器称之为CPU ,存储器如内存.硬盘等.计算机只有CPU和内存其实就可以独立完成计算任务了,只是其输入输出都在内存中实现,但是,内存属于随机存储单元,断点就会导致数据丢失,因此,我们就通过其他辅助设备来弥补内存的不足,这些辅助设备称之为外存,如:

linux &nbsp; 第七章 磁盘和文件系统管理(一)

linux 第七章磁盘和文件系统管理(一) 享受生活 热爱挑战 明远分享 每章一句话: 在别人光鲜的背后有着太多太多,别人不知道的痛苦,自己不喜欢的人,以微笑面对,默默地为他祝福:对于喜欢的人,真情流露,真诚相待.人在做天在看,冥冥中自有因果安排,永远保持一颗善良的心,持续做对的事情,不断地提醒自己,低调做人,高调做事. 要求:    跟着做一下吧 看不清图片就点一下图片 一,关机后添加一块20GB的SCSI磁盘,重新开机进入RHEL 5系统 二,分区并格式化 1, 使用fdisk命令对新硬盘进

第七章、epub文件处理 -- 解析 .xhtml文件 (一)

第七章.epub文件处理 -- 解析 .xhtml文件 (一) 本章将介绍代码如何利用ZLTextPlainModel类来分别处理.xhtml文件中的文本信息与标签信息. 本章涉及的核心类是ZLTextPlainModel类.ZLTextWritablePlainModel类.CachedCharStorage类.XHTMLTagAction接口实现类 .xhtml文件中包含着两种信息:文本信息与标签信息.我们需要先正确解析出标签信息代表的结构,才能正确得将文本信息显示在屏幕上. 举个例子:(这

Linux运维 第二阶段 (七)高级文件系统管理

Linux运维第二阶段(七)高级文件系统管理 一.磁盘配额: 多用户共同使用一个硬盘,管理员应适当限制硬盘的空间,以妥善分配系统资源. #grepCONFIG_QUOTA /boot/config-2.6.32-279.el6.i686 #rpm–qa | grep quota 用户配额和组配额:磁盘容量限制和文件个数限制:软限制和硬限制:宽限时间. 注:如果用户的空间处于软限制和硬限制之间,系统会在用户登录时警告将满,宽限时间默认7天,如果达到了宽限时间未调整,软限制就会升级为硬限制. #mo

Linux常用命令(七)磁盘和文件系统管理

 Linux常用命令(七)磁盘和文件系统管理 一.管理磁盘及分区   1.检测并确认新硬盘 fdisk –l命令--列出当前系统中所有硬盘设备及其分区的信息 上述信息中包含了各硬盘的整体情况和分区情况 ■ Device:分区的设备文件名称 ■ Boot:是否是引导分区.是,则有"*"标识. ■ Start:该分区在硬盘中的起始位置(柱面数). ■ End:该分区在硬盘中的结束位置(柱面数). ■ Blocks:分区的大小,以Blocks(块)为单位,默认的块大小为1024字节. ■ I