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

 找回密码
 立即注册
查看: 2742|回复: 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)3 t; d- l: w8 ^  j, m$ F( p
      or: fdisk /dev/sdc  (for the third SCSI disk)  ^% k5 R& a6 B8 o0 [3 U
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
( w4 E1 z' A" z: [+ z2 f7 T      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices), Z3 J+ l; R: k
      ...8 f+ `2 }2 A* d& b& ]9 l: W
  1. df -k
    / K& ^+ O$ f2 f( [
  2. df -lh
    ! j" j% s3 z$ }
  3. 查看有几块硬盘:fdisk -l4 T2 g0 u7 H+ c  @
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点4 s9 \7 o. }1 H
    /dev/sda3              3723848    705968   2828716  20% /
2 @8 q0 W. q# |/ D& a4 l% w    /dev/sda1               101089      9274     86596  10% /boot
7 w9 H. q5 F& J* h$ Y4 a    none                     14520         0     14520   0% /dev/shm7 O( x  n- T% Y5 |9 S' F& J
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
. p6 w/ |1 l; m$ v$ e
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel) _) G) P2 _( M) o! x5 D
    Building a new DOS disklabel. Changes will remain in memory only,
+ J4 ^% x$ J/ J3 {. B    until you decide to write them. After that, of course, the previous: P7 F  U3 w$ n5 p4 F) x" x6 _
    content won't be recoverable.
- @/ M( G% n1 t6 R    The number of cylinders for this disk is set to 8322.
, V1 P! R6 [8 L) |. a4 e6 V  B    There is nothing wrong with that, but this is larger than 1024,
4 B3 V+ o0 z2 A0 L( ]    and could in certain setups cause problems with:8 E! R7 k- p5 k4 |8 U8 ~
    1) software that runs at boot time (e.g., old versions of LILO)
( y: e) g' f; G8 ~0 F    2) booting and partitioning software from other OSs; ^: q  x% y) ^7 U/ k* \
       (e.g., DOS FDISK, OS/2 FDISK)
/ J( v# A* S& D" z1 q    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
+ e6 Z8 h0 H% y    Command (m for help): p/ T$ U( m, N4 p$ b/ P
    Disk /dev/hda: 4294 MB, 4294967296 bytes/ {; A6 p" \  }0 \9 E. z! ?! s# p. i- X
    16 heads, 63 sectors/track, 8322 cylinders% u5 n6 i- h! F  B" \3 ]
    Units = cylinders of 1008 * 512 = 516096 bytes
6 }- c, y# e; t( U' v( t: z4 [$ h# V       Device Boot    Start       End    Blocks   Id  System
* a- w* x+ R4 `( U    Command (m for help): m
+ f1 O2 _! ~2 I8 K- Z" e7 i    Command action' c7 U  |8 \% @; h# Q
       a   toggle a bootable flag
* L, _) u0 B# l% h       b   edit bsd disklabel2 v  A1 @4 u6 e/ y. q& ?
       c   toggle the dos compatibility flag' X6 V, \$ e4 Z* x
       d   delete a partition% Y0 o! @! K* ?' _, w* U
       l   list known partition types6 j8 ~4 f# S# \
       m   print this menu, o: {! h' }0 V+ w( E7 c
       n   add a new partition: y! W7 H' ~) c! ?, u- j4 T
       o   create a new empty DOS partition table
" w1 ~* i: _7 f       p   print the partition table* f* F5 S: R- H0 n" P$ j  o
       q   quit without saving changes
0 K5 i1 s7 D& ~5 A4 T' k9 O       s   create a new empty Sun disklabel- B" a' Q4 w. s
       t   change a partition's system id
. ]" p8 |6 f5 M1 N. n       u   change display/entry units, ~  @0 x8 V7 r
       v   verify the partition table  c, U( w5 T$ Z1 e$ [; W! h; `
       w   write table to disk and exit
, D4 D0 z( J. d- Q6 m4 J       x   extra functionality (experts only)
' Y9 ], b7 c) X6 ]! R3 `2 P' D- b    Command (m for help): n
- E' `; \0 T) g6 u! m    Command action% I: k' E9 i2 l
       e   extended
7 u9 n' d3 H! c3 Y( @& P8 m       p   primary partition (1-4)( x9 U% \) @1 K7 B
    p
: ]* O+ w* o: b) W* O+ f    Partition number (1-4): 11 U! B* |$ R  G0 L- J8 B; M6 f+ D
    First cylinder (1-8322, default 1):
5 h( y! X/ O4 g$ ^' H* C    Using default value 1
9 f# u/ F9 l0 |    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
2 W- z8 {: k+ \. d    Command (m for help): p# ~& r. m' V; _, v( ]
    Disk /dev/hda: 4294 MB, 4294967296 bytes9 {4 s8 _$ O7 S. U
    16 heads, 63 sectors/track, 8322 cylinders
9 H0 g, b) M/ R, `6 d- |: {) E    Units = cylinders of 1008 * 512 = 516096 bytes
& Y5 j& J: W$ |4 ]' p       Device Boot    Start       End    Blocks   Id  System6 P5 I$ W8 z0 e) J. e- v
    /dev/hda1             1      1000    503968+  83  Linux* F9 g8 x7 O; [( _9 B
    Command (m for help): w
! i# n4 }" ~) b# L/ m# B4 h    The partition table has been altered!, V9 t3 U& B6 k9 ^1 e
    Calling ioctl() to re-read partition table.. M& k" }; W0 u3 M# Z% z) O
    Syncing disks.
# X& q- O/ C; y& K9 g6 P+ J1 `    //格式化新分区
" K4 u$ F. L( A
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
9 V2 V9 x# d7 w/ q6 ]: |    Filesystem label=) A1 i1 h7 G- k! t
    OS type: Linux( ^) S7 Y9 ?: F, P' G
    Block size=1024 (log=0)
0 d: b, y2 B3 ~$ [0 R    Fragment size=1024 (log=0)
" O" Y! e2 G4 x    126480 inodes, 503968 blocks
6 G. }/ D, ~# A; H, H% c1 u    25198 blocks (5.00%) reserved for the super user; D% r- b3 T; d* D" \& X
    First data block=1; O( w! M5 D; f
    62 block groups
! G& O: r( l2 K$ A" ]    8192 blocks per group, 8192 fragments per group. m5 R) \9 c8 Q/ `7 v
    2040 inodes per group
6 G+ y0 u7 d  r2 s5 E4 X    Superblock backups stored on blocks:
" t% z# N7 g4 K9 {7 L2 A            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
( K; W9 W9 h% N    Writing inode tables: done                           
, o' C! p' }9 j    Creating journal (8192 blocks): done( {. j' v4 L* R( h# ~
    Writing superblocks and filesystem accounting information: done; O: |2 a: P: E
    This filesystem will be automatically checked every 30 mounts or$ k, ~, e/ Z4 n" a
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
% `! {: W  j; g7 q, q6 }) P) Q3 V
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: C' ?! x3 s9 l1 M    /dev/sda3              3723848    705992   2828692  20% /, M* w& x. L' t
    /dev/sda1               101089      9274     86596  10% /boot( _, D: p: ?5 _5 f# A8 e
    none                     14520         0     14520   0% /dev/shm
& C1 i4 g" Q# g5 m& s; o    //挂上新分区
5 P8 z: E9 K- N
  1. mount /dev/hda1 /home
    0 H6 z& B* b* Q; f5 d1 L
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# s5 x# N- k0 N& N, X    /dev/sda3              3723848    705992   2828692  20% /
5 |+ }: \' F" @6 ^1 s% |; u    /dev/sda1               101089      9274     86596  10% /boot. L( C( H( `" {+ \2 W
    none                     14520         0     14520   0% /dev/shm- {' O* ]" I# D5 e4 g% t
    /dev/hda1               488006      8239    454569   2% /home, X; k; O; w, |# D- E

9 M7 e' n1 Z+ J  S自动挂载:4 o. h, B7 s7 h: q$ x" Q; J
  1.           vi /etc/fstab- b7 p! W: g( x9 H% a! d6 P4 a

  2. " m/ o: C% x, l# u6 K% K
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0# ?* l& Q, ~! a5 H

  4. 1 G3 ^2 a$ T* t$ Y. ?* w  U
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
" }$ J4 `' N4 |! _* T" f: D
  1.           mount /dev/sdb5 /mnt/ljp1
    0 ^9 ~' }) N+ x5 V) @8 C
  2. * x8 ~+ r+ u1 ]2 s& q
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
/ b, ?! G4 w# h+ r+ ~6 q
3 W" R1 }6 o8 D: b" x5 A0 f
* d# H: O1 s. t
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-7 04:30 , Processed in 0.018527 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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