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

 找回密码
 立即注册
查看: 2633|回复: 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)
. j' q6 {' S' H7 |/ i9 L      or: fdisk /dev/sdc  (for the third SCSI disk)1 f% S2 n; f: f* Q
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
! H- p+ d) l1 b      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
" S9 x% f$ |$ e1 L7 V+ s2 n0 Z      ...5 Q) U$ O( z3 u8 m
  1. df -k
    5 a, b- T# f2 ]9 g, t
  2. df -lh% b3 U- z4 o( G; I4 x/ `' y
  3. 查看有几块硬盘:fdisk -l( ^: H+ S& `1 P1 G1 y
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; @  b, D% A# p2 }
    /dev/sda3              3723848    705968   2828716  20% /' z% M% {9 C2 v7 P8 V2 O: p
    /dev/sda1               101089      9274     86596  10% /boot' T6 C" Q! J3 K# Z7 o
    none                     14520         0     14520   0% /dev/shm
/ v# f/ X3 y# g: `    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用/ q' j7 C0 o" U$ J7 G7 Y
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel+ a& V& ?. K6 H6 ?; W- n
    Building a new DOS disklabel. Changes will remain in memory only,
+ R& B  i% t4 S2 p9 ^9 k0 d' j    until you decide to write them. After that, of course, the previous
, i  ?8 N7 _8 ?$ ?0 r) P    content won't be recoverable.9 J% Y1 T9 B6 `" _% L. l
    The number of cylinders for this disk is set to 8322., t- b* S; V! u
    There is nothing wrong with that, but this is larger than 1024,7 M9 ~6 C8 y, A- r( ]4 s
    and could in certain setups cause problems with:& K" V# {6 R9 I! A8 `" p
    1) software that runs at boot time (e.g., old versions of LILO)
$ ?; A! S) ~8 h    2) booting and partitioning software from other OSs% ]2 F: I2 K& T% _3 j: o# X
       (e.g., DOS FDISK, OS/2 FDISK)
7 q0 j; M, M( G3 f" }    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
$ M9 _& f" K  m- k5 C: P6 ]    Command (m for help): p
6 v" h7 P* Y% j7 w  }    Disk /dev/hda: 4294 MB, 4294967296 bytes! ?- l/ z" _9 O7 J5 |: w1 D4 Z# k
    16 heads, 63 sectors/track, 8322 cylinders
  Q8 }' `+ s  b- J! f/ c    Units = cylinders of 1008 * 512 = 516096 bytes# l# P6 S0 k, a: c# F
       Device Boot    Start       End    Blocks   Id  System/ i3 e: f% G, v9 [
    Command (m for help): m
& B& Y4 D3 R' K. t7 u6 y    Command action! z5 E0 {7 \5 S" Z3 i" s, y( O
       a   toggle a bootable flag# M7 b/ v( O9 N) ]! _4 |" `
       b   edit bsd disklabel, ~2 \7 b( X" ~5 u. p9 J6 v1 p
       c   toggle the dos compatibility flag$ N% \, A" R3 c
       d   delete a partition' M% f! G1 g7 A5 {
       l   list known partition types* u$ q- O. x* S* e  O
       m   print this menu4 {# I. a0 }8 F2 H% U
       n   add a new partition; X+ {9 D: m. r1 i% _# b
       o   create a new empty DOS partition table+ i* E/ Y( x6 L# c) c
       p   print the partition table, L; m4 t; K7 l7 t$ h
       q   quit without saving changes
: W6 w3 ^( P" P: F/ w) S       s   create a new empty Sun disklabel# C% X+ B9 w0 i9 X4 c  w$ C
       t   change a partition's system id4 \( T3 k6 P& y' Z& T3 [% X
       u   change display/entry units
+ o  I, l% T' w) v( q       v   verify the partition table7 t6 g9 D' E' u: \
       w   write table to disk and exit& p0 ]2 c5 d  B, d/ V
       x   extra functionality (experts only)  E- q7 c! |1 @  o# X( z
    Command (m for help): n
) O6 _% V, m7 B% O. _* K    Command action
# a2 ~' \( D- E4 t. I  E       e   extended
: u! E/ u0 N  \& E       p   primary partition (1-4)0 p0 N) d4 a8 w% b, Y0 n
    p/ N7 u$ a: u8 T# T. }
    Partition number (1-4): 1
3 I7 B% E3 i4 a0 e) W    First cylinder (1-8322, default 1):
( t9 m# s" N" Z$ |3 U" F. h    Using default value 1
$ A) `; M" k+ j) Y5 \    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G8 a: P( M  T! E2 `" @$ x+ U
    Command (m for help): p0 v! s: ]( h" ^! n
    Disk /dev/hda: 4294 MB, 4294967296 bytes. ^8 W+ H4 [" @+ \' v
    16 heads, 63 sectors/track, 8322 cylinders6 ?4 W+ ^" C. i( F9 N3 U$ o
    Units = cylinders of 1008 * 512 = 516096 bytes
3 f  G9 |' d/ R' c# g! _       Device Boot    Start       End    Blocks   Id  System% j6 y+ I* j. R7 d2 W7 }0 [, U
    /dev/hda1             1      1000    503968+  83  Linux
' |3 R  H9 \+ j% N7 t    Command (m for help): w4 q9 d- C+ N: w$ k1 l& G
    The partition table has been altered!! A+ l  I# k! U) @* a% \- \
    Calling ioctl() to re-read partition table.
1 V2 g! e2 [% P- G6 J/ O. D) K1 d( e    Syncing disks.
8 f' J) D  T9 |+ m7 q3 p    //格式化新分区
4 B! `0 O9 a' F+ p" b
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002). J7 L5 _, X0 X$ o: _1 m7 |4 Q
    Filesystem label=8 f) w5 H3 Z! C2 }
    OS type: Linux
! f- Z0 _. l/ Q# U5 o    Block size=1024 (log=0)" U) F) j; g; j6 b( h: _& a. F
    Fragment size=1024 (log=0)
4 A* h! ^5 Z! s" M/ m1 E7 T- L3 C    126480 inodes, 503968 blocks; h5 X( z& S: l
    25198 blocks (5.00%) reserved for the super user- `! j1 r6 }& Z) ^! p! M. n
    First data block=1
. B  }; j7 T3 \5 w, n( [    62 block groups7 p- {/ u' |$ E2 H; `
    8192 blocks per group, 8192 fragments per group
2 Q0 }/ }* ]$ ^7 |    2040 inodes per group+ Z! \8 I; ^) n2 r
    Superblock backups stored on blocks: 2 a( V* e8 i# j8 B6 n  P
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
  B3 A5 W% T" ?9 Q$ e5 V* }( y5 H    Writing inode tables: done                           
) j& K  z# \$ }# U. c    Creating journal (8192 blocks): done
8 I0 e* i* S+ l4 h    Writing superblocks and filesystem accounting information: done
+ u$ O% }9 Z4 T7 Z0 m4 a0 j) B    This filesystem will be automatically checked every 30 mounts or
6 K2 _4 N# J# [4 e: m* E# w    180 days, whichever comes first.  Use tune2fs -c or -i to override.
0 C: t" F8 D# P7 N
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
' i4 K1 e  f) I. f+ {9 k    /dev/sda3              3723848    705992   2828692  20% /
8 _+ E6 G1 Y, H$ q8 }6 [( L    /dev/sda1               101089      9274     86596  10% /boot
" `9 o# h4 Y: c8 d    none                     14520         0     14520   0% /dev/shm
: _- r9 h) [5 a    //挂上新分区
- _" L1 t0 G! l8 M- O
  1. mount /dev/hda1 /home
    & ?$ t, a) i. B$ w, n
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
# l. K9 i3 j2 K1 l2 U3 c    /dev/sda3              3723848    705992   2828692  20% /
: T6 ]5 p$ c7 @# y) M1 ?0 b; s4 y2 Q    /dev/sda1               101089      9274     86596  10% /boot3 G& ~2 q8 r5 z( z8 r
    none                     14520         0     14520   0% /dev/shm
+ O* R9 _' t: n7 E& x2 d    /dev/hda1               488006      8239    454569   2% /home
6 f7 n) x6 U5 ?5 T  z3 g- K+ x5 x4 m& u
自动挂载:
" \8 {: ]5 i- M
  1.           vi /etc/fstab
    " g) K1 _. X. Y; [: p0 R# s

  2. - i8 V$ x5 B, O" S2 _3 g
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 04 O- N9 X0 a1 z
  4. % n& D$ b  U/ j# z1 Y9 j
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
6 E" Z0 u4 ]( T
  1.           mount /dev/sdb5 /mnt/ljp16 a" t- _. E. g; G/ i" s2 t5 Q

  2. " Y5 @+ c- G' B* i- d) H1 r
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

( g" s) K6 a0 F, O1 c% V0 t% ^
3 G* [3 X+ T# N5 h) r- @* z
; k& f/ Q6 A% N* g9 t6 n; n
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-3 21:41 , Processed in 0.015998 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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