在linux系统中对大于2T的硬盘,使用fdisk进行分区,不是很好用,我们应该使用parted进行分区一、查看系统中待分区的硬盘信息[root@zabbix-c1~]#fdisk-lDisk/dev/sda:214.7GB,214748364800...
在linux系统中对大于2T的硬盘,使用fdisk进行分区,不是很好用,我们应该使用parted进行分区
一、查看系统中待分区的硬盘信息
[root@zabbix-c1 ~]# fdisk -l Disk /dev/sda: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00049d20 Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 281 2048000 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 281 26109 207461376 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc1760957 Device Boot Start End Blocks Id System /dev/sdb1 1 26 208813+ 83 Linux Disk /dev/sdc: 3221.2 GB, 3221225472000 bytes 255 heads, 63 sectors/track, 391625 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdd: 5368.7 GB, 5368709120000 bytes 255 heads, 63 sectors/track, 652708 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
二、在上面的结果中我们可以看到/dev/sdc和/dev/sdd2块新的硬盘,硬盘大小分别是3T和5T
对/dev/sdc进行分区
#将分区设置成gpt格式 [root@zabbix-c1 ~]# parted /dev/sdc mklabel gpt Information: You may need to update /etc/fstab. #创建一个20G的分区 [root@zabbix-c1 ~]# parted /dev/sdc mkpart primary 0 20000 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i Information: You may need to update /etc/fstab. [root@zabbix-c1 ~]# fdisk -l Disk /dev/sda: 214.7 GB, 214748364800 bytes 255 heads, 63 sectors/track, 26108 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00049d20 Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 281 2048000 82 Linux swap / Solaris Partition 2 does not end on cylinder boundary. /dev/sda3 281 26109 207461376 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc1760957 Device Boot Start End Blocks Id System /dev/sdb1 1 26 208813+ 83 Linux WARNING: GPT (GUID Partition Table) detected on ‘/dev/sdc‘! The util fdisk doesn‘t support GPT. Use GNU Parted. Disk /dev/sdc: 3221.2 GB, 3221225472000 bytes 255 heads, 63 sectors/track, 391625 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdc1 1 267350 2147483647+ ee GPT Disk /dev/sdd: 5368.7 GB, 5368709120000 bytes 255 heads, 63 sectors/track, 652708 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@zabbix-c1 ~]# parted /dev/sdc p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 3221GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 20.0GB 20.0GB primary #将剩余的空间全部创建成一个扩展分区 [root@zabbix-c1 ~]# parted /dev/sdc mkpart extended 1 100% Warning: You requested a partition from 1000kB to 3221GB. The closest location we can manage is 20.0GB to 3221GB. Is this still acceptable to you? Yes/No? y Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i Information: You may need to update /etc/fstab. #查看/dev/sdc上的分区信息 [root@zabbix-c1 ~]# parted /dev/sdc p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdc: 3221GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 20.0GB 20.0GB primary 2 20.0GB 3221GB 3201GB extended
格式化硬盘分区并挂载
/dev/sdc1挂载到/data目录下
[root@zabbix-c1 ~]# mkfs.ext4 /dev/sdc1 mke2fs 1.41.12 (17-May-2010) warning: 376 blocks unused. Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1222992 inodes, 4882432 blocks 244140 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 149 block groups 32768 blocks per group, 32768 fragments per group 8208 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. #通知内核 [root@zabbix-c1 ~]# partprobe /dev/sdc [root@zabbix-c1 ~]# mount /dev/sdc1 /data/ [root@zabbix-c1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 195G 1.4G 184G 1% / tmpfs 495M 0 495M 0% /dev/shm /dev/sda1 194M 28M 156M 16% /boot /dev/sdc1 19G 172M 18G 1% /data
格式化/dev/sdc2并挂载到/data1
#格式化/dev/sdc2 [root@zabbix-c1 ~]# mkfs.ext4 /dev/sdc2 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 195387392 inodes, 781549183 blocks 39077459 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 23851 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@zabbix-c1 ~]# mkdir /data1 [root@zabbix-c1 ~]# mount /dev/sdc2 /data1 [root@zabbix-c1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 195G 1.4G 184G 1% / tmpfs 495M 0 495M 0% /dev/shm /dev/sda1 194M 28M 156M 16% /boot /dev/sdc1 19G 172M 18G 1% /data /dev/sdc2 2.9T 200M 2.8T 1% /data1
我们将/dev/sdd分区分成1个分区,并挂载到/data2上
[root@zabbix-c1 ~]# parted /dev/sdd mklabel gpt Information: You may need to update /etc/fstab. [root@zabbix-c1 ~]# parted /dev/sdd mkpart primary 0 100% Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i Information: You may need to update /etc/fstab. #格式化分区 [root@zabbix-c1 ~]# mkfs.ext4 /dev/sdd1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 327680000 inodes, 1310719991 blocks 65535999 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 40000 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 32 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@zabbix-c1 ~]# mkdir /data2 [root@zabbix-c1 ~]# mount /dev/sdd1 /data2 [root@zabbix-c1 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 195G 1.4G 184G 1% / tmpfs 495M 0 495M 0% /dev/shm /dev/sda1 194M 28M 156M 16% /boot /dev/sdc1 19G 172M 18G 1% /data /dev/sdc2 2.9T 200M 2.8T 1% /data1 /dev/sdd1 4.9T 190M 4.6T 1% /data2
全文详见:http://xpxw.com/?id=35