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

 找回密码
 立即注册
查看: 2963|回复: 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)7 b' \/ o$ p+ E$ j  t
      or: fdisk /dev/sdc  (for the third SCSI disk)
1 H# J# ^7 ^6 n5 n2 c, L' ]      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
2 Y' v- i; c. i/ D9 |3 s, M& P& j, ~      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices), P- s! j/ T! ]; d& A9 F: k- j1 B
      ...) _) Y" d& D. v# W! z" ?
  1. df -k
    4 n" Z9 V) u, l' K# F. N2 Z4 O2 }6 I7 V
  2. df -lh
    % R& d4 Y$ y( N7 z) r( U- n
  3. 查看有几块硬盘:fdisk -l
    $ e& N, e- K8 G( W; a& O( j; U
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! R0 |3 c) a- D& F    /dev/sda3              3723848    705968   2828716  20% /  C+ j% x. U3 A2 O7 g8 W) K" k5 o& H
    /dev/sda1               101089      9274     86596  10% /boot
+ a3 s$ A2 d! U. J: L# ?1 P    none                     14520         0     14520   0% /dev/shm+ m1 z4 z9 O7 s/ T
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用: W$ T  [, T& ^$ J: P: d
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
/ V5 H3 B6 \( O7 d* T' R$ I    Building a new DOS disklabel. Changes will remain in memory only,9 K. f1 G% f2 X
    until you decide to write them. After that, of course, the previous
2 M$ V$ f. W$ a0 j    content won't be recoverable.+ a' j7 C) X2 l# C7 c+ ]1 {
    The number of cylinders for this disk is set to 8322.5 c* c8 T- x" {- R2 y
    There is nothing wrong with that, but this is larger than 1024,* E) k. a, Z, t. {
    and could in certain setups cause problems with:9 T! J2 G$ ?( _, t- j
    1) software that runs at boot time (e.g., old versions of LILO)
# s4 ^9 w* Y. @    2) booting and partitioning software from other OSs& j6 C  T  B; A
       (e.g., DOS FDISK, OS/2 FDISK)  A$ F- F1 F8 K; l6 |; ?4 z
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)& H! {. H9 I! w) ?6 r7 B# J9 Y
    Command (m for help): p
/ ~4 M. q* D0 c5 J    Disk /dev/hda: 4294 MB, 4294967296 bytes
: t; J% W# j, T9 v- u$ C    16 heads, 63 sectors/track, 8322 cylinders& K; ~  s4 Q; P3 E
    Units = cylinders of 1008 * 512 = 516096 bytes7 D) x5 N' A  I0 E
       Device Boot    Start       End    Blocks   Id  System
2 |$ F5 m+ b8 ^5 E. {. }    Command (m for help): m- [% m* @, e" A  b& V
    Command action
1 X9 G* B1 o. s; f3 P! i  Z( t       a   toggle a bootable flag
) q4 |% S" e3 o) ~! k  m* O: x       b   edit bsd disklabel
" A2 y4 J- L0 A; C       c   toggle the dos compatibility flag: y6 h3 e( v! S% x* m# w$ n- O
       d   delete a partition: V3 W' E& m% \) a
       l   list known partition types
; \7 o; E' J3 S! c  H' o( d       m   print this menu  K+ J. {) }4 T
       n   add a new partition8 i' Y/ w# g: P5 t2 {; F! R( V
       o   create a new empty DOS partition table
6 V3 I/ O! A" {& N, x: v       p   print the partition table* p5 j# ]( x: R, v+ g! K
       q   quit without saving changes! v& X( A0 A2 X. N$ Q
       s   create a new empty Sun disklabel; j+ z" |+ {6 f# y* |, q
       t   change a partition's system id
; s) Z: ^/ H* Y9 P5 \- [       u   change display/entry units( k  w! y  ^- y( H3 _
       v   verify the partition table
  K6 t9 t! t- K7 I       w   write table to disk and exit
: y: Q8 s% R: f$ [" h% ]       x   extra functionality (experts only)
& d, \4 m& i1 b$ |) i  a    Command (m for help): n- A, ]3 T$ p2 M( Y
    Command action* }6 z( g6 ?) q( [
       e   extended* J$ ?& f% ?7 T3 @2 L8 q, N: b; D
       p   primary partition (1-4)
7 k% L5 H6 D' p/ k# p" h( Q    p
/ M- w! m- ?8 U5 Z/ F7 P1 ^    Partition number (1-4): 1! a2 G  ^5 F' d' [( c9 K
    First cylinder (1-8322, default 1): $ A7 l) y5 W' m
    Using default value 1
2 p" E+ l  ?- [( V/ ]    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
9 W4 b. s) ~" C& [# N' A    Command (m for help): p% k5 t# t  k- _' p% U2 @
    Disk /dev/hda: 4294 MB, 4294967296 bytes
6 \! C! W+ U3 T5 C% }" X    16 heads, 63 sectors/track, 8322 cylinders
+ b/ g6 @( P" A    Units = cylinders of 1008 * 512 = 516096 bytes0 u8 Y* n" Z7 S0 k2 W* g: Q
       Device Boot    Start       End    Blocks   Id  System% s* c/ u2 [8 U8 b- j! S6 e# G7 W
    /dev/hda1             1      1000    503968+  83  Linux1 p2 n* }+ }$ u0 e6 r. F/ V
    Command (m for help): w
9 m# n$ \: f  i7 }2 |    The partition table has been altered!2 k- \) D+ P& P( e, _8 M
    Calling ioctl() to re-read partition table.
8 Y" _% ~; M. A% n+ r7 ^    Syncing disks.; E% ^5 l- ]6 F
    //格式化新分区' U# X7 ~; W# b( p5 X
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)% v* }% ~  V7 n/ O
    Filesystem label=
% L8 O0 M! Q9 q% ]' F6 J    OS type: Linux
8 x5 Q6 D2 E  x- ~  [    Block size=1024 (log=0)
! S% z  x) Q9 C0 x0 H    Fragment size=1024 (log=0)
* V8 `9 c8 E  m9 N    126480 inodes, 503968 blocks2 N' U9 G: T/ \
    25198 blocks (5.00%) reserved for the super user
4 r- _# i' C' s7 E    First data block=1
/ k* C' H5 o- R& T; _' o    62 block groups
! F+ s6 v9 w' N" Y! Z( b    8192 blocks per group, 8192 fragments per group# \" S4 ^- F1 [9 v. v( A
    2040 inodes per group
) x5 b+ a) m6 _    Superblock backups stored on blocks:
) F) t. A) Y  e* ~            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
* t+ _& D6 r5 X4 n    Writing inode tables: done                            ' k2 W  _0 b9 }# V% i
    Creating journal (8192 blocks): done" ^, H  C! U4 ]$ A2 t+ L- h' ^
    Writing superblocks and filesystem accounting information: done
2 B5 @0 U4 [2 q( L4 r7 C: A    This filesystem will be automatically checked every 30 mounts or) c9 r1 P8 b: }* B% d
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
9 E. M& e2 b) a+ y' P
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点+ @% a4 Q/ {  G* m% k4 _+ h/ u( D
    /dev/sda3              3723848    705992   2828692  20% /9 q6 C) p; c6 z+ G6 E
    /dev/sda1               101089      9274     86596  10% /boot. E3 s2 c" O+ Y
    none                     14520         0     14520   0% /dev/shm
6 _$ N3 Z: s+ Q' i6 o8 U    //挂上新分区
! L5 {( ^$ `+ J; J4 o8 q9 J
  1. mount /dev/hda1 /home
    ' d3 c, X# A- G) M  T
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点" M) f4 m% P  O+ [
    /dev/sda3              3723848    705992   2828692  20% /
! a; k! Q$ y7 A8 \, ?+ n    /dev/sda1               101089      9274     86596  10% /boot0 z! G7 }$ l9 b$ N9 u. K
    none                     14520         0     14520   0% /dev/shm" M; W4 T+ g% t; {; {
    /dev/hda1               488006      8239    454569   2% /home$ W7 a+ b  e/ A

" m- O4 P  R; B/ E% D6 L自动挂载:8 m' b2 l0 K& Z  h1 R1 A* t6 w% t
  1.           vi /etc/fstab
    ) x* \% d1 R( p- g
  2. ) [$ w' l2 @8 ?; ^( L2 c
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    + |. Y: W1 T+ J/ [+ e* J
  4. ) s) x$ h1 r& ~2 z- n- t. ~
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
! Y1 p8 c6 }0 c" C
  1.           mount /dev/sdb5 /mnt/ljp1
    ( ~3 ~$ B2 f% I3 Y2 Q" f( |

  2. # `& V2 J6 d) R8 M: [" a
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
# O+ j. w# Y1 n7 `. ]% B; r$ B

+ l6 \, U2 H- H7 b5 O/ ^
- a  R) \, e/ C
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

Powered by Discuz!

© 2010-2023.

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