原文:http://www.2cto.com/os/201110/109325.html,http://blog.sina.com.cn/s/blog_67be3b4501016tnh.html
一个新dell r710做数据库,6块500G,7.2k的SAS硬盘,做成RAID5
由于MBR分区有大小限制2.1T,所以采用了GPT分区格式。
1.第一次装好系统后,把MBR分区转换成GPT分区
yum install parted -y
parted /dev/sda
mklabel gpt
mkpart primary 0 1000
mkpart primary 1000 5000
mkpart primary 5000 200000
mkpart primary 200000 2500000
print
quit
2.GPT分区完成后重启服务器,因为分区后所有数据被删除,还得装遍centos6
安装过程中,自定义分区里会显示4个unknown的分区(就是我们的GPT分区)。
这里我们格式化前面3个分区, /boot ,/swap,/ ,使用ext4。最后一个分区装完系统后再弄。
3.系统装完后:
yum install kmod-xfs xfsprogs
modprobe xfs //载入xfs文件系统模块,如果不行要重启服务器
lsmod |grep xfs //查看是否载入了xfs模块
mkdir /data
mkfs.xfs -f /dev/sda4
mount -t xfs /dev/sda4 /data //把分区挂载到目录上
df -Th 查看下结果
最后加入/etc/fstab自动挂载。
vi /etc/fstab
/dev/sda4 /data xfs defaults 0 0
接下来我们了解一下GPT分区: GPT格式的磁盘相当于原来MBR磁盘中保留的4个Partition table的4*6个字节,只保留第一个16字节,类似于扩展分区,真正的Partition table在512字节之后(即第一扇区),GPT磁盘没有类似于MBR类型的四个主分区的限制 但是fdisk工具不支持GPT分区,我们可以使用parted来对GPT磁盘进行操作。 parted是一个磁盘分区管理工具,它比fdisk更加灵活,功能也更加丰富,同时还支持GUID分区表(GUID Partition Table) parted同时支持交互模式和非交互模式,它除了能够进行分区的添加、删除等常见的操作外,还可以移动分区,制作文件系统,调整文件系统的大小,复制文件系统等等 格外注意:不同于fdisk命令的分区中使用w命令可以保存并写入分区表信息,parted命令是执行的时候立即生效的,所以操作的时候要格外谨慎 1、删除一个分区 命令格式:parted device rm partition [root@model ~]# parted /dev/sda print Model: MAXTOR ATLAS10K5_73SCA (scsi) Disk /dev/sda: 73.6GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 10.0GB 10.0GB primary ext3 4 12.1GB 73.6GB 61.5GB extended 5 12.1GB 20.4GB 8390MB logical ext3 6 20.4GB 32.1GB 11.6GB logical ext3 7 32.1GB 73.6GB 41.5GB logical ext3 Information: Don't forget to update /etc/fstab, if necessary. [root@model ~]# parted /dev/sda rm 1 Information: Don't forget to update /etc/fstab, if necessary. [root@model ~]# parted /dev/sda print Model: MAXTOR ATLAS10K5_73SCA (scsi) Disk /dev/sda: 73.6GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 4 12.1GB 73.6GB 61.5GB extended 5 12.1GB 20.4GB 8390MB logical ext3 6 20.4GB 32.1GB 11.6GB logical ext3 7 32.1GB 73.6GB 41.5GB logical ext3 Information: Don't forget to update /etc/fstab, if necessary. 2、添加一个分区 命令格式:parted device mkpart part-type [fs-type] start end 添加一个3GB的分区: [root@model ~]# parted /dev/sda mkpart primary 32.3kB 3GB [root@model ~]# parted /dev/sda print -s Model: MAXTOR ATLAS10K5_73SCA (scsi) Disk /dev/sda: 73.6GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 3002MB 3002MB primary ext3 4 12.1GB 73.6GB 61.5GB extended 5 12.1GB 20.4GB 8390MB logical ext3 6 20.4GB 32.1GB 11.6GB logical ext3 7 32.1GB 73.6GB 41.5GB logical ext3 3、制作文件系统 命令格式:parted device mkfs 对刚才添加的分区制作文件系统: [root@model ~]# parted /dev/sda mkfs Warning: The existing file system will be destroyed and all data on the partition will be lost. Do you want to continue? Yes/No? y Partition number? 1 File system? [ext2]? Information: Don't forget to update /etc/fstab, if necessary. [root@model ~]# parted /dev/sda print -s Model: MAXTOR ATLAS10K5_73SCA (scsi) Disk /dev/sda: 73.6GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 3002MB 3002MB primary ext2 4 12.1GB 73.6GB 61.5GB extended 5 12.1GB 20.4GB 8390MB logical ext3 6 20.4GB 32.1GB 11.6GB logical ext3 7 32.1GB 73.6GB 41.5GB logical ext3 4、调整文件系统大小 命令格式:parted device resize partition start end 将分区/dev/sda1的大小增加到5GB: [root@model ~]# parted /dev/sda resize 1 32.3kB 5GB Warning: You should reinstall your boot loader before rebooting. Read section 4 of the Parted User documentation for more information. Information: Don't forget to update /etc/fstab, if necessary. [root@model ~]# parted /dev/sda print -s Model: MAXTOR ATLAS10K5_73SCA (scsi) Disk /dev/sda: 73.6GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 5001MB 5001MB primary ext2 4 12.1GB 73.6GB 61.5GB extended 5 12.1GB 20.4GB 8390MB logical ext3 6 20.4GB 32.1GB 11.6GB logical ext3 7 32.1GB 73.6GB 41.5GB logical ext3 5、移动分区 命令格式:parted device move partition start end 移动分区/dev/sda1: [root@model ~]# parted /dev/sda move 1 5001MB End? [10.0GB]? Warning: You should reinstall your boot loader before rebooting. Read section 4 of the Parted User documentation for more information. Information: Don't forget to update /etc/fstab, if necessary. [root@model ~]# parted /dev/sda print -s Model: MAXTOR ATLAS10K5_73SCA (scsi) Disk /dev/sda: 73.6GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 5001MB 10.0GB 5001MB primary ext2 4 12.1GB 73.6GB 61.5GB extended 5 12.1GB 20.4GB 8390MB logical ext3 6 20.4GB 32.1GB 11.6GB logical ext3 7 32.1GB 73.6GB 41.5GB logical ext3 6、另外一些命令说明: parted>select sdb # 选择sdb操作 parted>mklabel gpt # 将MBR磁盘格式化为GPT磁盘 parted>mklabel msdos # 将GPT磁盘格式化为MBR磁盘 parted>mkpart primary 0 100 # 划分一个起始位置是0,大小为100M的主分区 parted>mkpart primary 0 -1 # 将整个磁盘分成一个分区 parted>print # 打印当前的分区 OK了,绕了这么远了,下面对最初的那个案例做一下处理(由于介个文档是后来写的,所以不能按照实际的情况来写了,只能按照测试的环境来写了): [root@model ~]# parted /dev/sdb GNU Parted 1.8.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel gpt (parted) mkpart Partition name? []? /u01 File system type? [ext2]? ext3 Start? 0 End? -1 (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 21.5GB 21.5GB /u01 (parted) quit [root@model ~]# mkdir /u01 这个格式化的过程比较慢,当然在这个测试环境中格式化的比较快。在实际的格式化中,格式化一个5.8TB的分区花了差不多二十分钟 [root@model ~]# mkfs -t ext3 /dev/sdb1 [root@model ~]# mount -t ext3 /dev/sdb1 /u01