parted

    parted命令 是由GNU组织开发的一款功能强大的磁盘分区和分区大小调整工具,与fdisk不同,它支持调整分区的大小。作为一种设计用于Linux的工具,它没有构建成处理与fdisk关联的多种分区类型,但是,它可以处理最常见的分区格式,包括:ext2、ext3、fat16、fat32、NTFS、ReiserFS、JFS、XFS、UFS、HFS以及Linux交换分区。

    1. -i:交互式模式;
    2. -s:脚本模式,不提示用户;
    3. -v:显示版本号。
    • 设备:指定要分区的硬盘所对应的设备文件;
    • 命令:要执行的parted命令。

    红帽企业 Linux 4 Update 4供对大于 2 terabytes(TB)的磁盘设备的支持。

    注:

    • 绿色代表你需要使用的命令。
    • 红色代表你需要注意到的输出信息,在后续需要使用。
    1. [root@localhost ~]# parted /dev/sdb
    2. GNU Parted Copyright (C) 1998 - 2004 free Software Foundation, Inc.
    3. This program is free software, covered by the GNU General Public License.
    4. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
    5. PARTICULAR PURPOSE. See the GNU General Public License for more details.
    6. 使用/dev/sdb
    7. (parted)mklabel gpt
    8. (parted)print
    9. /dev/sdb的磁盘几何结构:0.000-2048.000兆字节
    10. Minor 起始点 终止点 文件系统 名称 标志
    11. (parted)mkpart primary 0 2048 <-----上面print显示的数字
    12. (parted)print
    13. /dev/sdb的磁盘几何结构:0.000-2048.000兆字节
    14. 磁盘标签类型:gpt
    15. Minor 起始点 终止点 文件系统 名称 标志
    16. 1 0.017 2047.983
    17. (parted)quit
    1. [root@localhost ~]# mkfs.ext3 /dev/sdb1
    2. Filesystem label=
    3. OS type: Linux
    4. Fragment size=4096 (log=2)
    5. 262144 inodes, 524279 blocks
    6. 26213 blocks (5.00%) reserved for the super user
    7. First data block=0
    8. Maximum filesystem blocks=536870912
    9. 16 block groups
    10. 32768 blocks per group, 32768 fragments per group
    11. 16384 inodes per group
    12. Superblock backups stored on blocks:
    13. 32768, 98304, 163840, 229376, 294912
    14. Writing inode tables: done
    15. Creating journal (8192 blocks): done
    16. Writing superblocks and filesystem accounting information: done
    17. 180 days, whichever comes first. Use tune2fs -c or -i to override.