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

 找回密码
 立即注册
查看: 2831|回复: 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)
  Q" t* t2 u6 t2 p      or: fdisk /dev/sdc  (for the third SCSI disk)
0 h/ t; o1 w/ F* M! F* P9 U      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
8 q" u) y% G+ G5 y3 D8 R0 B      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
8 Q8 j2 G) R  c! F6 e/ |3 `      ...- K2 k0 ?1 S3 ^4 S/ d7 [  N
  1. df -k+ }  x* S0 P& R4 I3 E5 ^1 W
  2. df -lh( W3 q$ K, C; J
  3. 查看有几块硬盘:fdisk -l# Q( {8 j4 W; [( h9 j6 v' V
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
1 x1 u% ]0 t+ k# E/ B! T2 c1 @    /dev/sda3              3723848    705968   2828716  20% /
% N2 o# S) m3 V+ X* ?, A    /dev/sda1               101089      9274     86596  10% /boot
+ x* h" |  `' f4 y- [7 [# m/ @: n    none                     14520         0     14520   0% /dev/shm' L( t4 k' D% y, ^2 d8 c6 I
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
6 w$ s: P7 m3 S! t* b5 K
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
! W$ U% g3 o  _% s2 F    Building a new DOS disklabel. Changes will remain in memory only,6 O# b: h9 z, v1 i9 M5 X% u) p" P
    until you decide to write them. After that, of course, the previous( p" U5 k; l3 p1 j
    content won't be recoverable.
7 R; W( ^5 i+ B. T+ a& W    The number of cylinders for this disk is set to 8322.2 ^5 d# i* n2 L1 H
    There is nothing wrong with that, but this is larger than 1024,
: g. @5 m6 p) H    and could in certain setups cause problems with:( [- |+ Z( R( e9 f
    1) software that runs at boot time (e.g., old versions of LILO)
' V2 Z2 t5 K9 E* d+ t    2) booting and partitioning software from other OSs
: x) U$ C2 y. [+ V       (e.g., DOS FDISK, OS/2 FDISK)
' V7 p+ Q/ A* Z/ x# M# J    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)$ H" P1 ?9 E# ^8 `4 ]
    Command (m for help): p
5 U, N2 H0 @0 L4 C$ y2 e    Disk /dev/hda: 4294 MB, 4294967296 bytes, E6 t' B3 _4 d+ g& J# ?% }/ S
    16 heads, 63 sectors/track, 8322 cylinders
" g: ?" o0 o3 V2 S) H+ p    Units = cylinders of 1008 * 512 = 516096 bytes& c+ K% H) M$ h- F; H
       Device Boot    Start       End    Blocks   Id  System
) k& @! ?# D! I* s    Command (m for help): m" n: d0 q  K  T4 d: A" K+ \9 j
    Command action
% \+ j6 T; F. t1 h* }0 x       a   toggle a bootable flag
, m; t  u+ `" Q' R) U* w' y       b   edit bsd disklabel
5 ^8 y6 C9 U6 Q+ w- ~! k" N0 F8 c       c   toggle the dos compatibility flag
0 x, m) A4 n* u; M! J/ |" z6 l       d   delete a partition
! M2 n) A/ [& i       l   list known partition types! F" a0 M3 z. ?- C
       m   print this menu
& I2 M0 c& H' {" D3 S7 k       n   add a new partition
8 ]. f, }$ h+ N# c5 z/ c8 |3 y; `1 b       o   create a new empty DOS partition table; K4 v# t$ I6 I$ Q# q: N+ L, c
       p   print the partition table
0 B- j) P3 ~" R; f* Z, p" z       q   quit without saving changes% \5 W  C* J7 W. G/ c, c3 s
       s   create a new empty Sun disklabel
. y$ H9 }) @) L/ z$ F& M       t   change a partition's system id
. w# v+ b( h/ z6 u& j2 ?       u   change display/entry units1 ~) N2 ~* A+ w/ x: `/ o
       v   verify the partition table
7 l# e6 i* L& ]1 Y& B  P+ m6 D       w   write table to disk and exit9 o3 h# t& F) z$ u( [5 q& W; b
       x   extra functionality (experts only)
& @( G& B  Y1 y6 Z    Command (m for help): n
# X5 j4 ^5 T' v4 F2 r4 c0 H  U    Command action
5 \% I2 |( C0 \& m9 Z) @( P       e   extended
! H% X" [+ p3 H8 ?, U4 A" ^       p   primary partition (1-4)
; [  k- x0 P! |# l5 R) }    p' |0 E$ A: `0 ~& r) h" _
    Partition number (1-4): 1
( J$ c& J- q' u" `& o8 t8 A' C# j# d/ D    First cylinder (1-8322, default 1): 0 S" \& ?( ]  C* J6 p+ b
    Using default value 1
+ \, E$ x  y; g5 C, _) b3 e9 T, E* ~, V    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G/ X# d' P' n/ Z1 L: _1 v
    Command (m for help): p+ I# Q, z7 C$ W  b, r" N+ m$ o
    Disk /dev/hda: 4294 MB, 4294967296 bytes
  ?, E4 }7 P: K, \' V& G/ B* J    16 heads, 63 sectors/track, 8322 cylinders
+ T& c. d% J! _! x/ O' X    Units = cylinders of 1008 * 512 = 516096 bytes; x( @6 r2 W7 C0 Y6 \/ r* [' [
       Device Boot    Start       End    Blocks   Id  System6 m, r" C# z- i
    /dev/hda1             1      1000    503968+  83  Linux
( |; S  e. t' X" M    Command (m for help): w
- p% W( c# w" ?1 r1 }. g    The partition table has been altered!
; j! t. c, T% r* O1 L    Calling ioctl() to re-read partition table.# D6 g% m; h$ D4 j" K: D! b
    Syncing disks.+ I  k" _$ L7 ^+ c* b
    //格式化新分区
7 p% I8 P/ H6 c
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
5 [" k1 x; T* Y    Filesystem label=
$ q2 f! s* v* g7 q- Y    OS type: Linux5 D3 j0 ^0 p( S6 B0 B2 o) u& n8 t
    Block size=1024 (log=0)7 M# n3 R. c$ ^
    Fragment size=1024 (log=0)
% e; F6 `6 s, q. ]    126480 inodes, 503968 blocks
( h5 C+ s# N# w6 y0 P( N    25198 blocks (5.00%) reserved for the super user; j/ V. G) b) S9 n6 R
    First data block=16 {# b" Q9 E. |8 M9 E) n
    62 block groups3 J3 l  ~: D; L: o" Q$ B
    8192 blocks per group, 8192 fragments per group
6 }3 v* P( D& q    2040 inodes per group
  E% |& Y( q" J" Q- @. h    Superblock backups stored on blocks: . I# q$ c! o" Y! f
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
( c  e. B- k; K6 v- V# s    Writing inode tables: done                           
, O6 O* P8 i# H    Creating journal (8192 blocks): done3 O' ^1 s; S3 d3 j% ]: \
    Writing superblocks and filesystem accounting information: done% w1 r+ b! U& [" w) Y
    This filesystem will be automatically checked every 30 mounts or
( l  v2 x! j: i& j    180 days, whichever comes first.  Use tune2fs -c or -i to override.
9 t5 O0 v( e2 ?) l
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
- S  N8 j/ O  I& `    /dev/sda3              3723848    705992   2828692  20% /
( |1 m$ S) ]& X, E( s& j3 ]& M    /dev/sda1               101089      9274     86596  10% /boot7 g# Q( a1 ^- V
    none                     14520         0     14520   0% /dev/shm+ Y- ?! t; _/ W4 ?, a6 r
    //挂上新分区4 ~6 L0 J. ?' {) l# @( @
  1. mount /dev/hda1 /home
    ! |" |" y7 w& ~0 y
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' P9 t- y4 {$ ^
    /dev/sda3              3723848    705992   2828692  20% /* P4 n5 s0 r3 [( T
    /dev/sda1               101089      9274     86596  10% /boot& `# _: q% ^5 ?" g
    none                     14520         0     14520   0% /dev/shm* i% A" F4 z, ~8 t
    /dev/hda1               488006      8239    454569   2% /home
9 J- X& }: `' y/ \1 X# A" z6 \- T: t3 A2 c# E  X/ I
自动挂载:
% c0 K3 W& E' B2 M$ M
  1.           vi /etc/fstab5 ?. U2 g4 |- a/ t( R, {
  2. $ S; ?' Z* [# T9 x: x
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0: a+ P: s& r; g3 p+ b7 h1 j3 V

  4. - C* K0 y! I1 ]0 \7 h
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
* C0 m* V8 L7 ~' |& E; \8 e- ?6 l
  1.           mount /dev/sdb5 /mnt/ljp1
    * s# y) M- o7 J, O. L

  2. 6 N% P9 W! h* S, L
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

! p9 V6 b9 o0 a# V+ O6 I/ R( e6 d) O/ g3 w! r) N, Q' m( R) c

/ `. ^# n5 `: R6 o; C% o
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-22 18:56 , Processed in 0.010441 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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