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

 找回密码
 立即注册
查看: 2772|回复: 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)2 q9 ]& V0 E4 d2 J  X7 p
      or: fdisk /dev/sdc  (for the third SCSI disk)$ i' y3 b( }6 W: C% r
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
+ d/ {6 O8 ^# K' ~# W      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)3 O- I; N% b% v: U4 L) [& x
      ...
( b! M8 h9 O9 ^0 d
  1. df -k
    & g$ r% H' c* y+ j1 p7 i" w' m8 Y
  2. df -lh) ?! n1 B" V: b- T! e
  3. 查看有几块硬盘:fdisk -l& [+ [' j* V) E: U6 v7 A( _
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
5 m# j- D8 N7 ^0 w6 Q    /dev/sda3              3723848    705968   2828716  20% /
" c  i0 ^. P2 F# U* w    /dev/sda1               101089      9274     86596  10% /boot
/ @/ i: o, {% d5 O5 T    none                     14520         0     14520   0% /dev/shm  x, J5 P  D7 \% E) w% K
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用3 t& k  L9 e5 S5 a4 T
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel# ]  H  v+ S/ W& O$ }6 B
    Building a new DOS disklabel. Changes will remain in memory only,8 [, T; x' w1 V* K
    until you decide to write them. After that, of course, the previous- @& X) ^1 k  v6 A4 x& o
    content won't be recoverable.
# S  s3 \+ C" Y5 l& [6 R/ e) I. P    The number of cylinders for this disk is set to 8322.
& a0 A# ]* r; ]    There is nothing wrong with that, but this is larger than 1024,
" A$ _3 I; U; |( o) F6 i% a. D    and could in certain setups cause problems with:
9 u" {6 f- b9 s3 ?    1) software that runs at boot time (e.g., old versions of LILO)7 k) l6 T, P& t- N4 g0 {0 ~) b
    2) booting and partitioning software from other OSs
0 O6 w: A/ T# n       (e.g., DOS FDISK, OS/2 FDISK)
  O" ]3 U* o. p* Z    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
+ d5 V  e# S8 P$ d" O    Command (m for help): p
% j' a  x& j$ n0 n" R, \    Disk /dev/hda: 4294 MB, 4294967296 bytes
+ D) ~2 B! Z" J; k0 N- }    16 heads, 63 sectors/track, 8322 cylinders0 w/ C/ r( ?/ I. o  e! E4 _
    Units = cylinders of 1008 * 512 = 516096 bytes& b$ T" L+ m5 ?2 F& J
       Device Boot    Start       End    Blocks   Id  System+ o; `6 |4 y% w3 ^+ ~9 m
    Command (m for help): m
! i' \; J$ U/ S5 R    Command action
2 B9 E7 D# e% \/ H       a   toggle a bootable flag9 v8 H- g9 D! s1 b
       b   edit bsd disklabel7 }& ]& b; m$ M* |6 H
       c   toggle the dos compatibility flag
8 s6 ~+ G9 A' w: J3 W/ y2 P       d   delete a partition* q7 d8 t0 E- X1 \" P! _
       l   list known partition types
" L0 z5 n, L2 Z5 u       m   print this menu. k, n+ {' N+ _$ R7 z5 [4 M' f) S
       n   add a new partition' I$ o3 `# O/ Z
       o   create a new empty DOS partition table
# P7 T* v0 h, Y3 E2 p+ d       p   print the partition table- e: Z( w( c2 j, B6 T* M4 H+ J
       q   quit without saving changes# o$ Y. r9 W9 Z% g! F7 r
       s   create a new empty Sun disklabel
3 G  u3 }! O. R& N- ?' }       t   change a partition's system id
- E' R/ K: ~+ r1 A0 A       u   change display/entry units3 w, }; f) G, j3 t! r
       v   verify the partition table* g% f. \9 k, c& Q. }- W
       w   write table to disk and exit
! ?$ I7 M. ~; u7 I5 p       x   extra functionality (experts only)
" I+ m4 Z5 r' u) i    Command (m for help): n+ M2 M  z6 S: H5 b' x2 t  Y9 c
    Command action3 ]5 V7 f" J- e  l4 n
       e   extended4 I* n  s/ U4 G) x3 p
       p   primary partition (1-4)2 P2 e: e1 a1 O7 U# @+ N1 y+ o
    p$ W- u7 J9 }* h, ~+ g
    Partition number (1-4): 1. L: _0 a5 Z2 n% S" z+ O! t$ E
    First cylinder (1-8322, default 1):
' F1 {+ o% s+ H    Using default value 18 x3 \: F; N$ O8 m
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
) q) `* m$ h3 _  Z0 `2 z! U2 W  E    Command (m for help): p% }* N4 M0 m3 k
    Disk /dev/hda: 4294 MB, 4294967296 bytes
! w2 j7 |8 [4 p/ P( B2 y1 }    16 heads, 63 sectors/track, 8322 cylinders
3 W- O' O6 N/ M# ]7 o    Units = cylinders of 1008 * 512 = 516096 bytes. C: v4 M4 R) S
       Device Boot    Start       End    Blocks   Id  System* i- Q7 n" T3 S( A, L3 P6 @% f
    /dev/hda1             1      1000    503968+  83  Linux& b7 d9 M) B4 o
    Command (m for help): w
  `4 U! A, M$ q    The partition table has been altered!7 B9 I; G7 r) q& O2 D- A
    Calling ioctl() to re-read partition table.7 j- k7 h: t) n* a& p( p; P' E
    Syncing disks.
8 L. O% ^1 D& Y% A0 n% e    //格式化新分区  Z1 H6 l% J& d6 O4 @  B
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
" G5 u# N# E5 R! R% h" n    Filesystem label=9 V2 i% Q. {4 K, L
    OS type: Linux
6 q8 G! f6 b- O3 |( F    Block size=1024 (log=0)
. F+ ?! y7 Q/ B& t    Fragment size=1024 (log=0)/ k8 E% e0 K. @
    126480 inodes, 503968 blocks! u1 O; A/ \8 L. |, j
    25198 blocks (5.00%) reserved for the super user
1 @* L( a: h" {+ m2 X; n: u9 {    First data block=1
7 p3 f2 ~3 O5 N; i    62 block groups
- H. t5 U2 `) j5 s1 C, l" k    8192 blocks per group, 8192 fragments per group9 P3 U& h3 e& T% D% g* y2 x; m
    2040 inodes per group4 F+ M) Z! Y3 G0 s1 P6 R( }
    Superblock backups stored on blocks:
" `) V8 ?+ L0 K/ Y' h; [            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409& z  M& N; u# i/ D& T, S
    Writing inode tables: done                            ) P$ n. Q3 L2 c! F7 R  V% A
    Creating journal (8192 blocks): done
9 C& t1 i; V; l& Q7 s! b) j' v    Writing superblocks and filesystem accounting information: done
/ L6 U7 E( b& M  j    This filesystem will be automatically checked every 30 mounts or
4 E9 `7 |  d7 Q    180 days, whichever comes first.  Use tune2fs -c or -i to override.9 I3 P, f' m. {: s! {: Z7 \! V! u8 d
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
. z, T) l" k1 n5 ?  L    /dev/sda3              3723848    705992   2828692  20% /
6 i- o2 k' j. S' g, g1 t    /dev/sda1               101089      9274     86596  10% /boot$ P+ D) T$ H8 J1 a  O! G
    none                     14520         0     14520   0% /dev/shm
5 d; Q% z3 v5 X# Y+ `% O, N" }    //挂上新分区4 |2 T; q9 A% X1 i: `( B  {
  1. mount /dev/hda1 /home6 d: y/ n2 z/ |$ o
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- n- q1 V+ p, c
    /dev/sda3              3723848    705992   2828692  20% /
# v1 d* E9 l% R    /dev/sda1               101089      9274     86596  10% /boot8 I$ s+ u, I9 u1 ^! L2 v) B
    none                     14520         0     14520   0% /dev/shm
% D, b1 [, e7 x    /dev/hda1               488006      8239    454569   2% /home
1 m* b0 @, a7 t. h1 X; W4 |5 r# y2 G1 b: V" m/ D
自动挂载:
! _# w0 e4 Z, \( C  D2 H& J& p
  1.           vi /etc/fstab' o5 x# w$ M3 E$ R5 X) i7 }8 h
  2. : s- ^* B% `8 X  b
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 08 W3 _! F3 P2 l1 s6 E

  4. $ C) c8 i- l3 {5 D2 E$ U
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
' y& u6 X6 n  t8 g
  1.           mount /dev/sdb5 /mnt/ljp1
    " |, O; ?8 b6 F- B% {) I. [" k
  2. $ P- O+ z3 r6 I
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
/ q& I* f# R. G' N/ G
( B: s9 I) l- j* M" P% @
1 P8 ~# B# F: z; r1 Y0 b3 t8 E" D
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-13 08:49 , Processed in 0.014925 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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