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

1、标记磁盘分区表类型

  1. [root@vertica-bk ~]# parted /dev/sdb
  2. GNU Parted 3.1
  3. Using /dev/sdb
  4. Welcome to GNU Parted! Type 'help' to view a list of commands.
  5. (parted) mklabel gpt
  6. 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?
  7. Yes/No? y
  8. (parted) p
  9. Model: DELL PERC H730P (scsi)
  10. Disk /dev/sdb: 4799GB
  11. Sector size (logical/physical): 512B/512B
  12. Partition Table: gpt
  13. Disk Flags:
  14. Number Start End Size File system Name Flags

2、分区

  1. (parted) mkpart
  2. Partition name? []? data
  3. File system type? [ext2]? ext4
  4. Start? 0
  5. End? 100%
  6. Warning: The resulting partition is not properly aligned for best performance.
  7. Ignore/Cancel? ignore
  8. (parted) p
  9. Model: DELL PERC H730P (scsi)
  10. Disk /dev/sdb: 4799GB
  11. Sector size (logical/physical): 512B/512B
  12. Partition Table: gpt
  13. Disk Flags:
  14. Number Start End Size File system Name Flags
  15. 1 17.4kB 4799GB 4799GB data
  16. quit

3、格式化

  1. [root@vertica-bk ~]# mkfs.ext4 /dev/sdb1
  2. mke2fs 1.42.9 (28-Dec-2013)
  3. Filesystem label=
  4. OS type: Linux
  5. Block size=4096 (log=2)
  6. Fragment size=4096 (log=2)
  7. Stride=0 blocks, Stripe width=0 blocks
  8. 146440192 inodes, 1171521527 blocks
  9. 58576076 blocks (5.00%) reserved for the super user
  10. First data block=0
  11. Maximum filesystem blocks=3319791616
  12. 35752 block groups
  13. 32768 blocks per group, 32768 fragments per group
  14. 4096 inodes per group
  15. Superblock backups stored on blocks:
  16. 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  17. 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
  18. 102400000, 214990848, 512000000, 550731776, 644972544
  19. Allocating group tables: done
  20. Writing inode tables: done
  21. Creating journal (32768 blocks): done
  22. Writing superblocks and filesystem accounting information: done

4、挂载

  1. [root@vertica-bk ~]# blkid
  2. /dev/sda2: UUID="9fe00c04-0c81-4e98-be7a-7428acea53a8" TYPE="ext4"
  3. /dev/sda3: UUID="e407640f-9e79-453b-8c24-651afdf6e6bb" TYPE="swap"
  4. /dev/sda5: UUID="f157cd4f-689a-4521-a72c-e2cb5db64f4a" TYPE="ext4"
  5. /dev/sdb1: UUID="6ac26a8d-49f7-4de2-b9e3-1122b1b75626" TYPE="ext4" PARTLABEL="data" PARTUUID="faaf7e7c-12b1-4c4b-b1af-a5086607ecda"
  6. [root@vertica-bk ~]# vim /etc/fstab
  7. -bash: vim: command not found
  8. [root@vertica-bk ~]# vi /etc/fstab
  9. [root@vertica-bk ~]# mount -a
  10. [root@vertica-bk ~]# df -h
  11. Filesystem Size Used Avail Use% Mounted on
  12. /dev/sda5 1.1T 990M 1.1T 1% /
  13. devtmpfs 189G 0 189G 0% /dev
  14. tmpfs 189G 0 189G 0% /dev/shm
  15. tmpfs 189G 9.0M 189G 1% /run
  16. tmpfs 189G 0 189G 0% /sys/fs/cgroup
  17. /dev/sda2 976M 86M 824M 10% /boot
  18. tmpfs 38G 0 38G 0% /run/user/0
  19. /dev/sdb1 4.4T 89M 4.2T 1% /data

5、完成