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

 找回密码
 立即注册
查看: 2605|回复: 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)/ u. s& ~" e. A7 Z8 I$ _, Q5 I
      or: fdisk /dev/sdc  (for the third SCSI disk)
" V  h2 \) I7 `3 ]2 h( h      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)2 ]' F! I; A7 [' A
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
  |; h: m" F; a2 n      ...
: I* C& Q  Q7 Y
  1. df -k8 V8 y  B& N/ R. N- U1 L
  2. df -lh
    ' d4 {) o7 C5 W
  3. 查看有几块硬盘:fdisk -l
    ( _& O9 J$ |, L4 T7 X
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% p' F$ {3 v7 o$ e4 ~. s" X
    /dev/sda3              3723848    705968   2828716  20% /
, Q& s1 |  w: @; n0 y    /dev/sda1               101089      9274     86596  10% /boot6 q/ V1 N- J: L2 @- y
    none                     14520         0     14520   0% /dev/shm
  E2 X+ ~/ H9 R    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用  G# u4 j- ~: L( h
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
& G! R) V5 A/ Q: `% o; Z; Y    Building a new DOS disklabel. Changes will remain in memory only,/ `8 D. Q* z6 b, c' s1 q
    until you decide to write them. After that, of course, the previous( ], J: d. Z, H7 @/ c( P. I
    content won't be recoverable.6 C4 e1 v; g) c8 q
    The number of cylinders for this disk is set to 8322.
6 U% i  z: a2 |2 H    There is nothing wrong with that, but this is larger than 1024,6 U, h8 T' ?+ R5 u7 k' t7 N# M
    and could in certain setups cause problems with:, }5 [; T# N8 A: J  c" [  O9 k6 P
    1) software that runs at boot time (e.g., old versions of LILO)) B( ?- I1 {8 l. w% l
    2) booting and partitioning software from other OSs( ^- l3 i. M1 V2 q% n' d
       (e.g., DOS FDISK, OS/2 FDISK)
; r$ B& z7 q+ t) [5 K; S    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)" o4 Y! g- k% ~  n8 V  F
    Command (m for help): p
6 a. d, I3 U  _& P( S    Disk /dev/hda: 4294 MB, 4294967296 bytes
% A& H& ]8 [. i  Q    16 heads, 63 sectors/track, 8322 cylinders
! ~* {) V3 T) x# T( a3 G. A    Units = cylinders of 1008 * 512 = 516096 bytes
, u- ^- o, I/ k6 I# U       Device Boot    Start       End    Blocks   Id  System% v7 C4 g6 q" h- d. E, o
    Command (m for help): m. i* x1 [- f# q
    Command action
3 V8 d) R6 D/ W. q. S5 v4 `0 v       a   toggle a bootable flag, v( q4 [- t2 |
       b   edit bsd disklabel
+ B" G3 a# A  r       c   toggle the dos compatibility flag* c4 y/ q6 D/ h3 Q  z4 t& k+ x# y
       d   delete a partition
# U, S0 [  S5 y/ G       l   list known partition types1 S7 w6 U) Q% h/ i) T) v
       m   print this menu
+ }; d4 y, ~. V8 l       n   add a new partition. l& g( V  d$ u1 ~7 F
       o   create a new empty DOS partition table3 z' h0 J- `4 s3 c' t
       p   print the partition table! X  m) @% z8 q% h8 Z4 Y: M9 c7 ~; l
       q   quit without saving changes$ e4 V  ^3 t! H. B3 t- W. z
       s   create a new empty Sun disklabel
: o' y6 |/ @7 n1 b4 v       t   change a partition's system id
- F1 U9 w8 V) r9 S' V  C! H       u   change display/entry units
3 r$ `; j$ L3 i" S# z8 L7 z0 r       v   verify the partition table
" x" R' j3 ^, y       w   write table to disk and exit( K0 ]9 \. H  H6 s2 @$ s% N6 D
       x   extra functionality (experts only)% T+ |9 m; H* ^* q2 U+ B& }
    Command (m for help): n0 n6 a5 \6 |3 p, u& }! F7 H$ `
    Command action/ }, T& k$ m2 k& y5 L. A1 D2 i
       e   extended7 S3 k( {  m* i- x1 P
       p   primary partition (1-4)
$ P( v6 h; [( E! E  ?' K6 t1 n    p# y  v- S' n! z  P7 d9 I
    Partition number (1-4): 1
3 F1 q5 j8 t# M( S, ]    First cylinder (1-8322, default 1):
" I% M7 [4 z9 ]9 J+ x  E4 v' `+ B    Using default value 1
- P7 _+ S/ J( r$ p' B  z4 u- B1 }    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G, T# T- A; w' {# j# ]1 B+ n. u/ W
    Command (m for help): p) x" [- Q3 q& \- }0 }
    Disk /dev/hda: 4294 MB, 4294967296 bytes
# y: c2 n  P  j/ ^; U    16 heads, 63 sectors/track, 8322 cylinders0 u; S1 i8 y3 k) A: O7 U6 p3 i7 N: O
    Units = cylinders of 1008 * 512 = 516096 bytes
0 o( N6 n2 H7 |  f; Y1 H- t6 h3 J8 I       Device Boot    Start       End    Blocks   Id  System! A) R3 e1 C3 k6 C- o7 k6 j4 Q% o7 f4 s/ R
    /dev/hda1             1      1000    503968+  83  Linux" A/ [3 T3 R1 z) ?8 z
    Command (m for help): w
! a5 N6 m( ]; o& z7 \$ B. s    The partition table has been altered!
: U2 ?; B; J" q/ ~- i* l- V    Calling ioctl() to re-read partition table.
/ A: O& w3 U2 ^3 G+ k# H+ L    Syncing disks.
/ D8 E: r! A! K' ^$ R5 s    //格式化新分区0 U/ ]& p/ j. @' S) s% ?
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
) j7 H2 S. Q: s/ i    Filesystem label=& X- w, x) z4 O
    OS type: Linux
; g: n! [. W% @6 p0 o1 g    Block size=1024 (log=0)2 ^* Q0 f" |: d0 j! `& R
    Fragment size=1024 (log=0)
* g7 R# \/ H( Q, Z+ m' k2 A    126480 inodes, 503968 blocks
- U6 C3 i" |) M0 n    25198 blocks (5.00%) reserved for the super user4 k. B+ p, @6 S% M( X
    First data block=1
. P8 W2 N9 b' u! Z! q+ v    62 block groups
0 k5 f" y) i1 O5 w* ~( t    8192 blocks per group, 8192 fragments per group3 W$ [6 y. _3 ]0 J: @1 ~  g5 a
    2040 inodes per group
) ^" j+ x: t6 ^9 x5 r    Superblock backups stored on blocks: / o: B4 B2 I- W" L! d3 v+ z& c. b7 i
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
4 F- v5 E0 \2 I6 p    Writing inode tables: done                              y6 g  F: Q. i
    Creating journal (8192 blocks): done
$ F) V, c0 \& P( O    Writing superblocks and filesystem accounting information: done0 y$ e0 ]1 o) S' G; Y) I
    This filesystem will be automatically checked every 30 mounts or
7 z7 C' q8 T1 o, ?+ {    180 days, whichever comes first.  Use tune2fs -c or -i to override.' G+ j# E# O4 x2 [
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ a4 v: m1 T: p: e7 ?$ Q+ P    /dev/sda3              3723848    705992   2828692  20% /
' y, p! V* [. Y    /dev/sda1               101089      9274     86596  10% /boot
8 I# a6 Z$ a) {  F3 \    none                     14520         0     14520   0% /dev/shm
+ \3 {0 n% W4 ^% j2 r; T    //挂上新分区1 V6 P- I' }2 A5 R) I% K4 N1 c
  1. mount /dev/hda1 /home
    6 b$ n* J2 K1 q7 }1 H4 f
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 e# W4 S; `! [3 Z, ?- ~    /dev/sda3              3723848    705992   2828692  20% /; W8 H% {5 \5 ?: j
    /dev/sda1               101089      9274     86596  10% /boot, g) V+ U" z7 x! p3 ?& C
    none                     14520         0     14520   0% /dev/shm
$ c" v' Q+ l7 e    /dev/hda1               488006      8239    454569   2% /home/ r) \' Q! m6 v# k  [" x

+ T$ S! S5 J( k, q. n+ ]5 o& T自动挂载:; S) |! x2 ?6 }$ K7 z
  1.           vi /etc/fstab
    % R+ q5 z' e. E, U6 r+ W

  2. - J9 n% w% R% W5 `
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 01 b& ?0 Z6 d8 z; M* _2 z7 o

  4. " `8 z! a5 x' n( A' a
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
1 \( g- n% T. m) A8 L1 E
  1.           mount /dev/sdb5 /mnt/ljp13 `, w( c$ P7 F  ?' v. S

  2. , d6 e7 z% u7 z0 o5 e0 w
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
9 A+ j2 W2 N! B) {; g2 n; A7 C. R

& L9 \! T, f! J0 D
8 \1 t; N5 P/ n0 Q+ t7 V! E$ o
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-27 19:35 , Processed in 0.032925 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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