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

 找回密码
 立即注册
查看: 2644|回复: 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)$ p0 P7 x5 D# v: k! L! A
      or: fdisk /dev/sdc  (for the third SCSI disk)
2 d8 c) K$ X. p3 {3 |- k      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)" k/ z' Y7 z* l
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)6 f# Y1 L. x" J% q- f( O( ?" y. u
      ...
+ W5 t. D% _1 q. M3 n4 J3 B( Q. u) j0 V
  1. df -k
    2 g0 g0 ^9 g  e9 G
  2. df -lh
    - M7 G; f$ y) R: R1 U% s
  3. 查看有几块硬盘:fdisk -l6 D! I# @6 k# K' h
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
. c  M& ~* A: |& f* d+ ^% w    /dev/sda3              3723848    705968   2828716  20% /1 _; U+ _3 |9 ?4 f# u# ^# ~
    /dev/sda1               101089      9274     86596  10% /boot6 a5 H. N) f; e6 C( x9 J# b2 |
    none                     14520         0     14520   0% /dev/shm  `) D2 F7 q8 e; }  a
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用$ Z3 ^, z! c# Z4 N' ~& g& D4 p1 l: H
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel, m$ k( B8 v% j8 t' \( S
    Building a new DOS disklabel. Changes will remain in memory only,
4 ^5 y8 W, H0 e$ e3 K0 B. ~    until you decide to write them. After that, of course, the previous
5 l/ E3 g. Q: p$ T1 S  S7 B    content won't be recoverable.8 x* z! B$ W/ n
    The number of cylinders for this disk is set to 8322.
, |9 D6 \7 C. p3 W3 M( |5 J0 m+ B    There is nothing wrong with that, but this is larger than 1024,$ l$ Z: O( R8 j
    and could in certain setups cause problems with:
* w+ r) H/ p/ M: b) u% t2 w    1) software that runs at boot time (e.g., old versions of LILO); P& c$ m: B: o1 Q5 A' @
    2) booting and partitioning software from other OSs
4 X2 ~! S; C- K' M, Y6 t3 i1 O$ n       (e.g., DOS FDISK, OS/2 FDISK)$ `! Z) T8 W4 @
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite), n% q1 y' I8 u4 F6 o- y! G  n
    Command (m for help): p2 g; D+ R; M8 M% x& c& P& @
    Disk /dev/hda: 4294 MB, 4294967296 bytes
* g6 K& Q8 K# V4 p7 C! k7 P$ K    16 heads, 63 sectors/track, 8322 cylinders8 U  k$ }+ {% ?% N' z
    Units = cylinders of 1008 * 512 = 516096 bytes
" D; K) p3 M# D8 X       Device Boot    Start       End    Blocks   Id  System
  Q) f: |. G$ e+ `8 ^    Command (m for help): m
9 u$ Y( l6 ~0 w  D; U7 g    Command action7 X. B, ]3 E' \. `' t% W: ?
       a   toggle a bootable flag7 W7 `( R4 I; \9 \6 ^6 J
       b   edit bsd disklabel
+ |2 W5 A- o; s+ h% }       c   toggle the dos compatibility flag; K; c1 f5 D: r, K$ n; u$ \. f0 e
       d   delete a partition. x* r. Z: }/ N2 u: i4 J+ @. }
       l   list known partition types
/ o- \' e% f, k) t; m       m   print this menu
6 L% O% N- U4 J+ y  J5 ]       n   add a new partition/ o9 {) v+ x, }! o
       o   create a new empty DOS partition table
- `4 M( w# Q8 Q; p: c6 n       p   print the partition table- ^* O# |+ O& X; |8 {8 |4 o
       q   quit without saving changes5 R# n) N+ M. a! q% r. j/ A
       s   create a new empty Sun disklabel
" k* ^) `5 I- z6 k       t   change a partition's system id
0 ?) P3 j8 Q7 t       u   change display/entry units7 A3 e0 i7 z$ {; x, ~
       v   verify the partition table; U3 \- c9 c: i6 Y: k
       w   write table to disk and exit! P/ }0 D) C, z  p8 R- M
       x   extra functionality (experts only)
$ J% y' g$ w3 ?- T' A) i    Command (m for help): n
' c+ s! d5 j/ a% t5 J    Command action
+ d) d& C0 m# W       e   extended3 e9 u: ], h/ }1 }% k; G
       p   primary partition (1-4)% `8 E8 A+ u' q+ I6 g0 R) ]
    p
# w) k8 \: ?0 ?' M' W1 V- J5 h    Partition number (1-4): 1- m; m- q% ?4 n8 v6 n- z
    First cylinder (1-8322, default 1): 9 q5 U2 u! f# J9 [6 m5 G
    Using default value 1+ U9 C8 A- y& f. t
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
! q1 r# a( `# f- k/ E3 q    Command (m for help): p% w2 c( j4 J9 V
    Disk /dev/hda: 4294 MB, 4294967296 bytes
! y. P. C& x( M& s2 e9 c! u; i    16 heads, 63 sectors/track, 8322 cylinders& g0 P& o* c: A7 V7 X+ l2 t. X; i
    Units = cylinders of 1008 * 512 = 516096 bytes
: }5 h4 P1 D# q4 K) \       Device Boot    Start       End    Blocks   Id  System, c7 G1 L9 N1 i/ n2 n
    /dev/hda1             1      1000    503968+  83  Linux5 w  |" C' R. m
    Command (m for help): w, Z! x; Q7 l0 K$ f* y
    The partition table has been altered!
8 k6 j2 h6 a* t- L$ u# B    Calling ioctl() to re-read partition table.
: G6 k: m5 f% O2 c. f4 {    Syncing disks.+ Z+ P6 W- ?7 j" U- O- t  Q. `
    //格式化新分区6 B$ x' l. q3 C
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)4 q9 g+ Y: O& o6 V0 }8 W2 b
    Filesystem label=
$ p% r3 Y3 L3 k- O. }0 s# W0 M    OS type: Linux0 }  m+ Z# ^' K
    Block size=1024 (log=0)7 W1 Q2 M6 D2 [+ F, `
    Fragment size=1024 (log=0)
8 e. @7 l+ I9 x- y) x4 C4 t+ u  n    126480 inodes, 503968 blocks; u/ P1 F" Q: ?& `1 w" s' b3 N
    25198 blocks (5.00%) reserved for the super user
7 B; j: \* k, Y7 }9 A0 L    First data block=1
/ {) T/ {9 H- Y+ R; v2 S    62 block groups
9 S. N2 J4 {: g    8192 blocks per group, 8192 fragments per group. N  f6 Y3 A" ?
    2040 inodes per group& g% s6 a3 n4 Y$ e7 P  U8 {! O
    Superblock backups stored on blocks:   o8 }$ e* e$ D7 }0 a4 |
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409+ Z! z6 \/ B2 t4 Q4 w
    Writing inode tables: done                            . a" b' Z, Z8 k7 m& b
    Creating journal (8192 blocks): done: ~' r3 T2 v3 ~* c& O
    Writing superblocks and filesystem accounting information: done2 P' C2 c5 ?0 z$ q
    This filesystem will be automatically checked every 30 mounts or
% r8 i' g( R( N2 w4 _    180 days, whichever comes first.  Use tune2fs -c or -i to override.9 B6 D7 S) M( [% R
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点& D0 K% O9 |6 n1 m8 D: ^
    /dev/sda3              3723848    705992   2828692  20% /8 z, p7 i; n5 _2 `# n9 [# @( \, ?
    /dev/sda1               101089      9274     86596  10% /boot
, ?! g8 H5 o, y3 l7 T8 l    none                     14520         0     14520   0% /dev/shm- G9 t1 }6 b& b7 W3 X
    //挂上新分区
. f* N5 T  E7 b3 i; Y( }0 }
  1. mount /dev/hda1 /home# s/ D9 {& k# \/ n1 R
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' k2 Y7 I+ U. }$ G    /dev/sda3              3723848    705992   2828692  20% /
" C- e/ V6 {3 _8 h    /dev/sda1               101089      9274     86596  10% /boot
% t% z1 x; O: X4 N+ `; d    none                     14520         0     14520   0% /dev/shm# G1 K9 \1 a$ ?+ ]: m8 f
    /dev/hda1               488006      8239    454569   2% /home
. J! n& {6 o; {. S/ ]6 r: _# Y" B4 p- c1 D
自动挂载:
% ~0 C- C8 O# @+ a7 ^
  1.           vi /etc/fstab& c! h9 [) W* {9 Z; A& q

  2. ' ^) `  o* T- k) G9 `
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ! \7 s0 M$ `- `0 Y/ V

  4. 3 C+ y  A- w6 V3 t
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:+ ?% @2 E" F4 `6 g/ X) g
  1.           mount /dev/sdb5 /mnt/ljp16 r1 W4 P: w5 B
  2. $ e% w/ k9 n2 w) q
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
2 g) ^! w" y) L; q4 N& W
2 S# p+ D) K7 `6 h

% M  x2 D# f( D0 D9 l0 g) I
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-6 04:15 , Processed in 0.014447 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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