linux parted 分区

来源:互联网 发布:stm32f103vb数据手册 编辑:程序博客网 时间:2024/05/16 10:20

http://www.dbdream.org/?p=157


用法示例:
打印一个磁盘的当前的分区结构:
$ parted /dev/sdb print
将一个MBR的磁盘格式化为GPT磁盘:
parted> mklabel gpt
将一个GPT磁盘格式化为MBR磁盘:
parted> mklabel msdos
划分一个起始位置是0,大小为100M的主分区:
parted> mkpart primary 0 100M 或者 $ parted /dev/sdb mkpart primary 0 100M
将一个磁盘的所有空间都划分成一个分区:
parted> mkpart primary 0 -1 或者 $ parted /dev/sdb mkpart primary 0 -1
删除一个分区:
parted> rm 1 或者 $ parted /dev/sdb rm 1

vgc-config -p /dev/vgcb0 -m maxperformance

vgc-config -p /dev/vgcb0 -m maxcapacity


parted /dev/vgca0p1 mkfs
parted /dev/vgcb0 rm 1
parted /dev/vgcb0 mkpart primary 65.5kB 2199GB
parted /dev/vgcb0 print
parted /dev/vgcb0 print -s
parted -l

parted /dev/vgcb0
mklabel ----创建磁盘标签


[root@sdw1 ~]# parted /dev/vgcb0
GNU Parted 2.1
Using /dev/vgcb0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help                                                             
  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) mklabel    创建分区表                                                       
New disk label type? gpt                                                  
(parted) p                                                              
Model: Unknown (unknown)
Disk /dev/vgcb0: 2222GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags


(parted) q                                                                
Information: You may need to update /etc/fstab.                           

创建分区

(parted) mkpart  Partition name?  []?            --可以指定分区名字 File system type?  [ext2]?      --文件系统类型  Start? 2048G                    --开始位置  End? 4096G                      --结束位置

在创建几个分区

(parted) mkpart                                                           Partition name?  []?                                                      File system type?  [ext2]?                                                Start? 4096G                                                              End? 6144G                                                                (parted) mkpart                                                           Partition name?  []?                                                      File system type?  [ext2]?                                                Start? 6144G                                                              End? 8192G                                                                (parted) mkpart                                                           Partition name?  []?                                                      File system type?  [ext2]?                                                Start? 8192G                                                              End? 10240G                                                               (parted) mkpart                                                           Partition name?  []?                                                      File system type?  [ext2]?                                                Start? 10240G                                                             End? -1                       --使用所有剩余空间 

[root@sdw1 ~]# parted /dev/vgcb0 mkpart primary 65.5kB 2199GB
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
Information: You may need to update /etc/fstab.                           



[root@sdw1 rules.d]# fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sda: 299.4 GB, 299439751168 bytes

255 heads, 63 sectors/track, 36404 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       36405   292421631+  ee  GPT

Disk /dev/vgca0: 2222.4 GB, 2222444249088 bytes
255 heads, 128 sectors/track, 132987 cylinders
Units = cylinders of 32640 * 512 = 16711680 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

      Device Boot      Start         End      Blocks   Id  System
/dev/vgca0p1               1      131586  2147483456   83  Linux
Partition 1 does not end on cylinder boundary.

WARNING: GPT (GUID Partition Table) detected on '/dev/vgcb0'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/vgcb0: 2222.4 GB, 2222444249088 bytes
255 heads, 63 sectors/track, 270196 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


      Device Boot      Start         End      Blocks   Id  System
/dev/vgcb0p1               1      267350  2147483647+  ee  GPT

0 0
原创粉丝点击