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

 找回密码
 立即注册
查看: 2579|回复: 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)
* z7 j+ j: Y8 m$ h1 R5 \$ k. T- |' c      or: fdisk /dev/sdc  (for the third SCSI disk)1 r1 z( b- b4 ]# ]# J( [
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)* b0 J+ h! O( n
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
2 k& N3 X; m* ^2 g* X      ...
0 k6 B2 O1 U3 r' {* e, u
  1. df -k
    + P7 o" `* |1 g- ]: f2 x# T$ n
  2. df -lh
    : F% P+ M$ a6 u: U
  3. 查看有几块硬盘:fdisk -l
    8 D  R# ^% J/ C) ^) _) `
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  x2 f5 U4 f1 w# Z& ~% [, O
    /dev/sda3              3723848    705968   2828716  20% /% O" @8 ~6 C' P4 v5 b2 {
    /dev/sda1               101089      9274     86596  10% /boot
: k  W# b: J5 ?, k    none                     14520         0     14520   0% /dev/shm5 @) }3 ?- a; c6 B) H: B
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用) _" l+ E1 v, t7 L9 ]4 j
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel9 G) ]/ E* ^0 Q. Z* o5 l
    Building a new DOS disklabel. Changes will remain in memory only,' W$ a. s9 V5 N
    until you decide to write them. After that, of course, the previous
, s" }  O: \) [* x6 C. c  o3 o, Y    content won't be recoverable.  I) }. Q: d9 ^* z2 X
    The number of cylinders for this disk is set to 8322./ O/ |- D2 X4 A
    There is nothing wrong with that, but this is larger than 1024,( D1 r' h- @, E3 n) H0 _
    and could in certain setups cause problems with:# E3 y8 w0 C* C4 H% `2 Z
    1) software that runs at boot time (e.g., old versions of LILO)
9 z2 l) c: U  j: S# H" ~    2) booting and partitioning software from other OSs
- G- n1 a4 x& _       (e.g., DOS FDISK, OS/2 FDISK)
1 q1 U8 j6 `2 U    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)5 r$ G/ |3 Z  N; {; f4 X
    Command (m for help): p8 }* C% j4 t$ ~/ ?% m% O4 n+ K- K
    Disk /dev/hda: 4294 MB, 4294967296 bytes! N( E% v1 \- B0 H8 B
    16 heads, 63 sectors/track, 8322 cylinders! A) A9 P) |# q$ ?
    Units = cylinders of 1008 * 512 = 516096 bytes
1 L* g' v- e4 G- \6 G       Device Boot    Start       End    Blocks   Id  System
  ^. p, [  Q* p2 s  ~    Command (m for help): m. y$ G6 ^# t" j
    Command action
1 }; Z. v) W' O- r       a   toggle a bootable flag
2 r7 }; D4 h: E4 `2 c8 D       b   edit bsd disklabel& Q. X$ ]; j" c' d! l: Q9 `
       c   toggle the dos compatibility flag7 V1 o9 j: i; B8 C# H' @* f
       d   delete a partition
/ z5 v+ E  g0 ~       l   list known partition types
/ p5 f: C/ |  M# q5 R       m   print this menu3 ]/ x8 w- j. i/ X  _" Y( U3 O& l' a
       n   add a new partition
7 t7 Z8 a6 U5 ]; Y1 u       o   create a new empty DOS partition table- l' ^3 c- B2 |" C+ O: B
       p   print the partition table
% o7 P  O8 ^$ T- k$ L0 }       q   quit without saving changes: A8 y5 `# t6 M
       s   create a new empty Sun disklabel
, i. |- c& X: ?  F" {       t   change a partition's system id% A5 r8 m5 e% O/ [9 I; y# I( u! w
       u   change display/entry units2 |2 C6 c) |4 t$ J
       v   verify the partition table" c) p$ g; y  F: R; `  \% C- G& `
       w   write table to disk and exit; O* G% X6 N3 x" |8 I
       x   extra functionality (experts only)" |# R1 L/ G. {$ P' P
    Command (m for help): n+ G% g: d# W. l# k
    Command action5 }$ I/ S* M% N, G2 i
       e   extended2 h0 f- C" N" _5 V& l. H/ e
       p   primary partition (1-4)
1 [4 ?0 J4 t: u' O% T5 Z# G4 u    p) t% i- @$ D. w# I6 ~4 x( x' \& H
    Partition number (1-4): 1  @3 e0 T9 ?# r
    First cylinder (1-8322, default 1):
9 w. [  Y1 k% r- X5 J5 R    Using default value 15 W6 ?% A3 T1 @) Z, ]) ~
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
) l* {% D5 V8 {! p6 k+ \    Command (m for help): p
: {1 J( t& ?, r3 `    Disk /dev/hda: 4294 MB, 4294967296 bytes
) _! p( l, ]) [$ ]    16 heads, 63 sectors/track, 8322 cylinders
" O- ~# a* S( u" k% f+ T    Units = cylinders of 1008 * 512 = 516096 bytes
* f0 M; b$ v. \- }: K       Device Boot    Start       End    Blocks   Id  System
) z1 \# |# ^; q: ?! S    /dev/hda1             1      1000    503968+  83  Linux- E' a' l. t1 O& [
    Command (m for help): w4 C2 x3 }0 ?2 t, U8 x7 q$ N5 t
    The partition table has been altered!3 K% {: q& I% s6 B3 V" ^9 M7 @6 i6 u
    Calling ioctl() to re-read partition table.
* @9 C8 J+ Z* Q, G0 m    Syncing disks.
& \6 B1 x5 r1 b( G" j% o9 `    //格式化新分区
/ _8 G8 h2 N) J' `5 d  i& A* d
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002). ]( s" {* F- y% Q
    Filesystem label=2 `8 D$ D! v* S% i* [8 M3 h
    OS type: Linux
" P) H) E; X* K, m1 }1 L  _    Block size=1024 (log=0)8 P0 E- l' }8 X% ?9 B5 _5 ^) ?
    Fragment size=1024 (log=0), C+ v+ B; R* t7 H" a# z
    126480 inodes, 503968 blocks
1 U( x3 A, y5 V& I& c) B; L8 K    25198 blocks (5.00%) reserved for the super user; J# p) w, C9 s) J/ i4 p5 r
    First data block=1( A  o# ?6 {% c% v) V) j7 g, G
    62 block groups/ _' b/ ?" V4 B/ k- A$ i, T( y
    8192 blocks per group, 8192 fragments per group
% M1 O; S9 {, i. I1 u9 }" A    2040 inodes per group
) K9 T9 v" `* d4 \+ L    Superblock backups stored on blocks:
! m5 m1 }( @9 q            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014097 Y- l; y3 C+ D1 z' `
    Writing inode tables: done                            + L! l! ^4 P! T' |' K3 h
    Creating journal (8192 blocks): done$ z* b/ a9 T' s5 v- `
    Writing superblocks and filesystem accounting information: done
1 M9 [6 L3 @0 O4 i$ j; D$ K1 j- e" H    This filesystem will be automatically checked every 30 mounts or! I: J: c! ]. P
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
) C6 Y: T: B9 H3 W- y$ K
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 v) y. C" w* F5 N& Z8 G8 n    /dev/sda3              3723848    705992   2828692  20% /  f) W9 R. Z# L
    /dev/sda1               101089      9274     86596  10% /boot
+ G" r; n/ A  U) f) N7 V1 O    none                     14520         0     14520   0% /dev/shm
* s7 P- r1 Q2 Q% t    //挂上新分区% V# L. p/ Z, n9 q! N: x
  1. mount /dev/hda1 /home) [3 M& r! y- z' @, P' V
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 Y: {. ^% R6 G& J# V
    /dev/sda3              3723848    705992   2828692  20% /
0 |8 l- a! C# _" Y    /dev/sda1               101089      9274     86596  10% /boot! h& P! M" O' A9 L2 d
    none                     14520         0     14520   0% /dev/shm1 w4 |* Z2 I6 v$ k
    /dev/hda1               488006      8239    454569   2% /home- H3 j4 U& O, c/ D( U

; l0 {+ }) N: S. c+ H6 [4 m  b自动挂载:8 t" ]& E" R7 m$ L; F
  1.           vi /etc/fstab& W3 Z& P2 v; U' T$ \
  2. ' q( e- N$ I! }. x
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0: r! ?  V" B! z! q( x# p

  4. 1 n+ t0 x9 ]8 X% @; y% @
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
: U: a4 Z8 M5 {
  1.           mount /dev/sdb5 /mnt/ljp1
    ( d$ ~' X# ^) q) ^; \/ j
  2. , M0 M& |6 v7 Z
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

% }$ \% `3 I7 s, r$ _; Q( k
$ g4 E/ g9 W0 x, r. Z# `" u( V3 V# y# `! C- Q4 n  B
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-22 05:27 , Processed in 0.030096 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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