本文介绍使用parted给大容量磁盘分区格式化。

1、标记磁盘分区表类型

[root@vertica-bk ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? y
(parted) p
Model: DELL PERC H730P (scsi)
Disk /dev/sdb: 4799GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number  Start  End  Size  File system  Name  Flags

2、分区

(parted) mkpart
Partition name?  []? data
File system type?  [ext2]? ext4
Start? 0
End? 100%
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ignore
(parted) p
Model: DELL PERC H730P (scsi)
Disk /dev/sdb: 4799GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      17.4kB  4799GB  4799GB               data
quit

3、格式化

[root@vertica-bk ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
146440192 inodes, 1171521527 blocks
58576076 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3319791616
35752 block groups
32768 blocks per group, 32768 fragments per group
4096 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

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

4、挂载

[root@vertica-bk ~]# blkid
/dev/sda2: UU TYPE="ext4"
/dev/sda3: UU TYPE="swap"
/dev/sda5: UU TYPE="ext4"
/dev/sdb1: UU TYPE="ext4" PARTLABEL="data" PARTUU
[root@vertica-bk ~]# vim /etc/fstab
-bash: vim: command not found
[root@vertica-bk ~]# vi /etc/fstab
[root@vertica-bk ~]# mount -a
[root@vertica-bk ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5       1.1T  990M  1.1T   1% /
devtmpfs        189G     0  189G   0% /dev
tmpfs           189G     0  189G   0% /dev/shm
tmpfs           189G  9.0M  189G   1% /run
tmpfs           189G     0  189G   0% /sys/fs/cgroup
/dev/sda2       976M   86M  824M  10% /boot
tmpfs            38G     0   38G   0% /run/user/0
/dev/sdb1       4.4T   89M  4.2T   1% /data

5、完成