fdisk不支持超過2T的硬盤所以使用parted進行掛載硬盤
當在命令行輸入parted后,進入parted命令的交互模式。輸入help會顯示幫助信息。下面就簡單介紹一下常用的功能
1、check 簡單檢查文件系統(tǒng)。建議用其他命令檢查文件系統(tǒng),比如fsck
2、help 顯示幫助信息
3、mklabel 創(chuàng)建分區(qū)表, 即是使用msdos(MBR)還是使用gpt,或者是其他方式分區(qū)表
4、 mkfs 創(chuàng)建文件系統(tǒng)。該命令不支持ext3 格式,因此建議不使用,最好是用parted分好區(qū),然后退出parted交互模式,用其他命令進行分區(qū),比如:mkfs.ext3
5、mkpart 創(chuàng)建新分區(qū)。
格式:mkpart PART-TYPE? [FS-TYPE]? START? END
PART-TYPE 類型主要有primary(主分區(qū)), extended(擴展分區(qū)), logical(邏輯區(qū)). 擴展分區(qū)和邏輯分區(qū)只對msdos。
fs-type?文件系統(tǒng)類型,主要有fs32,NTFS,ext2,ext3等
start end 分區(qū)的起始和結(jié)束位置。
6、mkpartfs 建立分區(qū)及其文件系統(tǒng)。目前還不支持ext3文件系統(tǒng),因此不建議使用該功能。最后是分好區(qū)后,退出parted,然后用其他命令建立文件系統(tǒng)。
7、print 輸出分區(qū)信息。該功能有3個選項,
free?顯示該盤的所有信息,并顯示磁盤剩余空間
number 顯示指定的分區(qū)的信息
all 顯示所有磁盤信息????
8、resize 調(diào)整指定的分區(qū)的大小。目前對ext3格式支持不是很好,所以不建議使用該功能。
9、rescue 恢復(fù)不小心刪除的分區(qū)。如果不小心用parted的rm命令刪除了一個分區(qū),那么可以通過rescue功能進行恢復(fù)。恢復(fù)時需要給出分區(qū)的起始和結(jié)束的位置。然后parted就會在給定的范圍內(nèi)去尋找,并提示恢復(fù)分區(qū)。
10、rm?刪除分區(qū)。命令格式?rm?number 。如:rm?3 就是將編號為3的分區(qū)刪除
11、select?選擇設(shè)備。當輸入parted命令后直接回車進入交互模式是,如果有多塊硬盤,需要用select?選擇要操作的硬盤。如:select?/dev/sdb
12、set?設(shè)置標記。更改指定分區(qū)編號的標志。標志通常有如下幾種:boot? hidden?? raid?? lvm 等。
boot 為引導(dǎo)分區(qū),hidden 為隱藏分區(qū),raid 軟raid,lvm 為邏輯分區(qū)。
如:set?3? boot? on?? 設(shè)置分區(qū)號3 為啟動分區(qū)
注:以上內(nèi)容為parted常用的功能,由于該工具目前對ext3支持得不是很好,因此有些功能無法應(yīng)用,比如move(移動分區(qū))和resize等。
下面是在虛擬機上的操作,實際情況自行修改.
首先? fdisk? -l? 找到新加進來的RAID5組 確定路徑/dev/sdb

[root@localhost ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number? Start? End? Size? File system? Name? Flags
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? y
(parted) mkpart sdb1 xfs? 0%? 100%? ? ? ? ? ? ? ? ? ? ?# 一定用百分符號否則會出現(xiàn)下面4k對齊失敗的錯誤
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) p? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number? Start? End? ? Size? ? File system? Name? Flags
1? ? ? 17.4kB? 21.5GB? 21.5GB? ? ? ? ? ? ? sdb1
(parted) q? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Information: You may need to update /etc/fstab.
[root@localhost ~]# mkfs.xfs? -f? /dev/sdb1? #格式化為xfs格式,-f 是強制使用未對齊4K的設(shè)置一般上面步驟已經(jīng)對齊過不需要用f
meta-data=/dev/sdb1? ? ? ? ? ? ? isize=512? ? agcount=4, agsize=1310718 blks
? ? ? ? =? ? ? ? ? ? ? ? ? ? ? sectsz=512? attr=2, projid32bit=1
? ? ? ? =? ? ? ? ? ? ? ? ? ? ? crc=1? ? ? ? finobt=0, sparse=0
data? ? =? ? ? ? ? ? ? ? ? ? ? bsize=4096? blocks=5242871, imaxpct=25
? ? ? ? =? ? ? ? ? ? ? ? ? ? ? sunit=0? ? ? swidth=0 blks
naming? =version 2? ? ? ? ? ? ? bsize=4096? ascii-ci=0 ftype=1
log? ? ? =internal log? ? ? ? ? bsize=4096? blocks=2560, version=2
? ? ? ? =? ? ? ? ? ? ? ? ? ? ? sectsz=512? sunit=0 blks, lazy-count=1
realtime =none? ? ? ? ? ? ? ? ? extsz=4096? blocks=0, rtextents=0
[root@localhost ~]# fdisk -l? #再次查看一下
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: A397BB7B-031C-481B-9672-2B37012C2624
#? ? ? ? Start? ? ? ? ? End? ? Size? Type? ? ? ? ? ? Name
1? ? ? ? ? 34? ? 41943006? ? 20G? Microsoft basic sdb1
Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000be025
? Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System
/dev/sda1? *? ? ? ? 2048? ? 2099199? ? 1048576? 83? Linux
/dev/sda2? ? ? ? 2099200? ? 41943039? ? 19921920? 8e? Linux LVM
Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[root@localhost ~]# mkdir /data? ? #創(chuàng)建一個掛載用的文件夾做測試
[root@localhost ~]# mount /dev/sdb1 /data/
[root@localhost ~]# df -h
Filesystem? ? ? ? ? ? ? Size? Used Avail Use% Mounted on
/dev/mapper/centos-root? 17G? 13G? 4.3G? 75% /
devtmpfs? ? ? ? ? ? ? ? 894M? ? 0? 894M? 0% /dev
tmpfs? ? ? ? ? ? ? ? ? ? 910M? ? 0? 910M? 0% /dev/shm
tmpfs? ? ? ? ? ? ? ? ? ? 910M? 11M? 900M? 2% /run
tmpfs? ? ? ? ? ? ? ? ? ? 910M? ? 0? 910M? 0% /sys/fs/cgroup
/dev/sda1? ? ? ? ? ? ? 1014M? 179M? 836M? 18% /boot
tmpfs? ? ? ? ? ? ? ? ? ? 182M? 8.0K? 182M? 1% /run/user/42
tmpfs? ? ? ? ? ? ? ? ? ? 182M? 44K? 182M? 1% /run/user/0
/dev/sr0? ? ? ? ? ? ? ? 4.3G? 4.3G? ? 0 100% /run/media/root/CentOS 7 x86_64
/dev/sdb1? ? ? ? ? ? ? ? 20G? 33M? 20G? 1% /data
[root@localhost ~]# echo "/dev/sdb1? ?/data? xfs? ?defaults? 0 0 " >> /etc/fstab? ? #添加啟動項