Linux 磁盘分区

来源:互联网 发布:wkwebview的优化 编辑:程序博客网 时间:2024/05/17 02:39

简单分区和文件系统
• 存储是每个计算机系统的基本需求。 Red Hat Enterprise
Linux 提供了一些强大的工具 , 它们能在大量的场景中管
理多种类型的存储设备
• disk 是用于管理磁盘分区的实用程序。您可以通过选择 -l
选项和指定磁盘名称 ( fdisk -cul /dev/vda ) 运行该实用程
序 , 以查看磁盘及其分区。您可以通过交互式地运行该实用
程序 , 并选择相应的菜单选项 ( fdisk -cu /dev/vda ) 进行更
改。 -c 禁用旧的 DOS 兼容模式 , -u 以扇区 ( 而不是柱
面 , 已经过时 ) 的格式显示输出

查看系统设备信息
• fdisk -l
– 显示系统中所有可以使用的设备信息


• blkid
– 显示系统正在使用的设备 id

[root@localhost ~]# fdisk /dev/vdb
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      ##获得帮助
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition            ##删除分区
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types ##列出系统可用的分区类型
   m   print this menu
   n   add a new partition  ##添加分区
   o   create a new empty DOS partition table
   p   print the partition table ##显示添加成功的分区
   q   quit without saving changes ##退出
   s   create a new empty Sun disklabel
   t   change a partition's system id ##修改分区功能id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit ##保存更改到分区中
   x   extra functionality (experts only)

文件系统比较
• ext4 是 Red Hat Enterprise linux 6 的标准文件系统。它非
常强大可靠 , 具有多项可以提高现代工作量处理性能的功能
• ext2 是常用于 Linux 中的较旧的文件系统。它简单可靠 , 非
常适合小型存储设备 , 但是效率低于 ext4
• vfat 支持包括一系列相关文件系统 ( VFAT/FAT16 和
FAT32 ), 这些文件系统针对较旧版本的 Microsoft Windows
开发 , 在大量的系统和设备上受支持
• xfs 在 Red Hat Enterprise Linux 7 的标准文件系统
其具备数据完全性 、性能稳定、扩展性强( 18eb )、传输速
率高( 7G/s )

文件系统创建示例 :




删除现有文件系统
1. 通过使用 umount /mountpoint 卸载文件系统。
2. 在 /etc/fstab 中删除相应条目。
3. 删除挂载点目录 : rmdir /mountpoint

swap 交换分区
• 换空间或交换区是磁盘驱动器上的空间 , 用
作当前未使用部分内存的溢出。这样 , 系统
就能在主内存中留出空间用于储存当前正在
处理的数据 , 并在系统面临主内存空间不足
的风险时提供应急溢出

管理交换分区
• 使用 fdisk 创建新分区。此外 , 在用 fdisk 保存
更改之前 , 将分区类型更改为 “ 0x82 Linux
Swap”
• mkswap /dev/vdaN 会准备好将分区用作交换区



[root@localhost ~]#
[root@localhost ~]# partprobe  ##同步分区表
[root@localhost ~]# mkswap /dev/vdb2 ##格式化成swap类型
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=b933737a-1409-48b5-8f92-d663d388134b
[root@localhost ~]# swapon -a /dev/vdb2 ##加入swap
[root@localhost ~]# swapon -s
Filename    Type  Size Used Priority
/dev/vdb2                               partition 4194300 0 -1
[root@localhost ~]#

























原创粉丝点击