你的位置:首页 > 操作系统

[操作系统]使用parted给大于2T的磁盘分区


1.使用命令parted /dev/sdb 

 1 [root@server ~]# parted /dev/sdb 2 GNU Parted 2.1 3 使用 /dev/sdb 4 Welcome to GNU Parted! Type 'help' to view a list of commands. 5                                    (parted) help 6  align-check TYPE N            check partition N for 7     TYPE(min|opt) alignment 8  check NUMBER               do a simple check on the 9     file system10  cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER  copy file system to11     another partition12  help [COMMAND]              print general help, or13     help on COMMAND

2.修改gpt分区表

 1 (parted) p                                 2 Model: VMware, VMware Virtual S (scsi) 3 Disk /dev/sdb: 1074MB 4 Sector size (logical/physical): 512B/512B 5 Partition Table: msdos 6  7 Number Start End Size Type File system 标志 8  9 (parted) mklabel gpt  //使用mklabel修改为gpt分区10 警告: The existing disk label on /dev/sdb will be destroyed and all    11 data on this disk will be lost. Do you want to continue?12 是/Yes/否/No? yes                             13 (parted) p                                14 Model: VMware, VMware Virtual S (scsi)15 Disk /dev/sdb: 1074MB16 Sector size (logical/physical): 512B/512B17 Partition Table: gpt

3.创建分区说明

mkpart PART-TYPE [FS-TYPE] START END make a partition
mkpartfs PART-TYPE FS-TYPE START END make a partition with a

4.创建主分区为200M的分区

 1 (parted) mkpart primary 0 200  //使用命令mkpart 2 警告: The resulting partition is not properly aligned for best       3 performance. 4 忽略/Ignore/放弃/Cancel? I                         5 (parted) p 6 Model: VMware, VMware Virtual S (scsi) 7 Disk /dev/sdb: 1074MB 8 Sector size (logical/physical): 512B/512B 9 Partition Table: gpt10 11 Number Start  End  Size  File system Name   标志12 1   17.4kB 200MB 200MB        primary

5.创建主分区为100M的分区

 1 (parted) mkpart primary 200 300    //mkpart 主分区 start end 2 (parted) p                                 3 Model: VMware, VMware Virtual S (scsi) 4 Disk /dev/sdb: 1074MB 5 Sector size (logical/physical): 512B/512B 6 Partition Table: gpt 7  8 Number Start  End  Size  File system Name   标志 9 1   17.4kB 200MB 200MB        primary10 2   200MB  300MB 99.6MB        primary

6.创建一个逻辑分区并且指定文件类型ext4

1 (parted) mkpart logical ext4 301 400 ignore                2  align-check TYPE N            check partition N for3     TYPE(min|opt) alignment4  check NUMBER               do a simple check on the5     file system6  cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER  copy file system to7     another partition8  help [COMMAND]              print general help, or

 1 (parted) p                                 2 Model: VMware, VMware Virtual S (scsi) 3 Disk /dev/sdb: 1074MB 4 Sector size (logical/physical): 512B/512B 5 Partition Table: gpt 6  7 Number Start  End  Size  File system Name   标志 8 1   17.4kB 200MB 200MB        primary 9 2   200MB  300MB 99.6MB        primary10 3   301MB  400MB 98.6MB        logical

7.直接在命令行下分区

1 [root@server ~]# parted /dev/sdb mklabel gpt yes2 [root@server ~]# parted /dev/sdb mkpart primary ext4 0 10 ignore3 [root@server ~]# parted /dev/sdb mkpart primary linux-swap 11 20 ignore4 [root@server ~]# parted /dev/sdb mkpart logical ext4 21 30 ignore5 [root@server ~]# parted /dev/sdb p

8.扩展

对新添加的磁盘快速分区方法:

#echo -e "n\np\n1\n\n+10G\nn\np\n2\n\n+20G\nw" |fdisk /dev/sdb

#partprobe