学校门户网站流程建设方案深圳福田区有哪些企业

当前位置: 首页 > news >正文

学校门户网站流程建设方案,深圳福田区有哪些企业,自己做图片的网站吗,wordpress的文章title在哪里目录 1、常见的linux文件系统 2、文件系统的组成 inode的内容#xff1a; 可以用stat命令#xff0c;查看某个文件的inode信息 inode的大小 inode号码 使用 ls -i来查看文件的inode号码 使用 df -i命令#xff0c;查看每个硬盘分区的inode总数和已经使用的数量#xff…目录 1、常见的linux文件系统 2、文件系统的组成 inode的内容 可以用stat命令查看某个文件的inode信息 inode的大小 inode号码 使用 ls -i来查看文件的inode号码 使用 df -i命令查看每个硬盘分区的inode总数和已经使用的数量可以使用df命令。  系统打开一个文件的整个过程 目录文件 block块 block调大 显示磁盘状态信息CentOS6用 dumpe2fs 分区名 CentOS7用xfs_info 分区名 磁盘分区工具与挂载 1、磁盘常识 2、磁盘两种分区表MBR和GPT 3、使用fdisk管理分区MBR分区表 1、fdisk -l 查看系统所有硬盘及分区 2、进入fdisk工具进行分区操作 4、使用gdisk管理分区gpt分区表  5、swap交换分区 5、将一个已经生效的分区改成swap分区 /etc/fstab 文件修复 1、常见的linux文件系统 extlinux中最早的文件系统由于在性能和兼容性上具有很多缺陷现在已经很少使用 ext2是ext文件系统的升级版本Red Hat Linux7.2版本以前的系统默认都是ext2文件系统于1993年发布支持最大16TB            的分区和最大2TB的文件1TB1024GB10241024KB ext3是ext2文件系统的升级版本最大的区别就是带日志功能以便系统突然停止时比如断电提高文件系统的可靠性            支持最大16TB的分区和最大2TB的文件。 ext4 是 ext3 文件系统的升级版。 ext4 在性能、 伸缩性和可靠性方面进行了大量改进。 ext4的变化可以说是翻天覆地的             比如向下兼容 ext3、最大 1EB 文件系统和 16TB 文件、无限数量子目录、 Extents 连续数据块概念、 多块分配、 延             迟分配、 持久预分配、 快速 FSCK、日志校验、 无日志模式、 在线碎片整理、 inode 增强、 默认启用 barrier 等。               它是 CentOS 6.x 的默认文件系统 xfs XFS 最早针对 IRIX 操作系统开发 是一个高性能的日志型文件系统 能够在断电以及操作系统崩溃的情况下保证文件系统数据的一致性。它是一个 64 位的文件系统后来进行开源并且移植到了 Linux 操作系统中目前 CentOS 7.x 将 XFSLVM逻辑卷管理作为默认的文件系统。据官方所称XFS 对于大文件的读写性能较好。单个文件系统最大可以支持8EB单个文件可以支持16TB swap swap 是 Linux 中用于交换分区的文件系统类似于 Windows 中的虚拟内存当内存不够用时使用交换分区暂时替代内存。一般大小为内存的 2 倍但是不要超过 2GB。它是 Linux 的必需分区 NFS NFS 是网络文件系统Network File System的缩写是用来实现不同主机之间文件共享的一种网络服务本地主机可以通过挂载的方式使用远程共享的资源 iso9660 光盘的标准文件系统。Linux 要想使用光盘必须支持 iso9660 文件系统  fat 就是 Windows 下的 fat16 文件系统在 Linux 中识别为 fat vfat 就是 Windows 下的 fat32 文件系统在 Linux 中识别为 vfat。支持最大 32GB 的分区和最大 4GB 的文件 NTFS 就是 Windows 下的 NTFS 文件系统不过 Linux 默认是不能识别 NTFS 文件系统的如果需要识别 则需要重新编译内核才能支持。 它比 fat32 文件系统更加安全 速度更快支持最大 2TB 的分区和最大 64GB 的文件 ufs Sun 公司的操作系统 Solaris 和 SunOS 所采用的文件系统  proc Linux 中基于内存的虚拟文件系统用来管理内存存储目录/proc其实是linux内核对外提供的一个接口 sysfs 和 proc 一样也是基于内存的虚拟文件系统用来管理内存存储目录/sys tmpfs 也是一种基于内存的虚拟文件系统不过也可以使用 swap 交换分区 ######################################################################   2、文件系统的组成 Linux文件系统具体由三部分组成文件名inodeblock inode的内容 inode包含文件的元信息相当于windows的文件的属性    文件的字节数   * 文件拥有者的User ID   * 文件的Group ID   * 文件的读、写、执行权限   * 文件的时间戳共有三个                 ctime指inode上一次变动的时间                 mtime指文件内容上一次变动的时间                 atime指文件上一次打开的时间   * 链接数即有多少文件名指向这个inode   * 文件数据block的位置 可以用stat命令查看某个文件的inode信息 [rootzabbix-server lianxi]# stat inode.txt 文件inode.txt大小4 块8 IO 块4096 普通文件 设备fd00h/64768d Inode17399383 硬链接1 权限(0644/-rw-r–r–) Uid( 0/ root) Gid( 0/ root) 环境unconfined_u:object_r:admin_home_t:s0 最近访问2023-03-02 15:49:20.384057399 0800 最近更改2023-03-02 15:50:54.088203475 0800 最近改动2023-03-02 15:50:54.088203475 0800 创建时间-inode的大小 inode也会消耗硬盘空间所以硬盘格式化的时候操作系统自动将硬盘分成两个区域。一个是数据区存放文件数据另一个是inode区inode table存放inode所包含的信息。lixun的文件系统中把这部分区域又叫super block超级块。 每个inode节点的大小一般是128字节或256字节。inode节点的总数在格式化时就给定假定在一块1GB的硬盘中每个inode节点的大小为128字节每1KB就设置一个inode那么inode table的大小就会达到128MB占整块硬盘的12.8%。 inode号码 每个inode都有一个号码操作系统用inode号码来识别不同的文件。 Unix/Linux系统内部不使用文件名而使用inode号码来识别文件。对于系统来说文件名只是inode号码便于识别的别称或者绰号 使用 ls -i来查看文件的inode号码 [rootzabbix-server lianxi]# ls -i 17399383 inode.txt使用 df -i命令查看每个硬盘分区的inode总数和已经使用的数量可以使用df命令。  [rootzabbix-server lianxi]# df -i 文件系统 Inode 已用(I) 可用(I) 已用(I)% 挂载点 devtmpfs 229876 401 229475 1% /dev tmpfs 232878 1 232877 1% /dev/shm tmpfs 232878 759 232119 1% /run tmpfs 232878 16 232862 1% /sys/fs/cgroup /dev/mapper/centos-root 8910848 43724 8867124 1% / /dev/sda1 524288 327 523961 1% /boot tmpfs 232878 1 232877 1% /run/user/0每一个文件都必须由一个inode所以有可能发生inode已经用完但是硬盘还没有用完的情况这样就无法在硬盘上面创建新文件  系统打开一个文件的整个过程 首先系统找到这个文件名对应的inode号码 其次通过inode号码获取inode信息 最后根据inode信息找到文件数据所在的block读出数据。 目录文件 在linux操作系统中目录directory也是一种文件打开一个目录其实就是打开了一个目录文件 目录文件的结构很简单就是一系列目录项的列表 每个目录项由两部分组成所包含文件的文件名以及该文件名所对应的inode号码 这也是为什么使用ls -h [rootzabbix-server lianxi]# ll -id /etc 16777281 drwxr-xr-x. 81 root root 8192 3月 2 09:58 /etc######################################################################  block块 操作系统读取硬盘的时候不会一个个扇区512字节地读取这样效率太低而是一次性的连续读取多个扇区即一次性读取一个块block这种由多个扇区组成的块是文件存取的最小单位块的大小最常见是1kb即连着2扇区组成一个block或4kb即八个扇区组成一个block。 block是真正存储数据的地方 block是文件系统中最小的存储单位 扇区是磁盘中最小的存储单位  ######################################################################  block调大 优点速度快节约寻址时间缺点空间浪费         例如2T硬盘前1.5T使用4k的block大小后面500G格式化成64k块大小用空间换时间         原因:                 block大小1KB2KB或4KB和数量在格式化后就已经决定不能改变除非重新格式化每个block只能保存一个文件的数据要是文件数据小于一个block块那么这个block的剩余空间不能被其他文件使用要是文件数据大于一个block块则占用多个block块 显示磁盘状态信息CentOS6用 dumpe2fs 分区名 CentOS7用xfs_info 分区名 [rootmonitor-vm ~]# xfs_info /dev/vda1 meta-data/dev/vda1 isize512 agcount4, agsize65536 blks sectsz512 attr2, projid32bit1 crc1 finobt0 spinodes0 data bsize4096 blocks262144, imaxpct25 sunit0 swidth0 blks naming version 2 bsize4096 ascii-ci0 ftype1 log internal bsize4096 blocks2560, version2 sectsz512 sunit0 blks, lazy-count1 realtime none extsz4096 blocks0, rtextents0######################################################################  磁盘分区工具与挂载 1、磁盘常识 工厂生产的硬盘必须经过低级格式化分区高级格式化三个处理步骤后电脑才能利用他们存储数据其中磁盘的低级格式化通常由生产厂家完成目的是划定磁盘可供使用的扇区和磁道并标记有问题的扇区而用户则需要使用操作系统提供的磁盘工具如fdiskgdisk等重新进行硬盘分区和格式化。 2、磁盘两种分区表MBR和GPT MBR将分区信息保存到磁盘的第一个扇区MBR扇区的64字节中每个分区要占用16个字节这意味着格式化的时候最多划分4个主分区因为MBR分区表给定分区信息只有64个字节这16个字节中存有活动状态标志、文件系统标识、起止柱面号、磁头号、扇区号、隐含扇区数目(4个字节)、分区总扇区数目(4个字节)等内容。 特点 MBR分区主分区数目不能超过4个很多时候4个主分区并不能满足需要。 MBR分区方案无法支持超过2TB容量的磁盘。因为这一方案用4个字节存储分区的总扇区数最大能表示2的32次方的扇区个数按每扇区512字节计算每个分区最大不能超过2TB。磁盘容量超过2TB以后分区的起止位置也就无法表示了BIOS将无法识别分区。(这种分区表逐渐将被淘汰当然现在很多系统还在用) GPT GUID磁盘分割表GUID Partition Table的缩写含义“全局唯一标识磁盘分区表”是一个实体硬盘的分区表的结构布局的标准。 GPT的分区方案之所以比MBR更先进是因为在GPT分区表头中可自定义分区数量的最大值也就是说GPT分区表的大小不是固定的。在Windows中微软设定GPT磁盘最大分区数量为128个。 特点 支持2TB以上的大硬盘。 每个磁盘的分区个数几乎没有限制。操作系统存在允许的最多分区数的限制比如win限制128个 ######################################################################   3、使用fdisk管理分区MBR分区表 1、fdisk -l 查看系统所有硬盘及分区 [rootzabbix-server ssh]# fdisk -l磁盘 /dev/sda21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节 磁盘标签类型dos 磁盘标识符0x0008f377设备 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM可以看到已经存在的一个磁盘 /dev/sda 总共41943040个扇区而这个磁盘已经分成了3个区已经分配完成了 要继续分配的话要新增加一块硬盘。 新增一块硬盘 新增硬盘成功开启虚拟机可以看到新增加了一个硬盘并且没有划分分区 [rootzabbix-server ~]# fdisk -l磁盘 /dev/sda21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节 磁盘标签类型dos 磁盘标识符0x0008f377设备 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM磁盘 /dev/sdb21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节######################################################################   2、进入fdisk工具进行分区操作 [rootzabbix-server ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中直到您决定将更改写入磁盘。 使用写入命令前请三思。Device does not contain a recognized partition table 使用磁盘标识符 0xa78730bb 创建新的 DOS 磁盘标签。命令(输入 m 获取帮助)m 命令操作a toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitiong create a new empty GPT partition tableG create an IRIX (SGI) partition tablel list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partitions system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only) 常用fdisk工具命令  a   toggle a bootable flagb   edit bsd disklabelc   toggle the dos compatibility flagd   delete a partition   删除分区g   create a new empty GPT partition tableG   create an IRIX (SGI) partition tablel   list known partition types   显示分区类型linux系统内核很多个分区的类型idm   print this menu   打印帮助菜单n   add a new partition   添加新的分区o   create a new empty DOS partition tablep   print the partition table   显示分区表q   quit without saving changes   不保存退出s   create a new empty Sun disklabelt   change a partitions system id   改变分区类型u   change display/entry unitsv   verify the partition tablew   write table to disk and exit   写分区表信息到硬盘保存操作并退出x   extra functionality (experts only)分区操作   [rootzabbix-server ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中直到您决定将更改写入磁盘。 使用写入命令前请三思。Device does not contain a recognized partition table 使用磁盘标识符 0xc57cdce7 创建新的 DOS 磁盘标签。命令(输入 m 获取帮助)n –新增分区 Partition type:p primary (0 primary, 0 extended, 4 free)e extended Select (default p): p –新增主分区 分区号 (1-4默认 1)1 –主分区只能有4个 起始 扇区 (2048-41943039默认为 2048) –新增分区起始扇区一般默认直接回车 将使用默认值 2048 Last 扇区, 扇区 or size{K,M,G} (2048-41943039默认为 41943039)1G –分区大小 分区 1 已设置为 Linux 类型大小设为 1 GiB命令(输入 m 获取帮助)n Partition type:p primary (1 primary, 0 extended, 3 free)e extended Select (default p): e –新增扩展分区 分区号 (2-4默认 2)2 –扩展分区也要占用一个主分区 起始 扇区 (2099200-41943039默认为 2099200) –默认起始扇区从上一个主分区的终止扇区开始 将使用默认值 2099200 Last 扇区, 扇区 or size{K,M,G} (2099200-41943039默认为 41943039)18G 分区 2 已设置为 Extended 类型大小设为 18 GiB命令(输入 m 获取帮助)p磁盘 /dev/sdb21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节 磁盘标签类型dos 磁盘标识符0xc57cdce7设备 Boot Start End Blocks Id System /dev/sdb1 2048 2099199 1048576 83 Linux /dev/sdb2 2099200 39847935 18874368 5 Extended命令(输入 m 获取帮助)n Partition type:p primary (1 primary, 1 extended, 2 free)l logical (numbered from 5) Select (default p): l –扩展分区只能有一个现在只能新建主分区和逻辑分区 添加逻辑分区 5 –逻辑分区从5开始 起始 扇区 (2101248-39847935默认为 2101248) 将使用默认值 2101248 Last 扇区, 扇区 or size{K,M,G} (2101248-39847935默认为 39847935)2G 分区 5 已设置为 Linux 类型大小设为 2 GiB命令(输入 m 获取帮助)p磁盘 /dev/sdb21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节 磁盘标签类型dos 磁盘标识符0xc57cdce7设备 Boot Start End Blocks Id System /dev/sdb1 2048 2099199 1048576 83 Linux /dev/sdb2 2099200 39847935 18874368 5 Extended /dev/sdb5 2101248 6295551 2097152 83 Linux命令(输入 m 获取帮助)w –保存将操作写入磁盘里 The partition table has been altered!Calling ioctl() to re-read partition table. 正在同步磁盘。可以看到刚才划分的分区就已经成功写入磁盘里了  分区格式化操作  一般centos7使用xfs文件系统centos6使用ext4文件系统通常情况下使用官方建议的文件系统 [rootzabbix-server ~]# mkfs.xfs /dev/sdb1 meta-data/dev/sdb1 isize512 agcount4, agsize65536 blks sectsz512 attr2, projid32bit1 crc1 finobt0, sparse0 data bsize4096 blocks262144, imaxpct25 sunit0 swidth0 blks naming version 2 bsize4096 ascii-ci0 ftype1 log internal log bsize4096 blocks2560, version2 sectsz512 sunit0 blks, lazy-count1 realtime none extsz4096 blocks0, rtextents0mkfs 命令非常简单易用不过是不能调整分区的默认参数的比如块大小是 4096这些默认参数除非特殊情况否则不需要调整如果想要调整就需要使用 mke2fs 命令进行重新格式化 建立挂载点 新建一个挂载目录/disk1准备将主分区/dev/sda1 挂载到/disk1,挂载完了以后如果重启的话就会失效 [rootzabbix-server ~]# mkdir -p /disk1 [rootzabbix-server ~]# mount /dev/sdb1 /disk1 [rootzabbix-server ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 898M 0 898M 0% /dev tmpfs 910M 0 910M 0% /dev/shm tmpfs 910M 9.6M 901M 2% /run tmpfs 910M 0 910M 0% /sys/fs/cgroup /dev/mapper/centos-root 17G 2.2G 15G 13% / /dev/sda1 1014M 151M 864M 15% /boot tmpfs 182M 0 182M 0% /run/user/0 /dev/sdb1 1014M 33M 982M 4% /disk1自动挂载 修改分区自动挂载文件 /etc/fstab 文件添加自动挂载以后当服务器重启的时候磁盘会自动挂载到对应目录 [rootzabbix-server ~]# vim /etc/fstab /dev/sdb1 /disk1 xfs defaults 0 0 ######################################################################  4、使用gdisk管理分区gpt分区表  gpt分区表没有扩展分区和逻辑分区之分只有主分区一般windows对于gpt分区表的主分区数有一个128的数量限制  安装gdisk工具 yum install -y gdisk进入gdisk进行分区 [rootzabbix-server ~]# gdisk /deb/sdb GPT fdisk (gdisk) version 0.8.10Problem opening /deb/sdb for reading! Error is 2. The specified file does not exist! [rootzabbix-server ~]# gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10Partition table scan:MBR: not presentBSD: not presentAPM: not presentGPT: not presentCreating new GPT entries.Command (? for help): ? b back up GPT data to a file c change a partitions name d delete a partition i show detailed information on a partition l list known partition types n add a new partition o create a new empty GUID partition table (GPT) p print the partition table q quit without saving changes r recovery and transformation options (experts only) s sort partitions t change a partitions type code v verify disk w write table to disk and exit x extra functionality (experts only) ? print this menugdisk常用命令 Command (? for help): ?    #  查看帮助 b      back up GPT data to a file c       change a partitions name   d      delete a partition    #删除分区 i show detailed information on a partition l list known partition types n      add a new partition        # 添加一个分区 o      create a new empty GUID partition table (GPT) p      print the partition table       # 打印分区表 q      quit without saving changes     # 退出不保存 r       recovery and transformation options (experts only) s       sort partitions t       change a partitions type code #修改分区系统id v      verify disk w      write table to disk and exit     # 写入分区表并退出 x      extra functionality (experts only) ?       print this menu 分区操作 [rootzabbix-server ~]# gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10Partition table scan:MBR: not presentBSD: not presentAPM: not presentGPT: not presentCreating new GPT entries.Command (? for help): p Disk /dev/sdb: 41943040 sectors, 20.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8D21C732-A799-40B8-B25B-7F9DE91252D8 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 41943006 Partitions will be aligned on 2048-sector boundaries Total free space is 41942973 sectors (20.0 GiB)Number Start (sector) End (sector) Size Code NameCommand (? for help): n Partition number (1-128, default 1): 1 First sector (34-41943006, default 2048) or {-}size{KMGTP}: Last sector (2048-41943006, default 41943006) or {-}size{KMGTP}: 2G Current type is Linux filesystem Hex code or GUID (L to show codes, Enter 8300): 8300 Changed type of partition to Linux filesystemCommand (? for help): p Disk /dev/sdb: 41943040 sectors, 20.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8D21C732-A799-40B8-B25B-7F9DE91252D8 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 41943006 Partitions will be aligned on 2048-sector boundaries Total free space is 37748669 sectors (18.0 GiB)Number Start (sector) End (sector) Size Code Name1 2048 4196351 2.0 GiB 8300 Linux filesystemCommand (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully. 查看分区 [rootzabbix-server ~]# fdisk -l磁盘 /dev/sda21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节 磁盘标签类型dos 磁盘标识符0x0008f377设备 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.磁盘 /dev/sdb21.5 GB, 21474836480 字节41943040 个扇区 Units 扇区 of 1 * 512 512 bytes 扇区大小(逻辑/物理)512 字节 / 512 字节 I/O 大小(最小/最佳)512 字节 / 512 字节 磁盘标签类型gpt Disk identifier: 8D21C732-A799-40B8-B25B-7F9DE91252D8# Start End Size Type Name1 2048 4196351 2G Linux filesyste Linux filesystem5、swap交换分区 未扩大swap之前 [rootzabbix-server ~]# free -htotal used free shared buff/cache available Mem: 1.8G 432M 894M 10M 492M 1.2G Swap: 2.0G 0B 2.0G配置交换分区  [rootzabbix-server ~]# gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10Partition table scan:MBR: protectiveBSD: not presentAPM: not presentGPT: presentFound valid GPT with protective MBR; using GPT.Command (? for help): p Disk /dev/sdb: 41943040 sectors, 20.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8D21C732-A799-40B8-B25B-7F9DE91252D8 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 41943006 Partitions will be aligned on 2048-sector boundaries Total free space is 37748669 sectors (18.0 GiB)Number Start (sector) End (sector) Size Code Name1 2048 4196351 2.0 GiB 8300 Linux filesystemCommand (? for help): n Partition number (2-128, default 2): 2 First sector (34-41943006, default 4196352) or {-}size{KMGTP}: Last sector (4196352-41943006, default 41943006) or {-}size{KMGTP}: 1G Current type is Linux filesystem Hex code or GUID (L to show codes, Enter 8300): 8200 Changed type of partition to Linux swapCommand (? for help): p Disk /dev/sdb: 41943040 sectors, 20.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8D21C732-A799-40B8-B25B-7F9DE91252D8 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 41943006 Partitions will be aligned on 2048-sector boundaries Total free space is 35651517 sectors (17.0 GiB)Number Start (sector) End (sector) Size Code Name1 2048 4196351 2.0 GiB 8300 Linux filesystem2 4196352 6293503 1024.0 MiB 8200 Linux swapCommand (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!Do you want to proceed? (Y/N): y OK; writing new GUID partition table (GPT) to /dev/sdb. The operation has completed successfully.######################################################################  格式化交换分区 [rootzabbix-server ~]# mkswap /dev/sdb2 正在设置交换空间版本 1大小 1048572 KiB 无标签UUIDefd3c262-1b70-435f-9b54-b79f305585bc临时生效swap [rootzabbix-server ~]# swapon /dev/sdb2 [rootzabbix-server ~]# free -htotal used free shared buff/cache available Mem: 1.8G 439M 884M 10M 495M 1.2G Swap: 3.0G 0B 3.0Gswap由2G变成3G 永久生效要写入/etc/fstab文件里面 /dev/sdb2 swap swap defaults 0 0 ######################################################################  5、将一个已经生效的分区改成swap分区 [rootzabbix-server ~]# gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10Partition table scan:MBR: protectiveBSD: not presentAPM: not presentGPT: presentFound valid GPT with protective MBR; using GPT.Command (? for help): p Disk /dev/sdb: 41943040 sectors, 20.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8D21C732-A799-40B8-B25B-7F9DE91252D8 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 41943006 Partitions will be aligned on 2048-sector boundaries Total free space is 35651517 sectors (17.0 GiB)Number Start (sector) End (sector) Size Code Name1 2048 4196351 2.0 GiB 8300 Linux filesystem2 4196352 6293503 1024.0 MiB 8200 Linux swapCommand (? for help): t Partition number (1-2): 1 Current type is Linux filesystem Hex code or GUID (L to show codes, Enter 8300): 8200 Changed type of partition to Linux swapCommand (? for help): p Disk /dev/sdb: 41943040 sectors, 20.0 GiB Logical sector size: 512 bytes Disk identifier (GUID): 8D21C732-A799-40B8-B25B-7F9DE91252D8 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 41943006 Partitions will be aligned on 2048-sector boundaries Total free space is 35651517 sectors (17.0 GiB)Number Start (sector) End (sector) Size Code Name1 2048 4196351 2.0 GiB 8200 Linux swap2 4196352 6293503 1024.0 MiB 8200 Linux swap######################################################################  /etc/fstab 文件修复 如果/etc/fstab文件挂载目录信息出错服务器会启动不了需要修复fstab文件 报错的情况下继续登录修改/etc/fstab 报错可能改不了是挂载的问题 mount -o remount,rw / 然后修改最后重启