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

 找回密码
 立即注册
查看: 2586|回复: 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)
* D8 P8 T- K8 A$ o      or: fdisk /dev/sdc  (for the third SCSI disk)$ x) R% K1 o8 X2 m1 Y
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
% {. a# p- B1 g      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
) O* ]; \/ t0 H4 n3 R1 }; _/ g      ...  q/ @- C' K9 b! b- u
  1. df -k: U! X! X6 H) Q, f/ j
  2. df -lh8 d4 q, K$ W3 P9 f. M1 P$ [
  3. 查看有几块硬盘:fdisk -l
    8 Y5 }5 f8 ^  x2 y8 E# H4 t
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 S0 p' y: t0 Y5 K
    /dev/sda3              3723848    705968   2828716  20% /
5 v! I7 ~; U+ N1 T( p0 [    /dev/sda1               101089      9274     86596  10% /boot
% ^1 G4 y) z$ s+ C5 ~    none                     14520         0     14520   0% /dev/shm8 o, _4 Y# Z6 K1 I$ e, d; g7 w2 D1 w
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
, z% Y8 C5 J% m! d) d/ c
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3 b6 ~/ e8 h* v2 z* Y' ?) W    Building a new DOS disklabel. Changes will remain in memory only,
! l2 @6 p  G* E9 j    until you decide to write them. After that, of course, the previous4 }% r% L) R/ x; W6 i
    content won't be recoverable.' J+ }0 w3 W' {* d# L  C
    The number of cylinders for this disk is set to 8322.& M& P8 T, |$ o& S! D
    There is nothing wrong with that, but this is larger than 1024,
0 ~- N& s* W! Q" r2 n5 ~: k    and could in certain setups cause problems with:0 ^1 ~% A, r) r) C; D; N1 B
    1) software that runs at boot time (e.g., old versions of LILO)* f/ g! R0 m8 q* ]2 `. x  t1 u
    2) booting and partitioning software from other OSs
, y9 e% B- V0 k/ B  w' l1 c2 e       (e.g., DOS FDISK, OS/2 FDISK)
$ i2 A# {1 |5 c3 q    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)5 U- |- W/ f, Z- A; o  P6 m
    Command (m for help): p; F% T3 l2 |+ q! d1 {0 B
    Disk /dev/hda: 4294 MB, 4294967296 bytes  [; S6 k, Q. ~5 E
    16 heads, 63 sectors/track, 8322 cylinders
4 R6 v/ A6 J1 S$ s6 y& G  u    Units = cylinders of 1008 * 512 = 516096 bytes
9 d/ E  V' \9 {) P# s       Device Boot    Start       End    Blocks   Id  System" d6 _. n- W5 ~) W' m) T
    Command (m for help): m- y: q0 w6 G& w& Y9 ^; Q7 r# V) v
    Command action4 {) W$ X! @: Y/ T9 J4 C2 j* ^
       a   toggle a bootable flag# W! e7 k$ X' h$ e, S- E2 [
       b   edit bsd disklabel' B# t. ~& t+ e
       c   toggle the dos compatibility flag4 ]) `: i: `6 J
       d   delete a partition& X7 k* |! @- m% M1 I% e
       l   list known partition types
1 B  z' ~0 }8 @* R6 n% y       m   print this menu; u. q5 F1 z& C$ k
       n   add a new partition
2 D/ s  F7 r& X- D3 w       o   create a new empty DOS partition table
  s" x* P; R5 m) z       p   print the partition table1 E; p7 q/ v0 m! W6 f  ~- x
       q   quit without saving changes
2 z5 g) _+ b/ h6 S; A( N! }! J2 [       s   create a new empty Sun disklabel
4 P; \2 y4 H. X2 u* s* B! ~       t   change a partition's system id- [, z6 x4 J6 C1 y' h: ]( U: A+ g& J
       u   change display/entry units
+ z0 P& Z: J! N( Z* c# P8 ]# \       v   verify the partition table
: q) h4 `6 ]1 ^' P       w   write table to disk and exit1 Z1 {. Q( y2 V) j* |" `
       x   extra functionality (experts only)9 b5 M1 h. ~2 ]7 z
    Command (m for help): n$ W( e8 N2 E2 ^
    Command action
9 W; P! {7 ^* ?7 J       e   extended. E% W% a' q  M3 a  _5 \
       p   primary partition (1-4)
: k) g2 n" J  @1 A  `9 ~5 |    p
' d8 H6 G: }% Q% T" A0 I1 u& W5 T1 y    Partition number (1-4): 1
2 y. h1 _5 r; m; N    First cylinder (1-8322, default 1):
2 a' b; ?/ {$ O$ V1 ]0 L0 J+ x1 N    Using default value 1
( \$ O( Y6 u) T- W1 i7 Z    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
2 F0 C3 F* x. X' h$ l    Command (m for help): p
# ~( D+ C: @5 }) h6 n+ n    Disk /dev/hda: 4294 MB, 4294967296 bytes
$ C1 J1 P4 Q, x4 [+ T    16 heads, 63 sectors/track, 8322 cylinders
" j4 {" V: C- @' T* S    Units = cylinders of 1008 * 512 = 516096 bytes
* H/ ]/ ^7 ~  i/ x' Q       Device Boot    Start       End    Blocks   Id  System- j3 |/ S. _* c7 m
    /dev/hda1             1      1000    503968+  83  Linux
2 _8 @4 `4 P; a) ?1 D. P3 q/ a& I    Command (m for help): w
, \: [/ Z: i1 t4 J, R; A8 m    The partition table has been altered!
- _! l1 q+ Y4 U* L. q! E  S+ u    Calling ioctl() to re-read partition table.. f! G  f# n5 P7 q* S+ R
    Syncing disks.+ r  h+ j4 y! Z  i8 C+ y; o
    //格式化新分区$ u- ~7 V4 ^1 J" ]% c* Y
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)6 Y& i+ Y) @5 d, X- B
    Filesystem label=2 R5 c& d- T$ d* G; \9 D- D& A4 y
    OS type: Linux
; p( W- @+ n  _& A2 {    Block size=1024 (log=0)
8 R8 b5 a# i6 X( b% J: _2 w! {    Fragment size=1024 (log=0)
& X0 D2 {' E& g, u( f! W    126480 inodes, 503968 blocks0 t% R( @5 Y# M
    25198 blocks (5.00%) reserved for the super user% @% P. z, J! U6 k
    First data block=1% h3 M6 w4 A# e
    62 block groups( q: C% y& F% J( |; y8 G* m/ m" g) Y3 p
    8192 blocks per group, 8192 fragments per group
' I7 O! J. Y+ [0 N    2040 inodes per group# Z/ I% W  ?6 x, i5 F2 O
    Superblock backups stored on blocks: 1 {- r7 r7 O5 X# O9 L
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
( |1 i) M# v; R- T; v6 }  h    Writing inode tables: done                            - [* m7 R" Z9 ~1 k  \- i, d
    Creating journal (8192 blocks): done
5 l  Y4 _1 m( \+ ~    Writing superblocks and filesystem accounting information: done: x3 i: s) N9 s8 l/ x2 W
    This filesystem will be automatically checked every 30 mounts or) N1 ]3 _+ G3 f& H1 C2 S
    180 days, whichever comes first.  Use tune2fs -c or -i to override.+ q$ T; F3 a% z' y" B
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  s( H8 k; J4 W4 l! {/ z6 c    /dev/sda3              3723848    705992   2828692  20% /' ?8 f) E" I! R9 A
    /dev/sda1               101089      9274     86596  10% /boot- F( J3 j3 T" \( Q1 O" E+ @
    none                     14520         0     14520   0% /dev/shm" {* P$ r8 b& K
    //挂上新分区
1 ~- n8 n$ l( M5 Z
  1. mount /dev/hda1 /home4 L0 M- K% F8 [; a, c5 b# ?" B
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- ?) b0 d' V3 s$ q! ^$ c* i
    /dev/sda3              3723848    705992   2828692  20% /0 {6 E- d: ]! o% L1 C) ~
    /dev/sda1               101089      9274     86596  10% /boot" O% B* b4 v0 S) p, \
    none                     14520         0     14520   0% /dev/shm
& q% z; N1 T0 q& E/ }& b7 m    /dev/hda1               488006      8239    454569   2% /home
( _& b3 R1 u, A& Z% o9 ~- U: y3 Z% w4 x6 Y. N4 w
自动挂载:
+ d& m2 c4 S8 N$ b; g' Z- G
  1.           vi /etc/fstab
    4 n6 Z! L2 I2 d: i4 T" K8 S" W) Q/ r

  2. $ z; K6 [7 _/ [
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    1 {: ^5 {9 K7 R1 a! T
  4. ; H) f7 L2 K! v+ s' q: g
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
* ?( f% u. w" E4 _
  1.           mount /dev/sdb5 /mnt/ljp1
    5 S7 m7 H* G, h* e
  2.   `4 n; N! h  L7 _9 h2 t" y& q
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

% x- U) Q7 C+ a' b( u" G( `# @3 M/ r5 e1 V" |' a6 c( a7 q

0 F8 T, {* k$ j1 c1 {% _
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-24 03:41 , Processed in 0.034128 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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