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

 找回密码
 立即注册
查看: 2704|回复: 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)
/ w7 Z1 [0 ]3 u$ U9 i' n      or: fdisk /dev/sdc  (for the third SCSI disk). c. D0 L2 y! x) B2 w. f# g& x* \
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
3 |/ f, l5 R6 }: w7 F; l) a" V      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
. F3 x  v+ ]- {3 n      ...+ J: x7 p0 x& C5 g
  1. df -k
    ) S) t" l- D" i! G/ L
  2. df -lh
    . d6 P  y' d/ b
  3. 查看有几块硬盘:fdisk -l) `. ^) _. @( P: X" v2 _
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 G/ e  [; O4 \* ~
    /dev/sda3              3723848    705968   2828716  20% /1 \- Z# L5 }7 v
    /dev/sda1               101089      9274     86596  10% /boot
3 f* _3 O- r5 I" J    none                     14520         0     14520   0% /dev/shm
3 o; S9 J; b5 z9 K* i, Q2 }    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
3 T9 h' y9 b  J2 P3 Z+ U6 L
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel  D- k3 F* I& o) E4 G5 w
    Building a new DOS disklabel. Changes will remain in memory only,% ?2 o! y  [$ M) Z9 O* D5 v9 J
    until you decide to write them. After that, of course, the previous
9 C. N: h' Q, o3 V& W. j    content won't be recoverable.
; s( j( B" K4 w    The number of cylinders for this disk is set to 8322.# @; A: D+ i! N# |& B
    There is nothing wrong with that, but this is larger than 1024,
1 U' {, f0 S  n% B* M, d$ l0 ~    and could in certain setups cause problems with:: ~  M" o( I  o
    1) software that runs at boot time (e.g., old versions of LILO)1 k& f6 a, f4 M
    2) booting and partitioning software from other OSs4 B8 l- q* B$ Q) u
       (e.g., DOS FDISK, OS/2 FDISK)3 o5 ~- q+ A, a, W& v
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
1 \% O! j. g- L  M3 z: M    Command (m for help): p
! }4 ~) I, |, I) R3 y    Disk /dev/hda: 4294 MB, 4294967296 bytes6 d; s9 ^9 ~7 P% S. n8 G$ k
    16 heads, 63 sectors/track, 8322 cylinders1 {1 p9 y: p8 ]# _1 T2 e
    Units = cylinders of 1008 * 512 = 516096 bytes+ F8 _' R+ h# ]8 {0 U$ x" |* Q
       Device Boot    Start       End    Blocks   Id  System4 ?7 V: H3 _2 \  K8 o
    Command (m for help): m( s# ]3 e4 i2 f; X
    Command action1 Y) c3 @# b* q. I1 Z% A1 ]
       a   toggle a bootable flag1 g. d* r# _! s  b
       b   edit bsd disklabel
! n3 x9 X( D, N" n8 M+ A       c   toggle the dos compatibility flag
3 T+ _& b( V* K; h- ^) j: Y       d   delete a partition
1 @* K, N: J& C5 S* Y' j6 X       l   list known partition types
- F) }- {- m4 x8 f6 L       m   print this menu3 a( H8 g) V6 h2 J
       n   add a new partition) ]$ k3 a1 }, E- R3 x4 z
       o   create a new empty DOS partition table
, Y7 h' }4 o( p7 F       p   print the partition table, T* q+ q! J% b! A# n/ O
       q   quit without saving changes
& M4 l; G' n2 w* [* B       s   create a new empty Sun disklabel. V4 m" b% T$ E$ m6 x2 f) K8 s
       t   change a partition's system id
* {, m4 B7 q8 O& t       u   change display/entry units
# r; x3 x3 N2 {  L: [6 P  R  q6 d) }) `       v   verify the partition table( R' f* b+ D% v. i3 C
       w   write table to disk and exit) W' T  [$ d& l7 w$ ]6 |9 N
       x   extra functionality (experts only)
& r2 v( Z5 v, x' i    Command (m for help): n
, A: a, e" Y" G" Q$ W# z* R; l1 y    Command action  S8 f4 Y& v* r' w" J* `
       e   extended! h2 h" T8 {1 s% }
       p   primary partition (1-4)9 {1 v3 v$ P8 c# V( K' f
    p% b. ?: E0 f# N' D
    Partition number (1-4): 1
8 g$ n  a7 H4 Q( ~6 v; I) m8 E    First cylinder (1-8322, default 1): 4 t1 x+ a" _4 s
    Using default value 17 J4 ?- _1 o, T% U
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
4 s: L* b2 n$ M% B0 W) W" U    Command (m for help): p$ D; s2 r9 Q9 @1 B8 t# j8 Y# f/ r
    Disk /dev/hda: 4294 MB, 4294967296 bytes+ r/ J( \2 T* w* r3 r2 D- n
    16 heads, 63 sectors/track, 8322 cylinders, x" O  X0 Y1 o+ c/ _5 o$ X
    Units = cylinders of 1008 * 512 = 516096 bytes' H* h# M" @# [; C; l4 N3 }
       Device Boot    Start       End    Blocks   Id  System! P( m4 Y8 l( ?) p
    /dev/hda1             1      1000    503968+  83  Linux
7 D/ n* s$ G8 k8 v    Command (m for help): w/ u7 w6 |; ^4 E6 \! u) h! l
    The partition table has been altered!+ X# i1 u. P* _0 U' H, `
    Calling ioctl() to re-read partition table.1 [' a8 R5 d; S) g/ @) S
    Syncing disks.. A& ]: T" Y2 S% R1 W- t. G
    //格式化新分区  F8 J) Q; z7 u8 g
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
5 D5 U4 y) x! j5 {  D8 P) [    Filesystem label=. \+ l- A# b) E- L7 t4 @  |
    OS type: Linux
- E& x( u) g2 o& W, K! Q    Block size=1024 (log=0)
& z3 C! }0 F. C    Fragment size=1024 (log=0)  |/ B8 |3 s8 {4 z& m
    126480 inodes, 503968 blocks
* {) N  J$ d. i    25198 blocks (5.00%) reserved for the super user/ }7 J" S; J. {! S' b
    First data block=1; J' \, o; W; W% W/ i
    62 block groups( x* m3 v0 T7 R* F5 y
    8192 blocks per group, 8192 fragments per group
) W# n9 {5 D$ C, P1 s& N# I. B    2040 inodes per group
# `4 J* X* M! q4 s2 V& p    Superblock backups stored on blocks:
( f3 J3 h1 \# W! i" F            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014090 B0 K; [) m/ y1 M: N# s- y
    Writing inode tables: done                           
6 J8 y; L2 {% U# H1 t8 R5 {: Q    Creating journal (8192 blocks): done
, I) k  ?+ r4 S; I    Writing superblocks and filesystem accounting information: done' E; z' e+ ~' l2 S
    This filesystem will be automatically checked every 30 mounts or) K. s! g) h5 G8 Q
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
, f2 D0 L/ d1 d5 O9 ]$ @6 T
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点* w9 Y' g. L; l4 P
    /dev/sda3              3723848    705992   2828692  20% /6 j5 A0 r' n1 z: H& R
    /dev/sda1               101089      9274     86596  10% /boot! O+ Y  J+ [. m' c# S+ U
    none                     14520         0     14520   0% /dev/shm
2 @/ V5 {, E% `* W    //挂上新分区
$ h( D4 U( J5 n' z
  1. mount /dev/hda1 /home1 y  l$ x# O  X$ u5 {3 \" @- }
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  k' ?% B% W3 I5 V' b$ [# O* x! i    /dev/sda3              3723848    705992   2828692  20% /0 R3 T2 m: k+ Q+ M* b) z! t
    /dev/sda1               101089      9274     86596  10% /boot) p3 u* g* a7 e
    none                     14520         0     14520   0% /dev/shm- u4 f) l5 T! c; B
    /dev/hda1               488006      8239    454569   2% /home
; k& b6 ?, D% b* }1 U- q" w
7 `& y2 ^! J. m: C( E自动挂载:. Y1 c. j0 o! z& C
  1.           vi /etc/fstab+ ?1 I7 |% o0 x. D3 c$ o
  2. 3 o4 b* U0 d" Y* T; n+ s. Y, `
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0+ C, \+ Q8 n4 E' _9 G  q
  4. $ a4 d$ S5 u6 X) l
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:5 a& P6 ^4 H8 J% N3 p0 ?
  1.           mount /dev/sdb5 /mnt/ljp19 ]7 {2 @8 }% _: c
  2. 2 U. j+ c/ r  R
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

- i, H1 d( F- {2 D" z6 b" B( J! D' X* G# t9 f& k! {6 s

+ V& s& Z6 e' L# r* `
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-22 15:22 , Processed in 0.008512 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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