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

 找回密码
 立即注册
查看: 2962|回复: 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)
6 Y. d$ d3 K2 H6 x+ g+ d4 @4 x      or: fdisk /dev/sdc  (for the third SCSI disk)
3 V5 d; I9 P& r6 h# @. L      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)5 k+ ?# Y4 F3 X, c& F( O# R
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
8 `; e, a& [2 t! x      ...
  ?- t$ m' M/ }$ _. p2 w
  1. df -k
    ' E, k6 `% {& X* Q3 V1 h
  2. df -lh
    / U( C& x: f2 m- W8 g9 [0 K; s
  3. 查看有几块硬盘:fdisk -l  p4 @) A7 V( ^) E+ F, y
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! L0 m) ^) ^% F* a& R    /dev/sda3              3723848    705968   2828716  20% /
; r0 M  G3 q6 F- i9 N( \4 X    /dev/sda1               101089      9274     86596  10% /boot* S: n1 |8 l! ~
    none                     14520         0     14520   0% /dev/shm: L; E* S* |8 q
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
. x  A: k  G2 w6 D2 V6 s2 H$ u  P
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel+ a5 b: |0 `# b3 H4 k& a1 D8 b4 l
    Building a new DOS disklabel. Changes will remain in memory only,& [8 d3 v) L2 ^$ e9 B
    until you decide to write them. After that, of course, the previous% y9 Y6 Z. I3 e1 X* U
    content won't be recoverable.$ m! O0 O; @4 E, N/ J# R
    The number of cylinders for this disk is set to 8322.0 ^, K( \. }$ `3 W
    There is nothing wrong with that, but this is larger than 1024,
" S7 V1 R/ ~/ ?: N    and could in certain setups cause problems with:: x$ @0 N& t* Q1 y- m2 D/ M
    1) software that runs at boot time (e.g., old versions of LILO). e4 F; c& @! c
    2) booting and partitioning software from other OSs' F8 z2 s' v- s6 _4 h6 ^3 W& B
       (e.g., DOS FDISK, OS/2 FDISK)
6 I- ?2 f! u; [. j9 Z    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)0 a$ B4 z) a5 s6 v2 ?% P5 K
    Command (m for help): p
+ w* L$ x! k& e    Disk /dev/hda: 4294 MB, 4294967296 bytes( l5 C2 _# _& q) _, T8 N
    16 heads, 63 sectors/track, 8322 cylinders
, }% H8 H6 W% G! a2 l. W" y    Units = cylinders of 1008 * 512 = 516096 bytes: ~# i( T5 N$ ?- c
       Device Boot    Start       End    Blocks   Id  System* i, o( ~" H3 {; q- s$ p
    Command (m for help): m: s) Z; |! H/ t# ?) v1 Y
    Command action* p0 _% a  \% A' I& l7 ~. u
       a   toggle a bootable flag
+ x, ]5 |. y( S" i5 g# w       b   edit bsd disklabel
6 R1 P, P1 @* m6 z  o       c   toggle the dos compatibility flag
6 Q4 F5 b9 u( i6 g' m       d   delete a partition
4 l" T- `  S. u+ F- \! C8 H' l: d       l   list known partition types- L  }+ i4 F$ H
       m   print this menu
/ t9 ^5 j- H' D) Y1 L       n   add a new partition
/ ]% J* a; j2 t* e9 P" W# M3 g7 }       o   create a new empty DOS partition table9 {# [. V$ [# |* b/ T4 N& M
       p   print the partition table
6 O; G! u1 F% h1 L       q   quit without saving changes  P% X) M) ]$ p
       s   create a new empty Sun disklabel& A; v' P* w3 w3 _( e* E2 I
       t   change a partition's system id; @7 Y5 q" @7 U0 x9 C
       u   change display/entry units
+ n6 u" f) Y) m# z       v   verify the partition table2 v1 p! d+ l8 q- ~& I
       w   write table to disk and exit
% Q, y2 D: o" X8 G; ~3 g$ [# B' t$ ?       x   extra functionality (experts only)
! t- Q3 }- m9 F    Command (m for help): n) }, C( f6 B, Q- l6 a  j
    Command action2 n1 f3 |5 f% r2 Y" A% O
       e   extended
( F/ D  }3 T; v; Q. Z! s- Y       p   primary partition (1-4)( Z6 W5 {- Y$ B! s
    p5 k# h9 p1 r. M$ A
    Partition number (1-4): 1, l) X/ y2 G. H9 G8 F
    First cylinder (1-8322, default 1):
* q3 Y0 Y6 P/ e3 f    Using default value 10 C- V, c; e# X. ?/ W' J# v7 T3 T
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
; j. \2 i! G2 @% o: ~    Command (m for help): p5 D  M5 y, c7 t
    Disk /dev/hda: 4294 MB, 4294967296 bytes
5 \) M) G% |; n' T9 D. c7 R. Y    16 heads, 63 sectors/track, 8322 cylinders
2 ]/ G' R  P$ C/ [* K, k' Z# t    Units = cylinders of 1008 * 512 = 516096 bytes
$ t+ K9 l4 {( p. D, D( r) S, U& i       Device Boot    Start       End    Blocks   Id  System7 d; ?" q0 y. ]
    /dev/hda1             1      1000    503968+  83  Linux) c2 K: S9 n" Y; Q" g, ?
    Command (m for help): w  |  d1 C6 }3 `+ g3 C2 |
    The partition table has been altered!
8 x8 J% A3 l! s/ a$ h9 J! I' o    Calling ioctl() to re-read partition table.
4 S$ f, A) l- u* Q    Syncing disks.
2 P* s9 b9 ?8 K1 s    //格式化新分区
, \$ C$ F: _8 _# T, N& B5 @1 N
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 x$ A. |9 V4 B" F    Filesystem label=
/ I& @/ B. G, A7 x) {: r: P    OS type: Linux* @4 O. w" W( ~& D
    Block size=1024 (log=0)+ \' Z* S6 a( r2 _
    Fragment size=1024 (log=0)
5 A1 X1 |' K$ K( g; k    126480 inodes, 503968 blocks
* k: r( O' X# `1 x9 j8 E    25198 blocks (5.00%) reserved for the super user$ O6 _" h* M3 C& W' a1 o
    First data block=14 m4 M' V* E- O+ Q6 E, G! G# z
    62 block groups3 @7 g7 B$ H5 w% e+ d
    8192 blocks per group, 8192 fragments per group- Y# I6 ~, F5 B$ n# W7 z; Z
    2040 inodes per group
8 M4 K) f# i% p; a    Superblock backups stored on blocks:
: u0 x% `7 ~- [            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409# i/ D6 G- h/ I1 s
    Writing inode tables: done                           
2 N6 T3 ?  P7 A$ _6 ?1 _    Creating journal (8192 blocks): done, H; m6 n# l8 E+ d9 I" D; P
    Writing superblocks and filesystem accounting information: done/ N+ ?, L+ \, u) v
    This filesystem will be automatically checked every 30 mounts or
# a9 _: J+ {8 P1 I1 _, c    180 days, whichever comes first.  Use tune2fs -c or -i to override.
8 g7 a9 Q5 A3 q" h
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' h! W; W- ^* o9 @
    /dev/sda3              3723848    705992   2828692  20% /
9 k- ^; c; ]5 c    /dev/sda1               101089      9274     86596  10% /boot
) ]! f' p  Q* W, w' h    none                     14520         0     14520   0% /dev/shm
5 y1 E0 y( f2 @8 v" L    //挂上新分区2 g2 U" i5 y! p
  1. mount /dev/hda1 /home
      z" ~- X) N5 j% ^! D
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点) V8 E3 ]3 v: k, J: i! g; E
    /dev/sda3              3723848    705992   2828692  20% /$ {( A' U! r& [  x& r
    /dev/sda1               101089      9274     86596  10% /boot7 z# ]: \; c, Y/ L4 X+ I2 e  j
    none                     14520         0     14520   0% /dev/shm& N- c7 X- _6 Q5 q# s2 a" M7 R
    /dev/hda1               488006      8239    454569   2% /home
7 ^$ v: `' V' Z1 l/ T
5 `9 a9 T: z- m) m% f( k4 A自动挂载:6 g+ N4 W$ n- D% G, R
  1.           vi /etc/fstab
    7 S4 M0 r' G/ ?; A

  2. 1 A+ z$ I4 I- Q# G+ W9 _
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 05 N7 F2 X( M  n
  4. 1 M: [0 L- o  ]5 y$ z7 J7 o
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
) G1 n0 z8 T, I( ^5 Y: G  G
  1.           mount /dev/sdb5 /mnt/ljp12 a! Z7 p+ \+ E
  2. 2 i" U1 B0 z7 B, w" C
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

% w9 N, m' T; c( R
' _4 L1 u, k/ y1 C- T6 I" \* n3 x" z5 r' e2 V/ L  `
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-5-18 01:50 , Processed in 0.014890 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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