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

 找回密码
 立即注册
查看: 2588|回复: 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)
3 E+ ~' t& Q0 n      or: fdisk /dev/sdc  (for the third SCSI disk)
; i: O* N2 e; V& `7 d      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
4 {1 b9 z* C* R9 y( }      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)5 X4 W7 T$ C& \
      ...
  ^! }/ x6 @( x" L! f, H* F0 g6 `
  1. df -k: ~0 d5 ]$ \# K8 B: a
  2. df -lh& ~, D6 o; c: ^" T  b. z
  3. 查看有几块硬盘:fdisk -l
    7 P4 L: D% P( J3 g& K7 W9 Q% q( A
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
$ _3 a# P/ K0 u$ F& X. {    /dev/sda3              3723848    705968   2828716  20% /
3 T% M- d. ^9 |; w: ~    /dev/sda1               101089      9274     86596  10% /boot4 c0 o* ^5 W- h* Z- L
    none                     14520         0     14520   0% /dev/shm9 w6 |$ |4 k+ k) j4 l
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用4 i! f: ?' i) P6 M' ?
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
4 ^* g7 G, E, Q& L, S0 ^    Building a new DOS disklabel. Changes will remain in memory only,8 [3 e* p# y) t
    until you decide to write them. After that, of course, the previous
& x6 |6 n: g$ H1 A7 r5 G2 K1 n    content won't be recoverable.
7 q/ |" T" B4 \    The number of cylinders for this disk is set to 8322.
' [# W! B/ a' ^0 ]5 @9 e    There is nothing wrong with that, but this is larger than 1024,% E  W( Z$ d" t2 Q" Y+ ^! a2 H
    and could in certain setups cause problems with:
6 q! m; [& Q7 j    1) software that runs at boot time (e.g., old versions of LILO)
7 Y6 t6 _: j( o% w- S    2) booting and partitioning software from other OSs# ]- E; \0 V. y
       (e.g., DOS FDISK, OS/2 FDISK)' D7 _" `/ f8 P. @. L( D
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)+ G6 r$ h9 M) u. @0 |9 b
    Command (m for help): p
' j* T2 o6 t8 f: P! T4 A    Disk /dev/hda: 4294 MB, 4294967296 bytes" v6 A8 G" p# F1 Q6 ]- @
    16 heads, 63 sectors/track, 8322 cylinders# O" _+ P1 x5 k$ o7 w$ N$ s: `
    Units = cylinders of 1008 * 512 = 516096 bytes
0 m! U- y" f+ ^, ?7 m/ x- b       Device Boot    Start       End    Blocks   Id  System+ `+ Z) r7 x  i3 ?0 ^6 _
    Command (m for help): m( q, r3 r  [; L* {
    Command action+ f6 [; r3 \1 F
       a   toggle a bootable flag
, a% |; A- A4 I% F4 G' k       b   edit bsd disklabel* B) u: H! a5 a& Z# \) v! F
       c   toggle the dos compatibility flag" t; `9 P$ \9 n: S/ z5 l! ^
       d   delete a partition
' j6 ]: x) p& d8 P: x       l   list known partition types
8 P! r. Z4 T/ ^" V6 M5 l7 a       m   print this menu! X/ M# w) i% r* k" }6 J
       n   add a new partition% ~/ p" X, B" F) l
       o   create a new empty DOS partition table7 {% o& \7 m2 H9 L6 {( o
       p   print the partition table
$ M% U4 X1 k1 N. [1 w' E       q   quit without saving changes6 j( n, o% r& `+ b
       s   create a new empty Sun disklabel9 T' P8 t* F/ l  B! q5 c3 s! q
       t   change a partition's system id
3 }; w( b. q! t3 L       u   change display/entry units
( P1 J% J" ~. W5 @. e3 I3 F       v   verify the partition table
9 ?9 Y" o3 t/ L       w   write table to disk and exit$ h+ X2 j' c' ~; p* X
       x   extra functionality (experts only)$ n  w4 e* |* j. G  g- s
    Command (m for help): n
# d. E# |# n9 t* m% v8 S3 D    Command action
3 j/ h% ?$ O2 J       e   extended
$ O- s/ I% I3 D- j4 ?4 W       p   primary partition (1-4)! i" ?2 E$ i- _2 h' c) v
    p
4 W( O" G& S) V8 K9 n2 r5 w    Partition number (1-4): 1
2 Q0 c) y, I  m* \( |; o% }    First cylinder (1-8322, default 1): 5 z/ O% H$ Z$ S+ p# q
    Using default value 1
7 _  q2 _' R& t+ k$ W/ T1 e    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G6 x8 b8 ?) G) J
    Command (m for help): p! c) G$ F) [' ^5 e
    Disk /dev/hda: 4294 MB, 4294967296 bytes- P5 e# w0 B0 N  d! E4 u: @4 j
    16 heads, 63 sectors/track, 8322 cylinders) d( y" ?. R, h' y3 Q$ C
    Units = cylinders of 1008 * 512 = 516096 bytes
( L  D8 W8 X4 D/ O& t) Z3 I# d       Device Boot    Start       End    Blocks   Id  System8 o; s+ w1 K9 ^5 ]3 d  b+ Q
    /dev/hda1             1      1000    503968+  83  Linux6 C9 ]# O4 Z, r: l0 p* }1 R# z
    Command (m for help): w
7 @9 i9 w5 B, E" G- p    The partition table has been altered!- j4 f0 Z# b, k. q
    Calling ioctl() to re-read partition table./ ]. L/ k# ~; R" j$ Q% R& I. H4 R
    Syncing disks./ m' q9 |% ]' K
    //格式化新分区
0 a$ _: A, h& R1 N5 h/ j8 {
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)" ^! @# b3 S2 x; J
    Filesystem label=
4 I2 T: V. z6 k) d    OS type: Linux
, U! r0 u% ]* d- }; ?  h    Block size=1024 (log=0)  `& H* m, V9 V9 r
    Fragment size=1024 (log=0)* ~+ m4 r  Z/ G3 U3 Y
    126480 inodes, 503968 blocks4 A0 m4 U# _7 m' I; U
    25198 blocks (5.00%) reserved for the super user
5 ^- \9 t1 A6 R, I' K    First data block=1- x' {" |5 w: K) C0 Q7 U
    62 block groups" c2 a+ |( M. I2 D& D
    8192 blocks per group, 8192 fragments per group5 e- b' }" V4 X; h* g7 n9 w
    2040 inodes per group
7 c. x9 J% y4 t7 X    Superblock backups stored on blocks: 1 `% ]$ Y8 V  F9 o& c- Y
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409; ^6 c3 c/ {; s. z4 F
    Writing inode tables: done                            5 y' U& n8 `+ u' F( M! ~9 X
    Creating journal (8192 blocks): done: ~, P6 C+ G3 f0 b. I
    Writing superblocks and filesystem accounting information: done' L' f2 ?% G3 h9 u! ^3 e
    This filesystem will be automatically checked every 30 mounts or; ]) i1 l7 i$ ]# L2 M
    180 days, whichever comes first.  Use tune2fs -c or -i to override., u& \- c8 j/ ], {- A% D
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 h5 l9 C5 O: K6 F4 B+ v    /dev/sda3              3723848    705992   2828692  20% /, N! C+ m7 ]: W* ~7 i: c% p3 x
    /dev/sda1               101089      9274     86596  10% /boot
5 _$ F1 {/ H, R2 S. d    none                     14520         0     14520   0% /dev/shm0 ^9 m, P* e, g4 i
    //挂上新分区
; n  Y* a$ @6 ^
  1. mount /dev/hda1 /home
    0 F! F: X9 L1 ?5 }: x' L$ O# w( n; T
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点* W5 Q& E, V' e  P2 T( ?
    /dev/sda3              3723848    705992   2828692  20% /+ v- \/ k8 `* M
    /dev/sda1               101089      9274     86596  10% /boot
& V" Q; G* }. L: W( w    none                     14520         0     14520   0% /dev/shm
0 `5 ~8 N$ y( T/ ~    /dev/hda1               488006      8239    454569   2% /home
9 e1 n* a1 ^2 d$ n: i; r! ^
. @/ L7 X1 k0 {! A& o自动挂载:* O- g- G. J0 F0 z' b  d
  1.           vi /etc/fstab7 g# V; i+ o- A5 s6 N

  2. % N2 M& e$ h/ ^8 f) S# W! M) |
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 06 r/ l! B6 R+ U7 x

  4. ) m3 |$ L3 `4 l+ }2 W
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
) x3 d& `6 I: }: _
  1.           mount /dev/sdb5 /mnt/ljp13 E) q) r# s( w; X( x# E2 V
  2. / O3 `& ?" D! B" K# i
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
+ l! _* X$ A% W+ C9 q( a' r
1 v+ Q8 Q; G4 e' d+ Q# D

$ j; b0 ~9 v) \! S" h6 x% P
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-24 15:49 , Processed in 0.018490 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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