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

 找回密码
 立即注册
查看: 2699|回复: 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)
& {& P' L, G& T; b+ _/ {0 c' F      or: fdisk /dev/sdc  (for the third SCSI disk)
' E0 N$ V+ Q9 D8 ~# f      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
1 X  [+ s2 W6 D+ z$ {- ^2 N      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)2 Q+ y2 a  n2 [& M$ @
      ...
$ w+ n+ O' e$ V3 b& l
  1. df -k4 U4 C: y# E! N8 h, J& B  b6 C
  2. df -lh
      J5 |7 n$ z, B- n0 M0 R9 S7 y" @9 k0 N
  3. 查看有几块硬盘:fdisk -l
    % ?" U9 u% @; ?) A* s2 g
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
$ Q3 `# m; ?' w    /dev/sda3              3723848    705968   2828716  20% /
0 V" C" D  f. |5 P5 B$ M    /dev/sda1               101089      9274     86596  10% /boot. N9 ?; Q: \- x9 K+ H8 N) n4 Q: M
    none                     14520         0     14520   0% /dev/shm
, A/ A- S  l2 Z, ?$ v    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
; F5 Y( q7 X# u8 N
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
. R2 e% M# }5 A0 E/ h, u    Building a new DOS disklabel. Changes will remain in memory only,
5 u0 L$ O4 G: V    until you decide to write them. After that, of course, the previous
5 A0 s" |9 ]9 H( [* y: u    content won't be recoverable.  }1 b+ s4 E# j( Y
    The number of cylinders for this disk is set to 8322.. V" b; W- M6 C
    There is nothing wrong with that, but this is larger than 1024,
; B; M% X( J8 l; k" |    and could in certain setups cause problems with:! r, ?, [! Z$ j* a
    1) software that runs at boot time (e.g., old versions of LILO)
( z- B0 M  k7 x8 ~; r; U8 h6 P    2) booting and partitioning software from other OSs7 Z/ `9 \1 k' F- T# H2 ^
       (e.g., DOS FDISK, OS/2 FDISK); \1 ?8 W; Z# W# |# J9 w  t
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
2 O* X+ Q- f% H! ?' e  {    Command (m for help): p* h$ Z' l, v3 V1 n! A6 k
    Disk /dev/hda: 4294 MB, 4294967296 bytes
+ k. U/ c4 ~5 L: [, j    16 heads, 63 sectors/track, 8322 cylinders/ l/ [5 P: G, j% L. O3 G  o
    Units = cylinders of 1008 * 512 = 516096 bytes; f( W! C; k! o  Q! D% `
       Device Boot    Start       End    Blocks   Id  System! t: ?- M3 j# n% {+ _5 O
    Command (m for help): m) _7 M! ]" K3 J+ T' n
    Command action% z4 E& c: b+ W5 t# `" V/ v
       a   toggle a bootable flag4 w" x2 P( D5 ?( ~
       b   edit bsd disklabel/ j$ D% q( ?6 {4 j# P& m
       c   toggle the dos compatibility flag, G- D" l4 c9 i) d7 j
       d   delete a partition, {* v* d& @/ a" _8 b! Z7 b0 |
       l   list known partition types
! t  V% M4 a% t       m   print this menu: B4 `! ]9 S; R5 B  x+ f
       n   add a new partition
# T& S9 y7 c- t3 \5 W; D" Q       o   create a new empty DOS partition table
. y7 e/ Z2 z3 z2 \0 Z       p   print the partition table+ A2 y7 r/ A4 R5 g7 M5 b% [% _
       q   quit without saving changes
0 X6 I/ c/ g7 ^* p8 G. o/ ~5 R       s   create a new empty Sun disklabel0 m& d7 ~) C  T& I% s, i
       t   change a partition's system id1 e( j0 Q2 h6 X2 R
       u   change display/entry units
1 _8 w, l/ R% t3 y       v   verify the partition table6 H( x" l' I$ m6 g8 X  U
       w   write table to disk and exit2 h) q3 m, {: m) o% A
       x   extra functionality (experts only)5 ]! F4 a- M( q- T1 t6 [
    Command (m for help): n
  S" f2 V1 W- j# f- ]4 q) Y  {    Command action
; R0 t1 U0 y. P% E  O       e   extended
* v/ @# C& }; o2 K* e3 w/ ]+ E       p   primary partition (1-4)
. U" s% w5 R0 l$ G8 Z: u/ Q' x1 h    p9 i( k/ ]' f0 m4 m1 |
    Partition number (1-4): 1
- n" u7 z6 X: o  m6 b* x# i    First cylinder (1-8322, default 1):
3 {0 @; l; m& g8 v5 N) |% Q2 K    Using default value 1
& ^4 s& [& N  D! b! @" {7 Q0 d# B    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
7 y0 F3 ~; B- H7 w  J    Command (m for help): p
2 P# u: B* f$ X    Disk /dev/hda: 4294 MB, 4294967296 bytes: J3 H) f$ o+ g6 k( N% {8 ]/ w
    16 heads, 63 sectors/track, 8322 cylinders
, x# t; W) D4 h3 }. u* a    Units = cylinders of 1008 * 512 = 516096 bytes
* ^! G6 E6 B5 S" Y- c       Device Boot    Start       End    Blocks   Id  System
' M: l- o1 b' s    /dev/hda1             1      1000    503968+  83  Linux
2 ]# A, I5 Y! o4 @" K3 ]+ t    Command (m for help): w: o% Q& u* v. r" l! N
    The partition table has been altered!
* Q) `9 T7 E# ?# Y8 {" y    Calling ioctl() to re-read partition table.
8 n+ A. {+ ]7 L! h3 i$ m2 X    Syncing disks.' N) B) N$ W9 w5 j: B: U& P3 @
    //格式化新分区
  z9 v$ a2 E( N
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
% }4 M5 g  `; Q+ L3 u5 i    Filesystem label=2 S6 \5 D- Y0 R" ?3 ?3 U0 {+ ~# b
    OS type: Linux! ^- K+ l- k* Q
    Block size=1024 (log=0)6 o+ w, |6 e' E% k% U3 m* N
    Fragment size=1024 (log=0)% ^* B2 L( e& F* V% @) }7 L
    126480 inodes, 503968 blocks
8 L2 ^( s( E2 l' I; a    25198 blocks (5.00%) reserved for the super user
/ I# ]" S# y$ A! Z  O# n    First data block=1! Y4 z2 F- u4 c. Q
    62 block groups
8 w1 B: b/ M) b5 d3 e% z    8192 blocks per group, 8192 fragments per group
) |9 x) j) T( |* R% Q2 M; F    2040 inodes per group) g1 P" n. c" @
    Superblock backups stored on blocks:
' E$ Y; S+ W% e  S. J) l4 B" d            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409* W3 C* f9 k$ H7 u1 @
    Writing inode tables: done                            ' T; x* c/ M2 N2 D2 i  H( r4 S
    Creating journal (8192 blocks): done
- p! z$ T1 K0 c( I2 I! P1 t; X# I, Q    Writing superblocks and filesystem accounting information: done: C2 O& t/ ^& M
    This filesystem will be automatically checked every 30 mounts or
6 \# r8 {  |, b! E0 n! k0 H: c    180 days, whichever comes first.  Use tune2fs -c or -i to override.: z/ H  D) a& q3 B! @+ K* H1 \# g
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% }/ C, {0 f, k, i# k    /dev/sda3              3723848    705992   2828692  20% /
5 O' `- ?( s7 O7 g- P) K8 J. |    /dev/sda1               101089      9274     86596  10% /boot
( P/ Z$ n: }# E) W    none                     14520         0     14520   0% /dev/shm9 [# S- n- V6 G: Z
    //挂上新分区7 ^5 Z1 B$ b5 a4 D: D
  1. mount /dev/hda1 /home
    ( V3 l1 K6 P! H5 g+ g
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
5 G: y2 `- s: E. u3 ~, d$ S' Y    /dev/sda3              3723848    705992   2828692  20% /
" g6 v( l; O2 e3 N    /dev/sda1               101089      9274     86596  10% /boot- |5 C$ T9 _: Q' K3 L
    none                     14520         0     14520   0% /dev/shm5 H4 Z2 c! Z4 x2 e6 Q! Y! E
    /dev/hda1               488006      8239    454569   2% /home
! E$ u6 e( _( O/ w5 y! a; L
3 B6 W* v0 u3 O+ m自动挂载:/ D5 }4 d! p0 j2 H1 x! R( N8 `
  1.           vi /etc/fstab7 J- n% ~1 o" z" Y* q9 p( `" R

  2. / N( ^" F( B0 M. H# Q
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 05 R$ x3 N9 \# ?  K" Z1 x. @
  4. ) R8 ^2 L) U- J+ q  S4 n9 ?
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
" L) r3 s7 L: K1 }; |! d
  1.           mount /dev/sdb5 /mnt/ljp1/ h& k% C6 M8 x3 u
  2. 8 W- @2 R' ]$ h1 p! Q4 n7 m1 t
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
* H- r7 i# J4 R2 y, n

: T) E% u( F1 ]( u
5 j& x" D; f; R% H2 ^+ ^( F
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-18 21:17 , Processed in 0.010336 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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