稳定互联,中美互联,站长交流,虚拟主机,香港主机,美国主机,虚拟空间,免费空间,免费VPS,免费域名

 找回密码
 立即注册
查看: 2834|回复: 0

[经验] linux下添加新硬盘方法

[复制链接]
发表于 2014-2-9 19:20:26 | 显示全部楼层 |阅读模式
  1. fdisk
复制代码
Usage: fdisk [-l] [-b SSZ] [-u] device    E.g.: fdisk /dev/hda  (for the first IDE disk)
9 f; `, j2 ~' C- J2 u$ W% [2 Q3 S$ H: n      or: fdisk /dev/sdc  (for the third SCSI disk)
  o: g" T  |% J$ m1 s: p5 b      or: fdisk /dev/eda  (for the first PS/2 ESDI drive), S( ?, G6 `: q
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)6 U( \2 H3 N6 o! X
      ...5 D& @/ X; d- B/ j: _* q* W  W4 `4 Z. T
  1. df -k$ I" a$ B- |7 ]. V( d) C( n
  2. df -lh6 E& R& |0 `: M. k
  3. 查看有几块硬盘:fdisk -l, E' p% ?% f* X5 J5 l3 t' J
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: n8 d! r; p6 I    /dev/sda3              3723848    705968   2828716  20% /
8 M0 q1 m9 `9 M; q& O    /dev/sda1               101089      9274     86596  10% /boot: e, z6 ]5 f$ Y- I
    none                     14520         0     14520   0% /dev/shm  ]' p9 [4 j# [9 [. h' ?
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
$ j9 n3 U3 `1 _, O
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel4 J& O! {( B( c. P- i! g) P: i3 |
    Building a new DOS disklabel. Changes will remain in memory only,. @& b1 h( `5 e" a
    until you decide to write them. After that, of course, the previous8 `2 [& ]% H9 Z6 G
    content won't be recoverable.# T8 _1 U. a$ L
    The number of cylinders for this disk is set to 8322.
$ z7 c- q2 v8 f0 N+ s    There is nothing wrong with that, but this is larger than 1024,
- }. Q- d6 y& U/ g  ]" `3 ^! u    and could in certain setups cause problems with:4 e4 t9 _0 D9 K
    1) software that runs at boot time (e.g., old versions of LILO)  ]0 M- b/ Q) O0 F1 s% N7 x7 O
    2) booting and partitioning software from other OSs! G, ?: k5 e, o, G9 J- x* {
       (e.g., DOS FDISK, OS/2 FDISK)
2 ~: X  B% a- H/ S$ J+ Z! G    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
* `) x3 J, W- \. `* s( f    Command (m for help): p/ q% \, W7 u5 C- [) G
    Disk /dev/hda: 4294 MB, 4294967296 bytes
; _$ ~1 j) `0 @4 C" g3 `    16 heads, 63 sectors/track, 8322 cylinders
& z  \% W4 W& c$ b/ B    Units = cylinders of 1008 * 512 = 516096 bytes
/ `; ]( Y9 t' A8 w8 B8 K       Device Boot    Start       End    Blocks   Id  System
# v( M' \! i& A    Command (m for help): m' b5 a! M; H  q5 L1 w1 i" E0 A- v
    Command action3 l# y0 ~0 e% }) f; C0 D* p* D
       a   toggle a bootable flag4 J# b- Z  ]8 b+ @
       b   edit bsd disklabel/ p( N: D6 S' t3 L  W- E
       c   toggle the dos compatibility flag+ o& f0 v& I' P( e$ @
       d   delete a partition
7 k5 ]0 H1 c$ R, I1 N  X7 ^       l   list known partition types$ i) u$ B) j& q. j
       m   print this menu% }( J; Z& |: ?4 W7 X" b
       n   add a new partition( P" Q# [0 b7 ^% R2 u
       o   create a new empty DOS partition table
1 p( k: G# {5 q  ]& z( y       p   print the partition table
0 V3 a6 A- N6 L, E0 x) h' M       q   quit without saving changes/ Z0 k  X/ `" j4 I
       s   create a new empty Sun disklabel8 H5 R; H: G( r' r1 {4 S' e$ q& p
       t   change a partition's system id, [& y2 K, d9 d6 m" e. C+ ?, A) e
       u   change display/entry units  S, `: r4 B* v4 e. c  L
       v   verify the partition table% [  X4 d" ~7 ?% \7 I$ [, t& t
       w   write table to disk and exit/ J7 b+ f/ G8 \1 f/ J
       x   extra functionality (experts only)8 J; R/ y. K& W0 O9 _2 d: f
    Command (m for help): n
9 L6 R, k1 E4 O# q& y" I. S    Command action
- i$ f# ^2 t& _! H/ A0 w+ p- V       e   extended; Y4 j- |/ J  C5 \& n
       p   primary partition (1-4)
3 h5 w) S/ G3 I9 N3 K# z; t    p
, H& s+ r! b$ J9 ]$ z    Partition number (1-4): 1
6 Z! M# K! X7 ^" b    First cylinder (1-8322, default 1):
8 v; X/ H" C" D* t4 X! ~( _0 g- c    Using default value 1
: `' C# v8 |* j    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G1 E- t5 o% y" b; c
    Command (m for help): p0 C  P, u2 O4 ]+ V+ `8 `
    Disk /dev/hda: 4294 MB, 4294967296 bytes
$ O* A" q* p  }$ k! t3 y    16 heads, 63 sectors/track, 8322 cylinders
, j0 K8 ?9 q: v. z    Units = cylinders of 1008 * 512 = 516096 bytes4 R. L: l' z" J1 }, {: ]# Z8 K
       Device Boot    Start       End    Blocks   Id  System! t5 N6 Q! ^( z
    /dev/hda1             1      1000    503968+  83  Linux1 z# D0 a! w. \- r
    Command (m for help): w2 A' ?, f2 [2 [# ~+ s% _9 d6 A- y3 b
    The partition table has been altered!! d: p& b* a1 C4 Z! a
    Calling ioctl() to re-read partition table.
1 L4 N" s, i7 _    Syncing disks.
" m( u: n1 H2 \+ s    //格式化新分区
+ L; `; x4 ^* {
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)( X) Q$ T  `1 ?! A2 f
    Filesystem label=
; S2 a, j, [! b* k0 i$ ~1 w; B    OS type: Linux
/ w& m0 \# H% M+ w4 c0 P    Block size=1024 (log=0)
. I: W- O  ~! `$ z( b    Fragment size=1024 (log=0)
% K+ }/ u5 ]# P. y. Q    126480 inodes, 503968 blocks9 x" o% w  x5 {3 a
    25198 blocks (5.00%) reserved for the super user
: h4 U/ f1 g" @* H    First data block=1' h# P+ r7 S  q. _6 n( B
    62 block groups7 f+ f3 K. q6 |  B
    8192 blocks per group, 8192 fragments per group/ h8 P  ?8 Q* ~3 o/ X- E$ u
    2040 inodes per group
" j$ G4 s% [+ [. H    Superblock backups stored on blocks: / G9 ?* {( m& X8 k4 g& j
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
( V* F' V7 m8 G, {* \0 Y# ^" R3 {    Writing inode tables: done                            * y6 q  `' S6 ?. \% s
    Creating journal (8192 blocks): done
+ j* h, H9 y6 F; n, k8 N    Writing superblocks and filesystem accounting information: done
" f5 G- n- V" d, }1 T* ^5 {/ }    This filesystem will be automatically checked every 30 mounts or) L: \- T% T3 z3 P3 ?7 ~5 D
    180 days, whichever comes first.  Use tune2fs -c or -i to override." w1 f" v; C, ^
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 x" U! E9 I; h) _0 N
    /dev/sda3              3723848    705992   2828692  20% /
: M8 r2 v) l, g4 Q4 M7 j9 X    /dev/sda1               101089      9274     86596  10% /boot" V4 T4 d2 Y1 x- ~- s6 o
    none                     14520         0     14520   0% /dev/shm
' X! o+ d; w2 }! I: W. F; r) }    //挂上新分区) a7 O' _' S; f0 h
  1. mount /dev/hda1 /home
    * L  e9 c+ K- y0 H; [
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 l' m8 {9 l. m9 c
    /dev/sda3              3723848    705992   2828692  20% /
1 s$ r9 Z# e. m1 h    /dev/sda1               101089      9274     86596  10% /boot( w- ]- J4 [8 t) X
    none                     14520         0     14520   0% /dev/shm" q! N+ [; v/ ?
    /dev/hda1               488006      8239    454569   2% /home
$ \7 Y0 D% Z$ x# D( ^- g, Q! z/ B5 I
自动挂载:" e  W% B8 |4 E5 ]8 m3 t
  1.           vi /etc/fstab: l( f+ i( `# b

  2. ! T3 A: Z) a, i- y' p  u) N
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 N+ E, Z& F+ f$ L1 k  M3 |

  4. 1 _! T" v+ e* j& L- R
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
+ H. T/ A4 U  r* @
  1.           mount /dev/sdb5 /mnt/ljp1
    2 P' ]; z$ w, f) A( e  b' a- k

  2. 2 W3 a- C7 Z! W4 B2 [; t: r( N
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
( {: U( @* ]$ i) i3 s8 }) d3 @

6 u  u* ?7 X1 K) N# [! ?
$ b  a+ u8 p: v, S0 A, {( Q
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|WdidcNet ( 苏ICP备17005075号-1 )

GMT+8, 2026-1-23 01:45 , Processed in 0.039083 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

快速回复 返回顶部 返回列表