52AV手機A片王|52AV.ONE

標題: 使用 gdisk或parted(支援GPT)指令來分割硬碟,fdisk 只支援MBR不支援GPT [打印本頁]

作者: IT_man    時間: 2016-1-2 20:13
標題: 使用 gdisk或parted(支援GPT)指令來分割硬碟,fdisk 只支援MBR不支援GPT
本帖最後由 IT_man 於 2017-3-21 22:08 編輯   }# f5 ?( p! ~! C; Q

4 c( s8 U3 z4 K1 \% ^參考 : http://linux.vbird.org/linux_basic/0230filesystem.php#parted  http://blog.yam.com/wesley1981/article/16596463        相關指令 fstab, findfs, mount  blkid7 B' w5 N- L* W
fdisk 請參考 :http://blogger.gtwang.org/2012/02/linux.html
6 [8 i+ u2 A8 _, M' W% d8 V' X* hformat 大於 16TB 的硬碟(>16TB一定要用此指令) : http://www.unix-ninja.com/p/Formatting_Ext4_volumes_beyond_the_16TB_limit/http://blog.yourdream.cc/2014/11/19/morethan16t.html
8 M% H' M. z* W6 t' ?8 k# a& \0 X1 g' i
新增硬碟時,開機自動mount(下指令mount只是暫時,重開機不會自動mount) :在/etc/fstab 加入下列一行:9 n5 m" z$ p/ |) o
/dev/sdb1               /home2                  ext4    defaults        1 17 i" a! w2 x  W; @5 Y. F1 j/ J

+ K" b2 Q9 K8 ]/ j4 b; rparted 詳細指令:https://blog.gtwang.org/linux/pa ... -disk-partitions/2/
( C6 {3 u: K; f/ `1 i5 Q   6 N' d6 r6 g( x6 ^/ h& h4 K% L
fdisk 指令只支援 MBR 不支援 GPT ,故要分割 GPT的硬碟需使用 parted 致個指令分割硬碟,以下將介紹 parted的用法
0 ?. T" V1 H* N0 }1 s1 f4 Q
2 y: [- j+ R8 G2 Y9 {- l) n% d% v% M7 l; G% `' E, s" i( }
parted 可以直接在一行指令列就完成分割,是一個非常好用的指令!它常用的語法如下:
4 ]3 A$ d1 T" r/ t& F4 W8 j5 C% O, T* M5 A# x7 R
parted [裝置] [指令 [參數]]
6 E& Q! y( f+ g+ R$ x選項與參數:- ~/ V$ K, r9 ]1 a
指令功能:: m: O! {# J' O1 n' K- T( @3 E" l2 F
          新增分割:mkpart [primary|logical|extended] [ext4|vfat|xfs] 開始 結束
, [; U( H6 x; H! `! k          顯示分割:print
1 M' v* O3 K. D: ^: y          刪除分割:rm [partition]& |2 ^5 J0 \8 B" c1 ~
例如:
  T& C! D& }7 z& p
$ d2 p2 j' f  F  o. _
方法一:  p' P0 e/ J" ?$ j/ S$ F
(parted) mkpart primary 0 100% (primary是partition name): y% d1 ]7 H& l: V! a

! ^/ T. J, M/ \% p5 }: m$ ?% Y方法二:
4 [' K: y  j6 ~  v4 pPartition name?  []? 30T_part
- G5 V4 j- o0 [/ aFile system type?  [ext2]? ext2  (ext4會有下列警告)
) c3 p9 l5 t# @+ ]3 @+ ]Start? 0B or 0%
& n/ `! S- o9 T6 yEnd? 30TB or 100%; b% d% `4 H3 t  m2 _
Warning: You requested a partition from 0.00B to 30.0TB.  d+ M6 m9 W# M) J# t
The closest location we can manage is 17.4kB to 30.0TB.
- E0 G* O' M0 v0 I8 m1 y  ~Is this still acceptable to you?5 {+ H% E- y/ {5 [0 i
Yes/No? Yes% M0 _; d) {) o# D5 z
Warning: The resulting partition is not properly aligned for best performance.
( m9 {: f) D; J. X: ^2 v$ P/ sIgnore/Cancel?
$ H5 t; i6 i- `  W7 \; F" H需使用ext2就不會有上述警告1 c8 s" }9 i7 O* W5 A
mkfs -t ext4 /dev/sdb1 ===> format) }# B. s. ^6 m9 F0 b, y2 x
ERROR:' ~+ r* x: i: w' k2 f0 y
mkfs.ext4: Size of device /dev/sdb1 too big to be expressed in 32 bits
# g* Q4 u2 m( U9 ^        using a blocksize of 40966 b, M. b3 Q2 V( v* w9 Z0 _
SOL: 0 x$ A" v+ F$ Q% c' d0 a! R0 R
format > 16TB see https://www.unix-ninja.com/p/For ... yond_the_16TB_limit% e1 P$ o3 C  ~6 o
/usr/local/src/wget -Oe2fsprogs-1.42.7.tar.gz http://downloads.sourceforge.net ... _mirror=superb-dca3
8 S+ J# {& a6 N$ x5 h/usr/local/src/tar -zxvf e2fsprogs-1.42.7.tar.gz, b" [0 Z- W! ?- z' K
cd /usr/local/src/e2fsprogs-1.42.7
3 M1 Y0 `& D2 o5 o+ Ymkdir build
/ x0 {; V* y6 B" M$ N- R2 A) ]cd build
9 {  L' i7 M8 ?: ?  B/ g" k ../configure
& {- X5 V2 v$ ]0 T3 x4 S, i0 e+ N make
; y; X5 ~/ j/ B) A make install
, F" B9 a* W+ X3 F  {! c" rmke2fs -O 64bit,has_journal,extents,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -i 4194304 /dev/sdb11 V, Q  c- x% |$ o
顯示下列提醒:* `! f' w) S4 S1 L' B5 V" ^0 U- E! R2 s
This filesystem will be automatically checked every 27 mounts or* W! h% L$ g- P* d, \* G6 E/ y
180 days, whichever comes first.  Use tune2fs -c or -i to override.% V0 {5 g  y7 H4 j
/etc/fstab中加入下列 : (fstab的介紹:http://horace1123.pixnet.net/blo ... b%E8%AA%AA%E6%98%8E)7 ]" M( D, d2 ^; t$ s( T- w- B' R
/dev/sdb1     /home2     ext4    defaults     1 0(第一個數字1:每日備份,第二個數字0:系統不正常時fsck不檢查)( I7 l/ R% y4 }- X
mount /home2, L/ d+ [4 q( u. z* e: w
, j1 d, o5 b9 o& Z' R2 z) y* C

: m- ]; c* }! c7 P1 o! |# ]=======================================================================  w) g* a2 D7 K; s

' K# t2 h. v- F1 d# P5 {[硬碟測試]1., L" [1 t- N- c; l; q8 t  Q4 J
Linux硬碟寫入速度測試的指令:7 c) q. \  @$ a3 ]
#time dd if=/dev/zero of=/home2/test bs=2k count=1000000   //     /home2 是mount raid0 的33TB 硬碟,由 11*3TB之SCSI硬碟' `; W* t+ U  b  \
1000000+0 records in
/ M) H, X7 ?& v- r8 O1000000+0 records out
) v3 f" M$ w" T/ u2048000000 bytes (2.0 GB) copied, 3.58735 s, 571 MB/s
# h, {0 N1 t7 g# [( k2 K& J! i! `
real    0m3.590s2 j8 I5 G0 H5 v# N9 M( t  b
user    0m0.130s6 U5 B: v- L* g& y& T5 D
sys     0m3.455s: X  E4 z% l% M+ m# m% t" J3 `

, J: [" Y1 H4 d* V. q6 p  _4 o: E
Linux硬碟讀取速度測試的指令:9 B' r: B" x( S$ |, c
#time dd if=/home2/test of=/dev/null bs=2k( C: y( h# Z4 ?# P% n" K/ @3 m5 n
1000000+0 records in
. D# x. V3 F# @5 n2 n* H1000000+0 records out2 J' L* }+ e$ \; n' s* }4 c' ^
2048000000 bytes (2.0 GB) copied, 0.952334 s, 2.2 GB/s0 k% \/ t0 ~9 f

2 \2 C$ w7 X# u, ]; h9 Lreal    0m0.954s
2 B! B, h% @& ?7 c4 xuser    0m0.083s
1 Z! n0 x) u& {) C& y1 Ysys     0m0.868s
+ ?$ b. }4 Q! Y  [- I4 i' O5 R7 o1 ^* G: t
解釋:
1 u9 [5 x  K, u3 k9 itime 用來計時
" y# q' d1 B7 B5 v' Y- ^( Vdd 用來複製,從if 到 OF
( }% p/ D2 ^) a2 Yif=/dev/zero不產生IO,所以可以用來測試純粹寫的速度;同樣的 of=/dev/null 不產生IO,可以用來測試純粹讀的速度. R$ U- k9 h# D. o0 r
bs 是每次測試單位量的大小,count是讀寫的速量,相乘就是資料的大小.( E4 U. r- P: |" M' v
資料越大越準確,多測試來取平均值。
6 C/ a' F1 x0 W" v數據量越大越准确,多次測試取平均值/ v4 _7 T+ D+ Q1 t; `& [; K0 P* X
由測試結果得到的數據顯示速度相當快了
/ T+ H6 I! d8 H% R1 P6 K, ~3 ?% Y2 U7 m5 [; e% @  Q
測試完記得刪除 /home2/test5 \4 Y! W: T  Z
2.
8 x5 p4 M- s. v9 B1 G另一種方法:) v: H0 \' B" A; Q4 T8 k& u
; y  ?0 r( Y2 l  o6 O
測試硬碟讀取速度:; H* @9 M, n0 c5 V" g
hdparm -t /dev/sdb
: q" [' t. B' X
- S. I; h/ l4 y$ F; D/dev/sdb: (使用raid0速度快)! s/ @( Q  y3 w! W) W
Timing buffered disk reads: 1732 MB in  3.00 seconds = 576.98 MB/sec
' @, l2 b  d/ @4 b$ `) C, B, ?; y5 `0 ?& \7 C, j9 l2 {
/dev/sdb: (後來改成LVM速度慢)7 `! }6 U9 M4 {' r6 W: i
/dev/sdb:
4 T, ?4 P: G/ k% jTiming buffered disk reads: 546 MB in  3.01 seconds = 181.43 MB/sec# u. K; \- C0 L6 ?- x
測試硬碟寫入速度:
$ g, \+ ~! W; C$ ~' n' O hdparm -t --direct /dev/sdb+ J& D; [8 C5 e* F
# V9 }$ z' o* v9 \! y# h
/dev/sdb: (使用raid0速度快)# C/ g$ B" X& F5 B
Timing O_DIRECT disk reads: 1326 MB in  3.29 seconds = 402.57 MB/sec
, }# G" `- K- E& {4 `+ A, w8 m, u
/dev/sdb: (後來改成LVM速度慢)) R% C& H3 r9 s! z# n) @' U
Timing O_DIRECT disk reads: 560 MB in  3.00 seconds = 186.36 MB/sec2 A6 x" I2 B6 @

) [2 g9 o0 W3 e  k$ |. {$ j; G+ m  q9 s+ W( h2 C
另外測試 /dev/sda  SSD硬碟 速度只有 raid0 scsi 硬碟的一半
/ Y  V6 c$ I/ Q: R! t: @8 p! X7 ?
, v2 h4 l  \1 S3 Z2 D5 W+ U9 x: @! z& y& P# A- R) h( j( M, l$ C4 r: @
% n* b1 B4 T" i
) H" x% E" P3 q" t
) |% z7 N$ f$ Q: S( D$ O. E) w' r% a
$ ]% [7 h- r9 x! J0 o* ^





歡迎光臨 52AV手機A片王|52AV.ONE (https://www.52av.one/) Powered by Discuz! X3.2