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

 找回密码
 立即注册
查看: 2671|回复: 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)# ^; N$ N! L1 ]0 R
      or: fdisk /dev/sdc  (for the third SCSI disk)! l7 T' {6 v4 U
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)) b" z! s2 G5 i' s
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
+ \- d! V! B* y+ X8 J: J% Z      ...
1 I2 R% r: l7 H% q; E
  1. df -k
    ; m6 O* N0 o! e3 C& O$ O9 k
  2. df -lh
    2 J9 c4 @+ e, ^: Y
  3. 查看有几块硬盘:fdisk -l' F' s  G1 L2 a( u9 T, X9 _. ]
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
; b7 ~% l5 n2 ?9 r# ~    /dev/sda3              3723848    705968   2828716  20% /  A2 f4 a4 p/ d, C# z: n- b) [
    /dev/sda1               101089      9274     86596  10% /boot
2 h2 M6 t. E/ T  L    none                     14520         0     14520   0% /dev/shm
) i8 Z: U; ?! L3 Q9 n    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用9 x2 I6 ?1 K- X8 C# n9 {0 N' ^  x
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel- K/ q1 T1 ^( w6 A; t5 i* l, K6 h
    Building a new DOS disklabel. Changes will remain in memory only,! S' ~; Y" E/ l- O: y0 k0 B
    until you decide to write them. After that, of course, the previous
' e4 w5 g: ]1 y3 o    content won't be recoverable.& ?% n1 U: B& I3 P- R) Z0 _( b
    The number of cylinders for this disk is set to 8322." c! B+ g7 X0 E4 M) m( o2 s& B
    There is nothing wrong with that, but this is larger than 1024,. R/ j1 ^  Y8 ^$ e6 ~7 ]
    and could in certain setups cause problems with:
" x" g( X' E& h/ c: ?  d, D: l; J    1) software that runs at boot time (e.g., old versions of LILO)
3 B# q* ?5 A1 h, i. X5 P    2) booting and partitioning software from other OSs/ |4 ?' w0 Y& j, I- o) X$ B: P( v
       (e.g., DOS FDISK, OS/2 FDISK)0 ^0 z/ @- C8 j/ B/ ?' e
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
" e  e0 [( }% h6 e    Command (m for help): p
0 k% W$ W: S1 R$ Y: q    Disk /dev/hda: 4294 MB, 4294967296 bytes
) z5 N2 t, f$ c2 v4 J- e    16 heads, 63 sectors/track, 8322 cylinders
7 `; P/ i) g3 z2 s' p9 N2 w    Units = cylinders of 1008 * 512 = 516096 bytes1 ~4 s6 j% y, e/ f* I; W% c
       Device Boot    Start       End    Blocks   Id  System( `/ u1 ~% N1 L/ k/ S  s# C
    Command (m for help): m  A: @1 q! a& U+ @: l2 U& _
    Command action
6 Q6 Z0 D6 ]* }; f$ m9 `+ N2 b       a   toggle a bootable flag
- b" I& P4 D0 I3 I, v" q" g       b   edit bsd disklabel
% Z  b8 [' e, ?) f: I4 C       c   toggle the dos compatibility flag
7 }: h+ i2 p" f% x- h       d   delete a partition
$ Q+ v5 n# \5 j7 X/ O       l   list known partition types
" K. D$ @/ q( ^7 i- G& K8 [4 D5 o       m   print this menu
8 `  O4 s$ }& Z; c/ o/ d; T       n   add a new partition
' X' y0 L% _, j1 J7 a: F/ W9 \       o   create a new empty DOS partition table* m. i8 G/ A% _6 |- `0 F
       p   print the partition table
. J# e6 r- ^: o       q   quit without saving changes
0 G4 x9 W  J( n       s   create a new empty Sun disklabel
+ h" P1 M- I& Q       t   change a partition's system id$ V5 }* Q6 Q' f
       u   change display/entry units2 M! |9 X! v* @4 O: C
       v   verify the partition table/ h, \' j2 _- _1 h  c: W8 o% a
       w   write table to disk and exit
6 y% r$ Y  B  m8 D       x   extra functionality (experts only)% ]0 i0 U/ {8 f
    Command (m for help): n) B4 b1 C8 j) F$ m7 o5 Z
    Command action
; X) e" V: ^( v8 x* K% w+ i, Q/ g       e   extended& J$ c6 ~  U9 \2 ]- {
       p   primary partition (1-4)0 I1 l7 s: e: w# @' k9 N
    p# P3 M% F/ Y; h$ D+ w3 z
    Partition number (1-4): 1
+ J# K" ?9 |. e' F. q# ]2 @    First cylinder (1-8322, default 1): # ~* }+ d1 v' X: u+ r7 i6 @
    Using default value 1: B; c+ j5 B: w* ]" I& U8 l" k* k
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G3 A* N2 f3 p2 y4 R( L* }
    Command (m for help): p3 K& }% ~) t) v! F' O' S
    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ p# P( Y- K; z; V6 L7 D    16 heads, 63 sectors/track, 8322 cylinders
) r/ |; F. g* Q& t; m9 T    Units = cylinders of 1008 * 512 = 516096 bytes
  k1 ~: ^8 c) M6 l       Device Boot    Start       End    Blocks   Id  System" V, u9 f+ s. n1 A' g$ C  I  ]
    /dev/hda1             1      1000    503968+  83  Linux9 d3 Y4 C! d: ~) @, P- K
    Command (m for help): w
* p3 E+ c! x1 l; h$ `    The partition table has been altered!
4 O# e$ X8 y6 \% o    Calling ioctl() to re-read partition table.
! v' J1 O$ Q3 i    Syncing disks.* l$ @, e( S: X# F/ p' x0 D) _5 [+ i
    //格式化新分区
( E* k& S3 S3 D
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
: z( ]$ o/ L4 @  t/ o    Filesystem label=8 h& `) `" n: |& Y& i& [
    OS type: Linux
) L  H- [: C& D/ E4 z% M! L    Block size=1024 (log=0). P( ]2 t, @5 n0 [! t, x9 @0 ]
    Fragment size=1024 (log=0)- [' T" Y; K. t  e2 f: R4 I) [9 H9 K2 o
    126480 inodes, 503968 blocks
3 z2 g' y1 `3 k. c8 S9 J    25198 blocks (5.00%) reserved for the super user
; A% W* z  H; T- g: o' `    First data block=1
% @* Y4 i  i' R  N    62 block groups! G! H( W$ p& [* P% W; a! D  q
    8192 blocks per group, 8192 fragments per group
7 p5 G3 C. J9 g; E    2040 inodes per group
5 ]) C$ J; w# T2 C; t6 e- Q: B    Superblock backups stored on blocks:
5 D8 z% j5 f" w            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
8 s( C' t3 o+ i, U    Writing inode tables: done                              w% k$ y- ]: {) D( R
    Creating journal (8192 blocks): done
6 Y4 r3 L+ {9 Y; c: I; d    Writing superblocks and filesystem accounting information: done( v& @7 o: v; d7 ?- I, B) r
    This filesystem will be automatically checked every 30 mounts or
* G! Z# v) o' d/ v2 L    180 days, whichever comes first.  Use tune2fs -c or -i to override.
  t5 k  @' ~4 I1 U
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 r# x, q, X* U! J    /dev/sda3              3723848    705992   2828692  20% /: b) Q1 i: o+ E" f0 P
    /dev/sda1               101089      9274     86596  10% /boot
3 z" e' b  c% t+ ^3 q    none                     14520         0     14520   0% /dev/shm
9 {: l3 c+ C# s- `8 |7 C    //挂上新分区, B1 U) h; R: W
  1. mount /dev/hda1 /home0 ^/ U2 q3 N) O; w( m
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 B1 j* e. X0 [3 \+ V
    /dev/sda3              3723848    705992   2828692  20% /
3 u3 n1 T: R, m5 a    /dev/sda1               101089      9274     86596  10% /boot! e( A! |- Z) A2 n4 R& j
    none                     14520         0     14520   0% /dev/shm
4 I- g3 |- x/ B' |! n' S, K    /dev/hda1               488006      8239    454569   2% /home( ~0 R1 B) B5 S- {" h" k& `. N# D
9 F5 C* K+ T7 Q! _& Y/ u
自动挂载:8 T4 r& c9 j* t% U: e$ R
  1.           vi /etc/fstab; I- t" S! W. {9 [  d6 J* N- Y7 }

  2. % `- w# ]" l- i6 Y/ F4 T: S
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    / t5 s* r4 J  {) g% _3 h

  4. 1 R$ {9 F9 T; A' N# f3 u' `
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 s- B# g6 x4 K; W4 k
  1.           mount /dev/sdb5 /mnt/ljp11 X* l  E+ y+ O- }
  2. ( R: ]/ T! I" J$ N0 u  H& G
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
# p5 R* _* r" R! ]3 p0 |
. w8 ^3 }0 L; v2 E

' X3 A5 a" E( A& L3 r( w; y/ o
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-11 21:40 , Processed in 0.027681 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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