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

 找回密码
 立即注册
查看: 2828|回复: 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+ {0 p6 e7 c( n- ]4 T' x
      or: fdisk /dev/sdc  (for the third SCSI disk)
5 V) L0 j! l8 A9 `- k      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
1 c" L' e; w" _. U% w' Z8 X      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices): ~3 [0 h- X7 b4 E
      ...$ i# {- `0 ^5 B( I- k
  1. df -k
    ' B4 V# _2 V" i
  2. df -lh
    0 q3 H* p2 h! X- a& D7 r
  3. 查看有几块硬盘:fdisk -l/ i6 z, R+ O  x! B" u# M( ^2 }+ k8 m# a
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ b; V0 v+ w- n! W0 M
    /dev/sda3              3723848    705968   2828716  20% /( O! }( l: U- E6 c1 z/ g4 F! C
    /dev/sda1               101089      9274     86596  10% /boot
/ l8 e' l3 z6 T" ^$ K) [    none                     14520         0     14520   0% /dev/shm# b' v7 z2 N( Y6 x) ~, t, g
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用5 K5 r) ~0 A1 |4 u7 k( y
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
' Z1 ]$ u; \. ?8 w+ U# f8 H    Building a new DOS disklabel. Changes will remain in memory only,' }& @$ _* |$ x! D5 {& p
    until you decide to write them. After that, of course, the previous
& n; |+ W( W  o9 E$ j3 F1 x/ Y    content won't be recoverable.
( t: Y4 o" S8 w9 [    The number of cylinders for this disk is set to 8322.! J: i- T& H" c1 r% u# i( {
    There is nothing wrong with that, but this is larger than 1024,
. B" C, K9 a" u3 d    and could in certain setups cause problems with:
8 a4 Y! g  o6 U; S' j- ?6 F6 T    1) software that runs at boot time (e.g., old versions of LILO)
+ Y$ ?  L3 f! Q4 I& S- E    2) booting and partitioning software from other OSs: D5 t+ ~) R* S& f& N
       (e.g., DOS FDISK, OS/2 FDISK)1 M& s# q& O* Q# p% r6 l
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)3 i3 b# |1 g0 P. H% ~) N' C& k8 E( {* H
    Command (m for help): p
+ k9 w) g( y8 @! g; E" _    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ p2 N" V8 A& l  r! `    16 heads, 63 sectors/track, 8322 cylinders
/ w5 O4 P  V  o, u8 C' j" {! A    Units = cylinders of 1008 * 512 = 516096 bytes' l: N0 x% v" o9 w4 a
       Device Boot    Start       End    Blocks   Id  System4 v! \. I: t7 y; A  l
    Command (m for help): m/ j; f9 ?" V$ M( [* _
    Command action" f( A- j3 y# d# P3 ?
       a   toggle a bootable flag7 x: Y& e4 ]$ Q- [; R
       b   edit bsd disklabel
. W; Y# }' D. L5 i! ~       c   toggle the dos compatibility flag
/ ~- T1 @7 K! u$ k5 r6 }3 U7 ^5 Q       d   delete a partition) i6 C: C7 K# @0 E$ x8 b
       l   list known partition types
9 [- r: }' b$ u. d. w       m   print this menu
) U' U9 }( p& ]9 `* `1 F       n   add a new partition  \% h8 R  F( c7 g4 ^
       o   create a new empty DOS partition table
' X- a) }# J9 z; B; n, M/ G" a       p   print the partition table) L3 Z# _) x& m6 Q: D" ]
       q   quit without saving changes- Y! d" [( n9 E* L
       s   create a new empty Sun disklabel+ E" r( c9 b! G" {8 x7 q
       t   change a partition's system id2 k! y: r1 ~0 P/ c
       u   change display/entry units5 q6 y& ]( S4 s+ q6 f
       v   verify the partition table' j+ t2 v6 z, R7 R
       w   write table to disk and exit
, Q" t2 K3 k, ^9 I0 Y( s       x   extra functionality (experts only)+ @; H. P% t7 N$ V# u/ q. Q
    Command (m for help): n
! F/ S/ r6 J2 v( o5 u0 `6 U    Command action
, X8 `8 v3 Y7 X% Y4 [. v+ A# ]; a       e   extended0 a  x" l6 z0 x4 m4 f" M
       p   primary partition (1-4)2 G5 x4 k, ?- w$ k& m$ m9 G: r
    p
+ M3 [1 t! ^$ Q( R: c. P1 w    Partition number (1-4): 1
% z5 r2 k6 E/ b/ w    First cylinder (1-8322, default 1):
: k+ B9 |  T. i5 y+ x    Using default value 1
: o" P. i" {, {: R6 e. x$ ~    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G# [# O- ?" ^3 r3 e& Z
    Command (m for help): p
: C2 L% K" g! r! J, U; V" h    Disk /dev/hda: 4294 MB, 4294967296 bytes) i2 a( V' b9 ]$ _
    16 heads, 63 sectors/track, 8322 cylinders6 k# v2 ~* V4 R3 Y: T9 H" D
    Units = cylinders of 1008 * 512 = 516096 bytes
; L1 u  w! X$ J/ }3 a$ w. n       Device Boot    Start       End    Blocks   Id  System
+ ~5 |% H& Y% [1 j    /dev/hda1             1      1000    503968+  83  Linux
9 X% w" q  ]% V' L$ v2 `    Command (m for help): w
" [( w, k$ Z" n8 s$ Y, _. Q    The partition table has been altered!
! ~& _! q. h% @- y# O/ }    Calling ioctl() to re-read partition table.
( g/ ~7 L) q( u/ O    Syncing disks.
8 p- u. a# Y3 t7 J    //格式化新分区" X& ?7 u, d7 d& S, q$ C4 x6 \
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)# f9 H0 t3 A& m4 [: B! N2 o5 T
    Filesystem label=
+ [$ O0 t" K$ z! g* `% l    OS type: Linux, {+ I1 v2 g0 s6 @6 P
    Block size=1024 (log=0)
, d$ K; o% \0 @0 A# f1 [    Fragment size=1024 (log=0)
/ q- o' ^) {; F2 T    126480 inodes, 503968 blocks9 Y8 i9 {7 ^1 e9 n2 i; c
    25198 blocks (5.00%) reserved for the super user
5 {' d" m5 [" c4 M! j: c    First data block=1
3 B& m0 R9 J5 B2 e    62 block groups2 @$ d, a: Y5 _, l/ V/ E% }+ ]
    8192 blocks per group, 8192 fragments per group
; p# X! }$ r5 _8 @+ |$ D) U    2040 inodes per group& X; C* C" k' j1 b
    Superblock backups stored on blocks:
$ E4 v: b# D* v  n+ h2 n- F3 s            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
* F* j2 r! F! Z7 ^    Writing inode tables: done                            . H) Y# O: m4 V  c( K- u) b
    Creating journal (8192 blocks): done
! Y% u$ p! b' r3 j  x; m7 ^) W7 [    Writing superblocks and filesystem accounting information: done1 `/ ?3 `+ H( e% m. S$ d* M
    This filesystem will be automatically checked every 30 mounts or( |$ l( T! ]% W# [  g1 t
    180 days, whichever comes first.  Use tune2fs -c or -i to override.$ A& M. p# q& a' q9 s
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ S1 Z0 x, s2 P+ a2 {
    /dev/sda3              3723848    705992   2828692  20% /& T  I& t# L' F' u# v; ?
    /dev/sda1               101089      9274     86596  10% /boot& ?  f# `1 G, K
    none                     14520         0     14520   0% /dev/shm
' x  o' Q2 d) r5 v    //挂上新分区3 |  b6 i. j& d% D$ ]1 A) G/ u: x( y( `
  1. mount /dev/hda1 /home, E3 R/ u, W, ^* p: N2 m% [' K
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
6 j  c% p4 |! p, e$ ?    /dev/sda3              3723848    705992   2828692  20% /
4 M+ x2 V' F6 a" }  G  V0 }; Z# Y+ x    /dev/sda1               101089      9274     86596  10% /boot7 y4 ^9 U# t! T, U4 ]
    none                     14520         0     14520   0% /dev/shm
+ x6 p3 |2 P3 U# I3 O6 A0 }  ]    /dev/hda1               488006      8239    454569   2% /home6 }7 O/ a* m) N9 R3 R4 V

+ t7 r3 N1 A; x$ f2 k' p% O* H7 a自动挂载:
7 l- t- o7 O% T: J0 p) Q
  1.           vi /etc/fstab- d& j. O) s* t8 p0 `
  2. 4 K3 Q, X; i9 a1 ^1 }0 J
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    5 V/ K* Q; q, `/ X! H) j$ }$ U
  4. % \5 B: f% Y' ]2 Z6 \, p. Z) F2 T
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
! s5 e' x8 p0 [7 A0 p+ |: S8 {
  1.           mount /dev/sdb5 /mnt/ljp1
    : Z! e# }( K( M. R* q$ }: Q8 ^& H
  2. 3 {. ^4 q0 e# G  z
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
# n! a/ Q1 j' [$ H) G
" [5 S9 m4 B" D) b# B0 {, x" Q
, P1 e. a. [) l1 Y: v
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-22 05:54 , Processed in 0.009958 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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