linux命令学习(30)-parted

 

【命令名称】 parted
【使用权限】root
【命令语法】 parted [硬盘名] [指令 [参数]]
【功能说明】大于 2T的硬盘用parted来分区,低于2T的硬盘用fdisk来分区
【常用参数】
            新增分区: mkpart [primary|logical|extended] [ext3|ext4|vfat] 开始 结束
            直接输入 parted,进行交互分区
            l 列出当前分区信息
【命令实例】
1.查看当前分区
[root@cxcserver ~]# parted    /dev/sda print
Model: ATA WDC WD800JD-00LS (scsi)
Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
 
Number Start    End     Size    Type      File system     Flags
 1       1049kB 26.7GB 26.7GB primary   ext4            boot
 3       26.7GB 37.2GB 10.5GB primary                   lvm
 4       37.2GB 80.0GB 42.8GB extended
 5       37.2GB 41.4GB 4194MB logical   linux-swap(v1)
 6       41.4GB 41.6GB 206MB   logical   ext4
 7       41.6GB 41.7GB 115MB   logical
 
2.用 parted命令分区,分好后提示让你重启,重启后再次查看
[root@cxcserver ~]# parted /dev/sda mkpart logical ext4 41.7GB 43GB
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda
(Device or resource busy). As a result, it may not reflect all of your changes
until after reboot.
[root@cxcserver ~]# parted /dev/sda print
Model: ATA WDC WD800JD-00LS (scsi)
Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
 
Number Start    End     Size    Type      File system     Flags
 1       1049kB 26.7GB 26.7GB primary   ext4            boot
 3       26.7GB 37.2GB 10.5GB primary                   lvm
 4       37.2GB 80.0GB 42.8GB extended
 5       37.2GB 41.4GB 4194MB logical   linux-swap(v1)
 6       41.4GB 41.6GB 206MB   logical   ext4
 7       41.6GB 41.7GB 115MB   logical
 8       41.7GB 43.0GB 1256MB logical                  #新增加的
 
 3.删除刚才的分区
[root@cxcserver ~]# parted /dev/sda mkpart rm 8
[root@cxcserver ~]# parted /dev/sda print
Model: ATA WDC WD800JD-00LS (scsi)
Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
 
Number Start    End     Size    Type      File system     Flags
 1       1049kB 26.7GB 26.7GB primary   ext4            boot
 3       26.7GB 37.2GB 10.5GB primary                   lvm
 4       37.2GB 80.0GB 42.8GB extended
 5       37.2GB 41.4GB 4194MB logical   linux-swap(v1)
 6       41.4GB 41.6GB 206MB   logical   ext4
 7       41.6GB 41.7GB 115MB   logical
 
 4.输入 parted进行交互分区
[cxc@cxcserver ~]$ sudo parted
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) h                                              #帮助
 align-check TYPE N                         check partition N for TYPE(min|opt) alignment
 check NUMBER                              do a simple check on the file system
 cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER    copy file system to another partition
 help [COMMAND]                            print general help, or help on COMMAND
 mklabel,mktable LABEL-TYPE                create a new disklabel (partition table)
 mkfs NUMBER FS-TYPE                       make a FS-TYPE file system on partition NUMBER
 mkpart PART-TYPE [FS-TYPE] START END      make a partition
 mkpartfs PART-TYPE FS-TYPE START END      make a partition with a file system
 move NUMBER START END                     move partition NUMBER
 name NUMBER NAME                          name partition NUMBER as NAME
 print [devices|free|list,all|NUMBER]      display the partition table, available devices, free space, all found partitions, or a particular partition
 quit                                      exit program
 rescue START END                          rescue a lost partition near START and END
  resize NUMBER START END                   resize partition NUMBER and its file system
 rm NUMBER                                 delete partition NUMBER
 select DEVICE                             choose the device to edit
 set NUMBER FLAG STATE                     change the FLAG on partition NUMBER
 toggle [NUMBER [FLAG]]                    toggle the state of FLAG on partition NUMBER
 unit UNIT                                 set the default unit to UNIT
 version                                   display the version number and copyright information of GNU Parted
(parted) p                                     #查看当前分区
Model: ATA WDC WD800JD-00LS (scsi)
Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
 
Number Start    End     Size    Type      File system     Flags
 1       1049kB 26.7GB 26.7GB primary   ext4            boot
 3       26.7GB 37.2GB 10.5GB primary                   lvm
 4       37.2GB 80.0GB 42.8GB extended
 5       37.2GB 41.4GB 4194MB logical   linux-swap(v1)
 6       41.4GB 41.6GB 206MB   logical   ext4
 7       41.6GB 41.7GB 115MB   logical
 
(parted) mkpart                                  #分区
Partition type? primary/logical? logical        #选择逻辑
File system type? [ext2]? ext4                  #文件分区格式
Start? 41.7GB                                    #初始位置
End? 48GB                                        #结束位置
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until
after reboot.
(parted) p                                       #查看当前分区
Model: ATA WDC WD800JD-00LS (scsi)
Disk /dev/sda: 80.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
 
Number Start    End     Size    Type      File system     Flags
 1       1049kB 26.7GB 26.7GB primary   ext4            boot
 3       26.7GB 37.2GB 10.5GB primary                   lvm
 4       37.2GB 80.0GB 42.8GB extended
 5       37.2GB 41.4GB 4194MB logical   linux-swap(v1)
 6       41.4GB 41.6GB 206MB   logical   ext4
 7       41.6GB 41.7GB 115MB   logical
 8       41.7GB 48.0GB 6256MB logical         #新增加的分区
 
(parted) 

你可能感兴趣的:(linux,linux命令,linux系统)