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

 找回密码
 立即注册
查看: 2677|回复: 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)
* Y. j9 N1 T4 \$ a: T: i' ^' z      or: fdisk /dev/sdc  (for the third SCSI disk)
6 Z: C% ~$ X' |* f" Y# P      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
. ?) A& w* W+ D. Z" O( o( Q      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)% q  i$ f( B1 X+ v
      ...# L' N& c5 }, f
  1. df -k* {) P$ v* y  p" }% r% |
  2. df -lh
      L; n1 U5 n& n# r4 C
  3. 查看有几块硬盘:fdisk -l
    # {; p5 k1 j3 Y- e2 e9 ~4 \
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: L( R% p1 N5 g$ }3 _& o$ B- ~9 i; m    /dev/sda3              3723848    705968   2828716  20% /
. W4 y1 E; V. B3 }    /dev/sda1               101089      9274     86596  10% /boot
+ r! d7 _1 f2 q* [6 z) L    none                     14520         0     14520   0% /dev/shm! [# M9 K2 m+ [, Y  B
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
! k* H1 ~8 L* Z( r5 H/ [
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
7 a7 x" C4 v6 f2 }; \+ w    Building a new DOS disklabel. Changes will remain in memory only,
' R4 s( g, ]8 R! _* a( n) ?  _    until you decide to write them. After that, of course, the previous
; Q! }. @# ]0 i4 v1 X' m" ]6 J    content won't be recoverable.$ k# U5 A( i! o+ W
    The number of cylinders for this disk is set to 8322.
. s1 H- U  ^2 @+ C1 |    There is nothing wrong with that, but this is larger than 1024,
' Z- [6 p+ O- Y# @    and could in certain setups cause problems with:4 Q1 m8 i" u0 D6 {
    1) software that runs at boot time (e.g., old versions of LILO): }# u) B* f. {4 b! {4 A2 ?( \
    2) booting and partitioning software from other OSs# V! W6 M' x6 C- l5 n2 _
       (e.g., DOS FDISK, OS/2 FDISK)2 M. j! S  b8 V1 c# @% N- |2 h# j
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)7 d9 p" o3 T/ w+ r1 P
    Command (m for help): p! X) G# ^0 {  f6 B( }/ A8 |
    Disk /dev/hda: 4294 MB, 4294967296 bytes: h7 y! u/ [3 s0 Q
    16 heads, 63 sectors/track, 8322 cylinders" \! u; P# S$ d6 L) E; h* ?! a5 d/ i  P" n
    Units = cylinders of 1008 * 512 = 516096 bytes
3 Y# i8 I; Q8 w0 i2 p       Device Boot    Start       End    Blocks   Id  System
1 @0 r8 h3 |4 C5 z    Command (m for help): m" D9 H  a7 W( K5 ]) I
    Command action. U" m6 V) b  `2 |  b" f
       a   toggle a bootable flag
4 Q& B6 ?3 S+ {; R. m, y       b   edit bsd disklabel) Q. A# [/ S" r' {$ N
       c   toggle the dos compatibility flag( P: _  ?0 }, t# P2 Y/ k, _* V
       d   delete a partition
, S! a- ?* c5 `; {0 s% P0 r, [+ C5 d9 U       l   list known partition types
4 H6 D! ~% a$ U) |       m   print this menu  M: k+ S1 L& Y* [& C, f
       n   add a new partition
% v. r5 f! V# x: c# Q' r) S) \1 w       o   create a new empty DOS partition table4 G( S* S, l0 h+ U7 d" i6 ?
       p   print the partition table* ]& g2 x( ?  I9 T. r
       q   quit without saving changes
7 I9 R" n. w4 c6 ?5 J1 t, Q       s   create a new empty Sun disklabel9 K, u& s, f. A$ ~; [6 w) ~( G3 v- U
       t   change a partition's system id
' W$ T. _' V# r! O       u   change display/entry units
4 n/ l3 ^2 S# b* Y9 a       v   verify the partition table
% D! E* _! S$ c1 h7 q/ p! [       w   write table to disk and exit
! a/ B, M; M  G       x   extra functionality (experts only)
$ o8 Z& }  M% _7 G- x    Command (m for help): n
1 r* \8 J3 f$ S4 C    Command action
! D9 V' s! v% u4 `       e   extended
5 t8 v' o1 L: T$ t% N, d       p   primary partition (1-4)0 m' ]7 _/ ~% g/ E) t
    p
2 X+ j6 d% A7 ]. W, M$ b    Partition number (1-4): 1
8 t2 ?- u, T# j; z    First cylinder (1-8322, default 1):
3 [3 z; u6 @$ C" \' `6 s    Using default value 1) w4 J) [/ Z% _. `0 \
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G$ P! {6 A: l1 N: \
    Command (m for help): p
# q9 ~+ L9 \9 Y    Disk /dev/hda: 4294 MB, 4294967296 bytes
8 ^( X7 e) w2 P! e, F6 |( U( Y4 _+ b    16 heads, 63 sectors/track, 8322 cylinders3 p* ^$ x4 ]& T- ?4 e
    Units = cylinders of 1008 * 512 = 516096 bytes- x% }* E+ ^+ v3 n
       Device Boot    Start       End    Blocks   Id  System0 m( n* u0 U" j7 C
    /dev/hda1             1      1000    503968+  83  Linux
1 e. O2 ?# i5 b& a( R  P1 k    Command (m for help): w* x5 N% H% z' e% y; [
    The partition table has been altered!! r; c: i3 e$ B6 f" H9 G- F$ a
    Calling ioctl() to re-read partition table.* b6 ]" m/ X; n$ I  ^8 x% e
    Syncing disks.: }* j: l: L0 q4 i; u- t/ m# u: `
    //格式化新分区
3 A# @% s! A# J& w& X
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)" D/ E7 T, c  E6 h
    Filesystem label=
% A3 z) ^, |  H7 H6 p! t    OS type: Linux
' t; m3 A, t  m2 d    Block size=1024 (log=0). x2 ]9 ?$ P! d0 O
    Fragment size=1024 (log=0)( n8 U3 M1 e* G% k" a9 I' Z
    126480 inodes, 503968 blocks
$ k3 t! m: G- ]- c2 m/ Z# _    25198 blocks (5.00%) reserved for the super user
" l8 z2 \" _' r' L: @    First data block=1- G% z0 q4 L9 M  w
    62 block groups
1 U( D( W; f4 R1 q8 Z" f: @    8192 blocks per group, 8192 fragments per group
9 z$ q- V+ ]5 k5 N! D    2040 inodes per group
$ F$ _/ i" J& H5 ^/ O! A    Superblock backups stored on blocks:
( Q' d! R) E& }! U/ v0 P! \            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409; X6 b9 W5 f5 m& e
    Writing inode tables: done                           
' S( u, j2 g  J5 H3 _1 U    Creating journal (8192 blocks): done* {5 N6 j; k, z9 x
    Writing superblocks and filesystem accounting information: done
8 T$ f8 ]5 `9 `# ?* a    This filesystem will be automatically checked every 30 mounts or0 N% f& V! D' E% @
    180 days, whichever comes first.  Use tune2fs -c or -i to override.( t$ E& i' l! q, l/ h1 C
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 ?0 g. }, B6 P4 [8 d' c$ u    /dev/sda3              3723848    705992   2828692  20% /
! D1 P3 I" d: r4 s    /dev/sda1               101089      9274     86596  10% /boot  }1 L" a( x) B' i2 Z& p$ c. L8 c
    none                     14520         0     14520   0% /dev/shm
' R( H# L" W8 R) N& B! i' \4 M6 R    //挂上新分区
5 l5 {; o: s. c* h: \/ B
  1. mount /dev/hda1 /home
    * u  B7 K) d  O4 c/ j& b$ h
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, \$ q5 I" T( Z, t+ u' O    /dev/sda3              3723848    705992   2828692  20% /3 N+ w, B( V! C3 {& A( v, t) Q
    /dev/sda1               101089      9274     86596  10% /boot8 B1 t) _8 ?' }! ^( S
    none                     14520         0     14520   0% /dev/shm; T( x' P3 m# u) q8 p3 q3 {9 q. P
    /dev/hda1               488006      8239    454569   2% /home' x1 \5 Z% m' j) _

) l- E/ T2 R3 H3 {. u* {" J, [自动挂载:) R* c) z& G; Y8 L' j
  1.           vi /etc/fstab  H' A3 @+ {6 {: C/ g! v
  2. 8 J$ y# a) G: F) J
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 09 @* r5 J8 n7 A0 o
  4. 1 W4 _( p8 G/ ^
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
8 A6 [/ Y  U4 m) B" G
  1.           mount /dev/sdb5 /mnt/ljp1
    1 K. j; I: m1 ]) P+ `+ X8 f4 P4 q! E
  2. 2 n: ?& Z8 j/ b* e, Z
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

0 F! u3 Q( Z/ j& ~1 a' G
( t1 B4 A9 U/ {$ }/ ]# N/ A% A" D  o; ?  N6 r/ O2 K
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-13 05:06 , Processed in 0.033774 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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