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

 找回密码
 立即注册
查看: 2662|回复: 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)  E. q7 q/ D3 d% Q4 _$ [
      or: fdisk /dev/sdc  (for the third SCSI disk)% ?1 Q9 ~6 C" l% V* G
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
! S5 z6 `/ t: {( U, G      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
( o1 p7 w* r3 L0 N8 q6 c      ...
) V# Z. e# j" U' h) e: N  X* m
  1. df -k
    3 `% H$ }. \. m# G: f4 h8 ~! n8 Z
  2. df -lh) G1 _& Q* f8 i1 y1 r
  3. 查看有几块硬盘:fdisk -l  |- X3 b1 w8 ^5 Z9 P
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
9 s2 y) T1 O, H- u' e$ |6 L0 e+ L    /dev/sda3              3723848    705968   2828716  20% /
7 e) d" k: \9 E    /dev/sda1               101089      9274     86596  10% /boot
' L& h( k# ^" `4 E! q& N    none                     14520         0     14520   0% /dev/shm0 ~) _4 P" }; r; Q9 s
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
: Z+ Q4 b& ~2 i8 o$ x0 a
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
. H0 a. @/ M. L7 A! t. X    Building a new DOS disklabel. Changes will remain in memory only,& h8 v& B* X# h/ R( B
    until you decide to write them. After that, of course, the previous7 w& Z+ }( j  y: a5 E
    content won't be recoverable.
5 h  V2 E* Y) p$ R1 f! t4 K    The number of cylinders for this disk is set to 8322.  p: X, }1 S) j# v8 T( A: W$ W; I
    There is nothing wrong with that, but this is larger than 1024,  |' R: G, F9 `' I
    and could in certain setups cause problems with:# E: q- l- ?4 a) ?7 L- I8 J
    1) software that runs at boot time (e.g., old versions of LILO)4 R; N/ X5 t* k' t
    2) booting and partitioning software from other OSs3 ^4 n2 U+ `8 I
       (e.g., DOS FDISK, OS/2 FDISK): f. J; \; C1 p; p( |
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
% x5 T" _2 R0 e: |8 p1 C    Command (m for help): p
. `% c7 y+ o$ i6 I; D/ A    Disk /dev/hda: 4294 MB, 4294967296 bytes6 l' d7 A+ w  J0 T( ^
    16 heads, 63 sectors/track, 8322 cylinders
7 r  G* C/ ]+ Z# C0 Y    Units = cylinders of 1008 * 512 = 516096 bytes$ s- Y: Q0 _6 S/ y; h& O  N
       Device Boot    Start       End    Blocks   Id  System
! c; J. ~: I" }+ s0 A    Command (m for help): m
* D: F0 U! [8 u: r8 W    Command action2 _: R% x6 C+ F' g' L4 E# a
       a   toggle a bootable flag4 d) q% W# V- H) C  `' r0 S
       b   edit bsd disklabel
; g* y1 \) I; m       c   toggle the dos compatibility flag
8 z9 a. M0 R1 |" D$ {, o  g       d   delete a partition
+ S& {$ _8 ~+ a, [- s& Y/ ~       l   list known partition types. e, ^( x, T) d7 N
       m   print this menu
2 d; f$ C/ d$ N3 G       n   add a new partition9 ~1 z" F0 l; f: l& |+ z
       o   create a new empty DOS partition table. w1 @$ u" D( a/ ?% S& s
       p   print the partition table; |, q: @$ x* C' n7 Q- ^5 X6 ]  F
       q   quit without saving changes
0 L( m& E: D; _       s   create a new empty Sun disklabel6 h) j: Z( a' Z5 L" \+ S# W
       t   change a partition's system id$ Z5 M: a, L  n
       u   change display/entry units
* b& ^/ ?0 }- P       v   verify the partition table; }) V+ D6 W  `/ y) L
       w   write table to disk and exit
/ w" A: p; i' t  @% N       x   extra functionality (experts only)
, `0 q% x9 v+ ?    Command (m for help): n
8 y; [! n5 D& g% E" I    Command action3 H2 ^$ p0 U% x" `0 y" D2 j. P
       e   extended( K- O/ V9 V: a) e' V
       p   primary partition (1-4)1 C# _) ~1 r+ @; l( A" U
    p
& Q- c" J' j) Z/ W2 j. a    Partition number (1-4): 1& l) \2 l  L0 _# R$ N! j
    First cylinder (1-8322, default 1):
+ K1 }' [4 w6 ?    Using default value 1, b" d* h+ [! W0 j
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G1 Y/ N& l) j  v. T1 G
    Command (m for help): p* D% g/ s7 c8 d
    Disk /dev/hda: 4294 MB, 4294967296 bytes
" R" d# m+ D$ x$ ?) x5 w* }7 o8 r    16 heads, 63 sectors/track, 8322 cylinders8 l- C; N$ x3 |* C
    Units = cylinders of 1008 * 512 = 516096 bytes
* i- |. o2 D1 v8 }6 H  w       Device Boot    Start       End    Blocks   Id  System% W' u# d% k8 X6 R6 ~1 I4 {
    /dev/hda1             1      1000    503968+  83  Linux* |  K. j1 V6 P  Z: v& e
    Command (m for help): w
. I; D" ?: M# w* O. p    The partition table has been altered!
+ X2 k/ ~2 W5 R1 ^* z; i: ?    Calling ioctl() to re-read partition table.! J8 B& v# H$ Z6 {+ F4 t! ~) J3 F
    Syncing disks.  ]1 `! q& i: G; Z, u) z1 Y
    //格式化新分区6 s% y# M# K" [# H7 |
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 h! X4 h5 q' f' {; v    Filesystem label=9 t( x0 k$ o- k' r, l( I* S) a
    OS type: Linux
; Y0 E% t" d( _% D- K    Block size=1024 (log=0)
; b( @' y2 {' }& u1 S    Fragment size=1024 (log=0)
: f( ?$ b: {8 j0 B    126480 inodes, 503968 blocks3 b# t8 v2 s2 U; M
    25198 blocks (5.00%) reserved for the super user; n( u5 U) V4 D+ h
    First data block=1
8 b9 Q, O' c5 C4 u3 T# w    62 block groups3 a1 s. Q$ E8 G0 d* A- H
    8192 blocks per group, 8192 fragments per group
0 W) |0 Z% B. d, d0 A    2040 inodes per group
+ ~4 D% X+ v1 l, Q2 p    Superblock backups stored on blocks:
/ e3 n5 r  J9 S2 u            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
; Z, {" q) v8 L8 E, P3 X% @. W    Writing inode tables: done                           
! Z3 f2 l8 B6 U+ F1 z    Creating journal (8192 blocks): done
. W, n) c& q' X) k, x: G; W    Writing superblocks and filesystem accounting information: done
" G% I- n! `8 L( X    This filesystem will be automatically checked every 30 mounts or) s2 W0 Z, L7 c. O
    180 days, whichever comes first.  Use tune2fs -c or -i to override.4 B+ Y" ?/ h" q/ s. C/ I$ ]
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
. n* Z: o, _0 q    /dev/sda3              3723848    705992   2828692  20% /) {( S6 L4 g# f9 S! e
    /dev/sda1               101089      9274     86596  10% /boot2 o7 y, g! w  t9 D# S
    none                     14520         0     14520   0% /dev/shm! ?( S7 U" P: ^6 b: K
    //挂上新分区. J2 v! _4 i' \- F) ^! T7 y; ^
  1. mount /dev/hda1 /home8 X: W+ J) }% C# H  V
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  h/ M; t8 l9 P5 c, h1 I
    /dev/sda3              3723848    705992   2828692  20% /8 G: G$ Q$ C4 a& Z
    /dev/sda1               101089      9274     86596  10% /boot
( D: J) Z7 [  Z0 L* n( U7 O    none                     14520         0     14520   0% /dev/shm8 W0 r1 w% r3 k8 w
    /dev/hda1               488006      8239    454569   2% /home
7 g, e2 `: ?" C5 S3 F! t! r8 M( D4 F. g8 Z4 u: C
自动挂载:
2 n. f. n$ d+ q9 B
  1.           vi /etc/fstab
    ) _* |, N& G6 z0 M7 |' U
  2. " k0 F" r9 Q/ k' L% X9 N
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ; z; a( _* j7 K" E" Y, _

  4. ; i4 h7 x9 n- t1 t8 a
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
2 `' w; w7 f. c7 A* U- Y
  1.           mount /dev/sdb5 /mnt/ljp1# v1 Y3 R2 K" ?! m  D3 U/ Q/ i

  2. % V6 j5 u6 E$ W9 w' S, N3 {" P/ J
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
+ b* a$ q: E0 A( c; H" \$ V
) u; ~$ u4 k" O  u# ]

( z" n+ [7 V) W5 B
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-10 03:35 , Processed in 0.040615 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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