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

 找回密码
 立即注册
查看: 2587|回复: 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)% P3 N0 S0 N) r
      or: fdisk /dev/sdc  (for the third SCSI disk). I" P7 g' A; Z2 u
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)8 n. F7 `) @/ j8 q$ b$ F1 _
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
3 R4 t4 O, t4 B2 `! w* H5 F      ...
; m; ?- R8 @  {. e" D+ {2 L
  1. df -k
    . e) C4 _# G# S+ ]; T1 I
  2. df -lh
    ( [+ |- H* s! C& ], z$ x3 K
  3. 查看有几块硬盘:fdisk -l
    % I/ v& a; G; j$ R! v& t/ w
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点" x2 ~0 Z$ H6 \3 j8 n/ P5 {
    /dev/sda3              3723848    705968   2828716  20% /4 h( A% I2 x) R7 K* e; _9 K0 M! t
    /dev/sda1               101089      9274     86596  10% /boot5 H3 K% [, g) f: A9 n
    none                     14520         0     14520   0% /dev/shm
" E; M* g1 D2 U1 h. U# m    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用- ~8 N3 ~3 J: X& Y
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
, G7 ]- E* e" ^7 N' C9 S    Building a new DOS disklabel. Changes will remain in memory only,5 Z! S7 }$ s3 I0 W; J- ]
    until you decide to write them. After that, of course, the previous
$ I$ L  @  b: v" L% r    content won't be recoverable.
9 a  d0 ~3 B5 z% N( Z4 L! s    The number of cylinders for this disk is set to 8322.; Y# o' a- L- U0 L! n& y* C
    There is nothing wrong with that, but this is larger than 1024,+ B- N  M& u5 k6 ~: c6 [
    and could in certain setups cause problems with:: a& H, ]0 K0 l2 F" p$ A! r
    1) software that runs at boot time (e.g., old versions of LILO)+ w$ Z) H; l* {; w+ U, |
    2) booting and partitioning software from other OSs
3 U4 _5 E% b3 |5 H+ R9 f+ p       (e.g., DOS FDISK, OS/2 FDISK)
8 Y, p2 Q' K7 J; Z    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
) B" t/ L. w& B1 W0 L, f: @    Command (m for help): p) s2 {0 Y8 N* W4 U0 u
    Disk /dev/hda: 4294 MB, 4294967296 bytes
5 I% F- K, y: u+ `  v0 a# d3 D    16 heads, 63 sectors/track, 8322 cylinders
8 Y$ e1 v# V* Y/ R$ [/ z    Units = cylinders of 1008 * 512 = 516096 bytes
! [$ d" R# Q7 E/ l, K9 ]       Device Boot    Start       End    Blocks   Id  System. @- K/ z# P7 ?; K" E4 C, W
    Command (m for help): m
9 U0 x2 q. L3 O% l& }" j    Command action
* V  r( R8 h, f2 y       a   toggle a bootable flag( o" ^8 s8 r% N# I
       b   edit bsd disklabel
" n  l1 G% T; a       c   toggle the dos compatibility flag6 F2 {$ |5 A! d( V
       d   delete a partition$ L: Y( D9 |1 C/ D4 X
       l   list known partition types6 s' A5 a4 U8 q2 e- H% B
       m   print this menu6 m! R+ v) T6 o$ E
       n   add a new partition
+ [5 e$ G/ ]3 A5 q       o   create a new empty DOS partition table
+ h/ V  V3 }' J7 a. v$ J       p   print the partition table
: x% ]5 {5 S  Y" ?       q   quit without saving changes% H6 Z2 _# _' Z! ]
       s   create a new empty Sun disklabel$ g/ \. s8 e, s9 U
       t   change a partition's system id
' q% p# K% l& @( S       u   change display/entry units  [6 d, x, e+ h# z
       v   verify the partition table& N/ E4 y( Q5 w- H# O
       w   write table to disk and exit
3 m5 S' V! }4 H- x# q3 F7 H       x   extra functionality (experts only). O7 D/ R# @3 \, q
    Command (m for help): n6 M. d4 _9 J" D7 e' p2 v4 Q
    Command action% x/ @% Z4 i- r: Q5 l: S
       e   extended
/ [* W. N. k' k# l% {% y       p   primary partition (1-4)$ o6 n! n1 _! s+ u
    p
5 G! \/ x' u3 b    Partition number (1-4): 1
) s  \% W' a& \6 C+ G+ E    First cylinder (1-8322, default 1):
& f4 L$ }! W( o9 T3 S' S+ f2 R( A2 u    Using default value 1- d( t9 e2 w$ ]2 h  P2 x* A) m# W
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G% R/ g, Y% [3 Q1 M6 R& _  {
    Command (m for help): p5 e! U  J4 e. @9 C0 S# {8 w
    Disk /dev/hda: 4294 MB, 4294967296 bytes. Y3 U$ V9 u8 b
    16 heads, 63 sectors/track, 8322 cylinders" M+ `$ B+ w( @6 r
    Units = cylinders of 1008 * 512 = 516096 bytes
+ ]& A5 A! r. n, q" [       Device Boot    Start       End    Blocks   Id  System
" {5 J9 W. R# x3 j$ [2 A! S8 w; v    /dev/hda1             1      1000    503968+  83  Linux7 I8 T; v9 L5 p$ ~+ D. A
    Command (m for help): w- C1 _) |7 v+ w
    The partition table has been altered!9 p1 R2 v  N" V! W
    Calling ioctl() to re-read partition table.# f5 l# _+ i7 r7 L' ?) y
    Syncing disks., w4 U1 S3 y+ v3 @
    //格式化新分区+ A7 _7 z1 m4 y: }& b* ]$ k
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 U/ R8 F0 v! a; T2 |: ?/ G; {' |4 B    Filesystem label=2 ]4 ?( {4 Y: G/ x0 e
    OS type: Linux) |* o- D4 z4 J2 ^/ t2 q/ ~: t
    Block size=1024 (log=0)
7 g8 Q5 }5 s# E( `' ~. y7 n# [* e9 d/ R    Fragment size=1024 (log=0)
7 P0 U$ ]0 r0 w! Q7 b    126480 inodes, 503968 blocks
" C" z( K9 @% S3 Y    25198 blocks (5.00%) reserved for the super user( A$ F5 x3 {5 s; a, A7 i, g& J
    First data block=1
3 j3 N& B' R0 a3 V2 V    62 block groups5 z* A2 H* K9 }  b$ X, J0 n* L
    8192 blocks per group, 8192 fragments per group0 f0 w( x: X6 A( R
    2040 inodes per group: n$ J: ]& c: T: F& i; S
    Superblock backups stored on blocks: 3 ]- |7 t3 g3 t) d6 j. `3 g
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014095 m4 m* [- b' `# I4 }; h) t- n  `
    Writing inode tables: done                            9 G  f6 F2 p6 W
    Creating journal (8192 blocks): done
, ]* L5 v( O3 f" {    Writing superblocks and filesystem accounting information: done
1 H- T7 G! v: l7 ~! L! T6 d7 l    This filesystem will be automatically checked every 30 mounts or
' `- ?( C9 |0 M6 {: L" k    180 days, whichever comes first.  Use tune2fs -c or -i to override.
$ ^0 g) w8 J# Y" ]$ ~( H+ s5 ?2 x
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点9 ?9 k/ l# n" n5 @2 D
    /dev/sda3              3723848    705992   2828692  20% /
+ X, g+ x+ `% ^7 q* u    /dev/sda1               101089      9274     86596  10% /boot3 A8 H$ G8 o7 I7 z; e' r
    none                     14520         0     14520   0% /dev/shm
% f" Y7 `$ V* i4 D* h, K    //挂上新分区3 B# E4 T% D+ d+ g
  1. mount /dev/hda1 /home/ f: j. e4 G' J" h, z+ @1 A# v
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点# T: x, h+ x8 p# n
    /dev/sda3              3723848    705992   2828692  20% /
; \8 e4 U+ G! y- a+ r2 k2 \    /dev/sda1               101089      9274     86596  10% /boot5 {; Y6 m% R/ v- D
    none                     14520         0     14520   0% /dev/shm! U5 D( o4 H8 T8 J( c
    /dev/hda1               488006      8239    454569   2% /home
( O: M, v( O- }! L# d+ R5 P- n+ g
$ e8 [8 ]. y% Q" H" ?! l; x自动挂载:  d! a/ n. T5 L2 I% _
  1.           vi /etc/fstab
      c- Z5 v; ^: z! B- m  y
  2. 2 f6 N2 x& f) n: ]. G! a5 e
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0% u1 ?" Z( B/ \; _5 F' w! q
  4. 7 W4 p5 m3 C. M6 P
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
" t: q: e% M) x1 b
  1.           mount /dev/sdb5 /mnt/ljp1# ]- {2 n  ?% _5 M; }% [& j# ?  K' b
  2. . s: T+ _' g3 b# D' n
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

0 C# B* l' @/ l6 d7 R" ^9 J
6 a# ?5 \9 r# P& j! s0 {
0 a: C( r& ?8 s- p5 W5 u
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-24 09:21 , Processed in 0.020039 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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