parted 用來管理硬碟磁區的指令,取代舊的 fdisk。
進入 parted CLI
#> parted /dev/mapper/mpath1
檢視目前硬碟的所有磁區清單
(parted) print free
新增一個 LVM 磁區
(parted) mklabel gpt (parted) mkpart datavg ext4 0 -1 (parted) print free
#mpathb is the disk name is in FC SAN with multipath enabled in my test env >parted /dev/mapper/mpathb (parted) mklabel gpt (parted) mkpart primary ext4 1024kb 2tb Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? #This warning indicates the start position of the partition may not aligned with physical sector of the #hard disk. It is very important for harddisk of hardware raid, the start position must be n*stripe size. #see also: http://honglus.blogspot.com.au/2009/08/align-partitions-on-stripe-boundary-for.html #It may also hold true for single hard disk, because even a single harddisk has sector size of 2K,4K #nowadays . #To fix the issue, just change the unit from SI to IEC 60027-2 standard # k- stands for kilo, meaning 1,000 in Metric(SI) Prefix # ki- stands for kilobinary ("kibi-"), meaning 1,024 in IEC 60027-2 standard (parted) help unit unit UNIT set the default unit to UNIT UNIT is one of: s, B, kB, MB, GB, TB, compact, cyl, chs, %, kiB, MiB, GiB, TiB (parted) mkpart primary ext4 1024KiB 8TiB #the values are accepted without any warning (parted) print .. Number Start End Size File system Name Flags 1 1049kB 8796GB 8796GB primary #1049KB is shown, because the default unit is KB, we change it to KiB (parted) unit KiB (parted) print .. Number Start End Size File system Name Flags 1 1024kiB 8589934592kiB 8589933568kiB primary #set LVM flag #GPT has reserved GUID for different partitions e.g LVM= E6D6D379-F507-44C2-A23C-238F2A3DF928 # (parted) set 1 lvm on (parted) p Model: Linux device-mapper (multipath) (dm) Disk /dev/mapper/mpathb: 19527106560kiB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 1024kiB 8589934592kiB 8589933568kiB primary lvm #create LVM physical volume as usual. >pvcreate /dev/mapper/mpathb1