转载

redhat 6.5 parted磁盘分区工具初识

1,操作系统版本
[root@mygirl ~]# more /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)
[root@mygirl ~]# 


2,查看新增的磁盘
[root@mygirl ~]# fdisk -l|grep -i --color "/dev/sd"
Disk /dev/sda: 21.5 GB, 21474836480 bytes
/dev/sda1   *           1        2168    17408000   83  Linux
/dev/sda2            2168        2611     3562496   82  Linux swap / Solaris
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
/dev/sdb1               1        2610    20964793+  83  Linux
Disk /dev/sdc: 2147 MB, 2147483648 bytes


3,查看parted命令
[root@mygirl ~]# parted --help
Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
Apply COMMANDs with PARAMETERS to DEVICE.  If no COMMAND(s) are given, run in
interactive mode.


OPTIONs:
  -h, --help                      displays this help message
  -l, --list                      lists partition layout on all block devices
  -m, --machine                   displays machine parseable output
  -s, --script                    never prompts for user intervention
  -v, --version                   displays the version
  -a, --align=[none|cyl|min|opt]  alignment for new partitions


COMMANDs:
  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
[root@mygirl ~]# 


4,显示所有磁盘分区信息


[root@mygirl ~]# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type     File system     Flags
 1      1049kB  17.8GB  17.8GB  primary  ext4            boot
 2      17.8GB  21.5GB  3648MB  primary  linux-swap(v1)




Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  21.5GB  21.5GB  primary  ext4




Error: /dev/sdc: unrecognised disk label


5,可见parted默认是定位第一个磁盘/dev/sda
[root@mygirl ~]# parted
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type     File system     Flags
 1      1049kB  17.8GB  17.8GB  primary  ext4            boot
 2      17.8GB  21.5GB  3648MB  primary  linux-swap(v1)


(parted) quit                                                             
[root@mygirl ~]# 


6,根据上述第3个命令可见parted命令的用法以及上述命令的结构分类
查看parted命令
[root@mygirl ~]# parted --help
Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
Apply COMMANDs with PARAMETERS to DEVICE.  If no COMMAND(s) are given, run in
interactive mode.




7,parted /dev/sdc可以定位指定的磁盘,然后help会显示对应的具体命令


[root@mygirl ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
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)     




8,查看mkpart创建分区的用法
(parted) help mkpart                                                      
  mkpart PART-TYPE [FS-TYPE] START END     make a partition


        PART-TYPE is one of: primary, logical, extended
        FS-TYPE is one of: ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs,
        amufs5, amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1, affs0, linux-swap, linux-swap(new), linux-swap(old)
        START and END are disk locations, such as 4GB or 10%.  Negative values count from the end of the disk.  For example, -1s specifies exactly the last sector.
        
        'mkpart' makes a partition without creating a new file system on the partition.  FS-TYPE may be specified to set an appropriate partition ID.
(parted)     




9,创建磁盘分区,但报错如下
(parted) mkpart primary                                                   
Error: /dev/sdc: unrecognised disk label  




10,据以上分析,可能还要进行其它的配置,查看mklabel命令
(parted) help mklabel                                                     
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)


        LABEL-TYPE is one of: aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun, loop  






11,使用mklabel创建磁盘标签
(parted) mklabel msdos  




12,无法预先知道开始及结束的柱面编号 
(parted) mkpart primary                                                   
File system type?  [ext2]? ext4                                           
Start? 1                                                                  
End?                                                                      
End?                                                                      
End?                                                                      
End? ^C                                                                   
(parted)    




(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start  End  Size  Type  File system  Flags




13,进行对比分析法获取磁盘分区之开始及结束的含义
(parted) mkpart primary ext4 1 100




14,查看磁盘所有的磁盘分区信息,可见开始及结束是以M为单元的
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type     File system  Flags
 1      1049kB  99.6MB  98.6MB  primary




 15,使用rm 删除某个磁盘分区
 (parted) rm 1 


 (parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start  End  Size  Type  File system  Flags


16,基于上述逻辑继续创建多个磁盘分区,可见主分区primary不能创建超过4个,如果创建第5个就会报错
(parted) mkpart primary 1 300                                             
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size   Type     File system  Flags
 1      1049kB  300MB  299MB  primary




 (parted) mkpart primary 301 400
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type     File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary




(parted) mkpart primary 401 450                                           
(parted) mkpart primary 451 453                                           
(parted) mkpart primary 454 455                                           
Error: Can't create any more partitions.                                  
(parted)                




(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type     File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   453MB  2097kB  primary




17,不以基于第4个主分区primary创建逻辑分区或者扩展分区
(parted) help mkpart                                                      
  mkpart PART-TYPE [FS-TYPE] START END     make a partition


        PART-TYPE is one of: primary, logical, extended
        FS-TYPE is one of: ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs, sun-ufs, xfs, apfs2, apfs1, asfs,
        amufs5, amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1, affs0, linux-swap, linux-swap(new), linux-swap(old)
        START and END are disk locations, such as 4GB or 10%.  Negative values count from the end of the disk.  For example, -1s specifies exactly the last sector.
        
        'mkpart' makes a partition without creating a new file system on the partition.  FS-TYPE may be specified to set an appropriate partition ID.
(parted)   




(parted) mkpart logical 455 480                                           
Error: Can't create any more partitions. 




(parted) mkpart extended 455 480                                          
Error: Can't create any more partitions.






18,可以基于第3个主分区然后马上创建扩展分区extended
(parted) rm 4
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type     File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary




 (parted) mkpart extended 451 500
(parted)  


(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type      File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   500MB  49.3MB  extended               lba




19,基于扩展分区创建的逻辑分区不能创建大小,否则会报错如下影响性能,当然你可以忽略这个提示
(parted) mkpart logical 452 480
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type      File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   500MB  49.3MB  extended               lba
 5      452MB   480MB  28.3MB  logical




(parted) mkpart logical 481 483                                           
(parted) mkpart logical 484 486                                           
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ignore                                                     
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type      File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   500MB  49.3MB  extended               lba
 5      452MB   480MB  28.3MB  logical
 6      481MB   483MB  2097kB  logical
 7      484MB   486MB  2000kB  logical


 (parted)                                                                  
(parted) mkpart logical 487 490                                           
(parted) mkpart logical 491 493                                           
(parted) mkpart logical 494 495
(parted) mkpart logical 496 497                                           
(parted) mkpart logical 498 499
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type      File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   500MB  49.3MB  extended               lba
 5      452MB   480MB  28.3MB  logical
 6      481MB   483MB  2097kB  logical
 7      484MB   486MB  2000kB  logical
 8      487MB   490MB  3146kB  logical
 9      491MB   493MB  2097kB  logical
10      494MB   495MB  1049kB  logical
11      496MB   497MB  1049kB  logical
12      498MB   499MB  1049kB  logical


20,可见扩展分区是父分区,而逻辑分区是子分区,即后者只能基于或依赖于前者,且后者逻辑分区的空间范围只能位于所属扩展分区的空间范围
(parted) mkpart logical 500 501                                           
Warning: You requested a partition from 500MB to 501MB.                   
The closest location we can manage is 500MB to 500MB.
Is this still acceptable to you?
Yes/No? ys                                                                
parted: invalid token: ys
Yes/No? yes                                                               
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? ignore                                                     
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type      File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   500MB  49.3MB  extended               lba
 5      452MB   480MB  28.3MB  logical
 6      481MB   483MB  2097kB  logical
 7      484MB   486MB  2000kB  logical
 8      487MB   490MB  3146kB  logical
 9      491MB   493MB  2097kB  logical
10      494MB   495MB  1049kB  logical
11      496MB   497MB  1049kB  logical
12      498MB   499MB  1049kB  logical
13      500MB   500MB  512B    logical


(parted)         




21,好像不能创建多个扩展分区extended
(parted) mkpart extended 501 600
parted: invalid token: extended
Partition type?  [logical]? 


22,可见退出parted会自动保存上次parted操作的结果
(parted) quit                                                             
Information: You may need to update /etc/fstab.   




[root@mygirl ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type      File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary
 4      451MB   500MB  49.3MB  extended               lba
 5      452MB   480MB  28.3MB  logical
 6      481MB   483MB  2097kB  logical
 7      484MB   486MB  2000kB  logical
 8      487MB   490MB  3146kB  logical
 9      491MB   493MB  2097kB  logical
10      494MB   495MB  1049kB  logical
11      496MB   497MB  1049kB  logical
12      498MB   499MB  1049kB  logical
13      500MB   500MB  512B    logical


(parted)          




23,可见只要删除扩展分区,会一并把下属的逻辑分区全部删除
(parted) rm 4                                                             
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type     File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary




24,可见只能创建一个扩展分区,不能创建多个扩展分区
(parted) mkpart extended 451 500                                          
(parted) mkpart extended 501 600                                          
parted: invalid token: extended
Partition type?  [logical]? logical                                       
File system type?  [ext2]? ext3                                           
Start? 451                                                                
End? 600                                                                  
Warning: You requested a partition from 451MB to 600MB.                   
The closest location we can manage is 451MB to 500MB.
Is this still acceptable to you?
Yes/No?     


25,由下可知,主分区为第1到第4,从第5之后为逻辑分区
(parted) rm 4
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End    Size    Type     File system  Flags
 1      1049kB  300MB  299MB   primary
 2      301MB   400MB  98.6MB  primary
 3      401MB   450MB  49.3MB  primary




(parted) mkpart extended 451 2147                                         
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type      File system  Flags
 1      1049kB  300MB   299MB   primary
 2      301MB   400MB   98.6MB  primary
 3      401MB   450MB   49.3MB  primary
 4      451MB   2147MB  1697MB  extended               lba




(parted) help mkfs                                                        
  mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partition NUMBER


        NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards.
        FS-TYPE is one of: ext2, fat32, fat16, swsusp, linux-swap(v1), linux-swap(v0), linux-swap, linux-swap(new), linux-swap(old)
(parted)    




26,mkfs好像不能指定磁盘分区编号进行划分文件系统,而且可以指定的文件系统特别少,顶多到ext2,我分析可能是parted的版本太老了可能
(parted) mkfs 1  ext2                                                     
WARNING: you are attempting to use parted to operate on (mkfs) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs.  We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Warning: The existing file system will be destroyed and all data on the partition will be lost. Do you want to continue?
parted: invalid token: 1
Yes/No? yes                                                               
Partition number? 1                                                       
File system type?  [ext2]? ext2                                           
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type      File system  Flags
 1      1049kB  300MB   299MB   primary   ext2
 2      301MB   400MB   98.6MB  primary
 3      401MB   450MB   49.3MB  primary
 4      451MB   2147MB  1697MB  extended               lba


(parted)                       




27,check 用于检查磁盘分区的文件系统,但parted不建议使用它,而应使用e2fsck检查文件系统
(parted) help check                                                       
  check NUMBER                             do a simple check on the file system


        NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards.
(parted)    


(parted) check 1                                                          
WARNING: you are attempting to use parted to operate on (check) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs.  We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Information: The ext2 file system passed a basic check.  For a more comprehensive check, use the e2fsck program.
(parted)       


28,基于磁盘分区1的文件系统进行挂载目录
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type      File system  Flags
 1      1049kB  300MB   299MB   primary   ext2
 2      301MB   400MB   98.6MB  primary
 3      401MB   450MB   49.3MB  primary
 4      451MB   2147MB  1697MB  extended               lba


(parted)   




[root@mygirl ~]# fdisk -l|grep "/dev/sdc"
Disk /dev/sdc: 2147 MB, 2147483648 bytes
/dev/sdc1               1          37      291840   83  Linux
/dev/sdc2              37          49       96256   83  Linux
/dev/sdc3              49          55       48128   83  Linux
/dev/sdc4              55         262     1656832    f  W95 Ext'd (LBA)
[root@mygirl ~]# 


[root@mygirl ~]# mkdir -p /test_dir
[root@mygirl ~]# mount /dev/sdc1 /test_dir
[root@mygirl ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        17G   16G   89M 100% /
tmpfs          1004M  112K 1004M   1% /dev/shm
/dev/sdc1       268M   13K  253M   1% /test_dir




29,基于msdos的分区类型,使用name对指定的磁盘分区重命名会报错如下
[root@mygirl ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)  


(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos


Number  Start   End     Size    Type      File system  Flags
 1      1049kB  300MB   299MB   primary   ext2
 2      301MB   400MB   98.6MB  primary
 3      401MB   450MB   49.3MB  primary
 4      451MB   2147MB  1697MB  extended               lba


(parted)                    




(parted) help name                                                        
  name NUMBER NAME                         name partition NUMBER as NAME


        NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards.
        NAME is any word you want






(parted) name 2 part2                                                     
Error: msdos disk labels do not support partition names.                  
Error: msdos disk labels do not support partition names.                  
(parted)   






30,使用mklabel已经配置了分区表后,然后再次执行mklabel,之前的分区表以及磁盘分区信息全部会丢失,所以一定要小心仔细 


清除之前MSDOS的磁盘分区表,然后重新创建GPT磁盘分区表
(parted) help mklabel                                                     
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)


        LABEL-TYPE is one of: aix, amiga, bsd, dvh, gpt, mac, msdos, pc98, sun, loop
(parted) 




(parted) mklabel gpt                                                      
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt


Number  Start  End  Size  File system  Name  Flags


(parted)    




31,基于GPT磁盘分区表可以使用NAME命令,但好像我之前理解不对,这个名称是对应主分区PRIMARY之类的,而不是NUMBER对应的信息
(parted) mkpart primary 1 100                                             
(parted) mkpart primary 101 200                                           
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt


Number  Start   End     Size    File system  Name     Flags
 1      1049kB  99.6MB  98.6MB  ext2         primary
 2      101MB   200MB   99.6MB               primary


 (parted) name 2 part2                                                     
(parted) 


                                                    
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt


Number  Start   End     Size    File system  Name     Flags
 1      1049kB  99.6MB  98.6MB  ext2         primary
 2      101MB   200MB   99.6MB               part2




32,mkfs还是不能使用ext3,只能使用ext2
(parted) help mkfs                                                        
  mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on partition NUMBER


        NUMBER is the partition number used by Linux.  On MS-DOS disk labels, the primary partitions number from 1 to 4, logical partitions from 5 onwards.
        FS-TYPE is one of: ext2, fat32, fat16, swsusp, linux-swap(v1), linux-swap(v0), linux-swap, linux-swap(new), linux-swap(old)
(parted) 






(parted) mkfs 2 ext2                                                      
WARNING: you are attempting to use parted to operate on (mkfs) a file system.
parted's file system manipulation code is not as robust as what you'll find in
dedicated, file-system-specific packages like e2fsprogs.  We recommend
you use parted only to manipulate partition tables, whenever possible.
Support for performing most operations on most types of file systems
will be removed in an upcoming release.
Warning: The existing file system will be destroyed and all data on the partition will be lost. Do you want to continue?
parted: invalid token: 2
Yes/No? y                                                                 
Partition number? 2                                                       
File system type?  [ext2]? ext3                                           
No Implementation: Support for creating ext3 file systems is not implemented yet.
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdc: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt


Number  Start   End     Size    File system  Name     Flags
 1      1049kB  99.6MB  98.6MB  ext2         primary
 2      101MB   200MB   99.6MB               part2


(parted)   

正文到此结束
Loading...