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

 找回密码
 立即注册
查看: 2596|回复: 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)5 W" T) ?) o  L8 L2 h. ^/ n
      or: fdisk /dev/sdc  (for the third SCSI disk)
1 r' p3 J2 v$ N8 }) \      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
7 M& S* F  ^9 O: l( ^, z      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)* Z+ T5 I' M: b: K. `: ]
      ...6 x3 X; L5 b/ G" e2 ~
  1. df -k0 R; l" I/ T, \# E; j
  2. df -lh
    ; H- }6 c7 R7 m5 }! Q* h& P3 U
  3. 查看有几块硬盘:fdisk -l- I+ J! K, c9 o$ G
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  G5 d( V) H% W" F
    /dev/sda3              3723848    705968   2828716  20% /2 G1 `2 k, D5 t  {
    /dev/sda1               101089      9274     86596  10% /boot
( v' u' G& U5 }0 V" P7 g$ n# E- K    none                     14520         0     14520   0% /dev/shm
$ o  W5 K" `( I    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
% z$ o/ U2 K! d6 v% p
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) q0 v* E7 R) w2 C6 @/ p) z    Building a new DOS disklabel. Changes will remain in memory only,
& t( b% B8 o9 N9 I. k    until you decide to write them. After that, of course, the previous
  F. O/ ?1 i8 i1 q  r& @' j    content won't be recoverable.0 e; y: J7 U8 O* M* ^
    The number of cylinders for this disk is set to 8322.8 T) k2 `% A0 I2 K2 Y# H8 x
    There is nothing wrong with that, but this is larger than 1024,
4 k% x. b1 Z) e' v* T- b, X    and could in certain setups cause problems with:4 T& j7 ?8 q  {9 c. r. F* h
    1) software that runs at boot time (e.g., old versions of LILO)& r# M1 g9 u& [2 g" @3 H8 U# @
    2) booting and partitioning software from other OSs
! C1 K" ]4 `5 k0 f0 J- j; c       (e.g., DOS FDISK, OS/2 FDISK)3 p  T) ], u% z' N
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
% c3 I9 W  {( Q2 D) ?    Command (m for help): p
1 _0 i0 ^4 m7 C    Disk /dev/hda: 4294 MB, 4294967296 bytes
/ P) Y6 X* i' |    16 heads, 63 sectors/track, 8322 cylinders
! z! D2 Y% G" R+ C: t6 u2 N    Units = cylinders of 1008 * 512 = 516096 bytes! a) t3 S% ]9 }; ^- U; x
       Device Boot    Start       End    Blocks   Id  System
& C: T2 x! D: Z1 C3 E' A$ m# u    Command (m for help): m2 W, P; N2 A1 g, x0 W! M
    Command action6 a+ \9 Z+ {$ v( }$ C
       a   toggle a bootable flag
4 p- F8 }  [, p2 `4 r6 ^       b   edit bsd disklabel
6 d: g4 P: F; s! r7 c7 W       c   toggle the dos compatibility flag2 J& G7 O/ W+ |' y) e6 p
       d   delete a partition* s% @' N2 D; ~
       l   list known partition types# o4 [, J$ t/ f! I( U- r
       m   print this menu- H& U! ^# ]* r6 C4 q0 a' ]
       n   add a new partition
; b' s4 ?. f, \0 O- {% x       o   create a new empty DOS partition table. L1 c6 G( g+ Q1 v, a& s9 }6 O" o
       p   print the partition table9 Q% I( j  G6 t$ H# ?  O7 L/ C
       q   quit without saving changes
& t! m( W; F: C* B) t& R  B8 l       s   create a new empty Sun disklabel4 e$ W0 K. n" A* W$ R
       t   change a partition's system id
3 c: y5 B- m0 t# y       u   change display/entry units
8 k7 p) Z& D7 y0 ]* V+ e       v   verify the partition table
) r  t/ a0 o) o, z4 W       w   write table to disk and exit
: C* o' i& ~. y! x9 U' D, l       x   extra functionality (experts only)
( m; w: X1 C8 T8 p: |. P    Command (m for help): n
& y0 M/ c4 D) ^2 _    Command action
- A$ J3 j7 C' S2 b' ?. z) J/ p       e   extended5 m1 V! N6 `4 i1 R8 j* v8 f9 m. o
       p   primary partition (1-4)
, @3 D! Y7 Z6 h  t; H( M  u8 \4 q* V    p
6 [% [* {# ]$ q' J  l" R* C; M* G    Partition number (1-4): 1: A$ Y+ k# w- H
    First cylinder (1-8322, default 1): 5 W& Y* m- F. H
    Using default value 1
0 Y5 N4 m# i0 r" Q: j    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
. e' y& v& L0 J& [7 |    Command (m for help): p; {1 w& b$ U' f+ J6 {4 O) w; v! r
    Disk /dev/hda: 4294 MB, 4294967296 bytes: O: L- i7 o: e, t+ v  \4 v
    16 heads, 63 sectors/track, 8322 cylinders
, b: ^  U. r7 P' o1 N    Units = cylinders of 1008 * 512 = 516096 bytes
5 ~( C0 Q5 ?' @- g) Z. Y       Device Boot    Start       End    Blocks   Id  System
/ O2 U9 T, W6 Z1 _! h1 Z4 ~. r    /dev/hda1             1      1000    503968+  83  Linux5 \1 n' U+ x2 d5 `9 V
    Command (m for help): w: [' t  K1 D5 h% w3 B* C& h
    The partition table has been altered!
! V5 Y, O& u. B2 N/ F8 u+ f9 g* t* a$ i    Calling ioctl() to re-read partition table.
8 B3 `( s1 D4 E0 _/ H' J# \& s    Syncing disks.1 t; f$ d/ R9 H1 G* }0 u! h
    //格式化新分区& T8 Q* k: f! _' ]" o* M
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
, ~* E2 a; K$ R2 g    Filesystem label=
# Z7 M$ u2 J: z    OS type: Linux
3 y& S4 x* M6 A, ^! W/ ^6 j( A4 F    Block size=1024 (log=0)
: ?8 C3 ~+ X+ e8 I1 y    Fragment size=1024 (log=0)
7 F! F: k- e$ i* x    126480 inodes, 503968 blocks
' o; M% m7 Y. j( J7 v    25198 blocks (5.00%) reserved for the super user5 l3 f4 E- {, I$ M) P, F! Z3 o
    First data block=1
7 y+ h5 a7 j5 n2 N    62 block groups: J+ @* u! }. _4 x
    8192 blocks per group, 8192 fragments per group
3 c. R! f7 W; e3 }* S0 o  l    2040 inodes per group
0 O' m1 ^' j/ I# x' h! _! }- v    Superblock backups stored on blocks: : b' n6 R4 Q6 j& V  K
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409& v& F! `8 l1 k. x8 `% h3 p# K
    Writing inode tables: done                           
  I( x. X, y( R# u% {. I    Creating journal (8192 blocks): done
: @  s- n( m2 Z    Writing superblocks and filesystem accounting information: done
! k+ S7 z2 `+ [# C9 K    This filesystem will be automatically checked every 30 mounts or8 T  l4 I6 D" j! F  h) I: K
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
" d% x3 }- i" k0 r& e" M, E
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
; w$ D4 G. Z7 ^    /dev/sda3              3723848    705992   2828692  20% // M2 y/ @+ |  |3 B
    /dev/sda1               101089      9274     86596  10% /boot
3 T  S9 ~8 W' {5 u  }# z# v2 Y' o    none                     14520         0     14520   0% /dev/shm
- h! B# k7 D$ j* ]7 m    //挂上新分区7 W5 v0 u4 c: {- W9 b
  1. mount /dev/hda1 /home
    7 P" W0 ]; ~, i
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ `. p+ a; E1 U9 A, j    /dev/sda3              3723848    705992   2828692  20% /
7 J0 j9 D3 `. H' Y    /dev/sda1               101089      9274     86596  10% /boot
& k5 `7 P3 V/ ?. d$ @4 y$ a    none                     14520         0     14520   0% /dev/shm
8 N- d# p, l) [' t# G    /dev/hda1               488006      8239    454569   2% /home; h, M* z% \7 {& u, h, b

/ n  x" O3 r; h$ P* ]* W) p自动挂载:
* C$ R! ~: r* p. h$ W) G" C4 z
  1.           vi /etc/fstab4 r' F% l4 }3 [. A/ R9 d7 m) y; t
  2. 7 Y2 E6 i& [3 R# z
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0* k3 G) S: N6 T5 _
  4.   Y2 _1 m2 z9 t, o3 v1 T
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
7 e  P0 c( {: W
  1.           mount /dev/sdb5 /mnt/ljp1
    - T( D/ }% ]( J% h/ r! \' c, ?5 e2 _& y: ]
  2. 5 Z3 [" S! x9 ?; B
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
( V& g" r7 P/ t" B
1 @; Z3 o% j* l9 _
0 f# r2 A* Z. t- H
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-26 04:24 , Processed in 0.015788 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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