redhat 6.5 parted磁碟分割槽工具初識

wisdomone1發表於2017-07-02
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)   

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-2141506/,如需轉載,請註明出處,否則將追究法律責任。

相關文章