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

 找回密码
 立即注册
查看: 2622|回复: 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)5 L9 w4 U+ q; z$ F) Y# d% d) P; S
      or: fdisk /dev/sdc  (for the third SCSI disk)
% ?; j2 P' b( U) X0 q- l  C      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
4 _  ^7 g& ~7 U      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices): |; G* e2 w8 ?
      .../ B! i% n0 ~! r4 Z# x
  1. df -k
    % f; Q8 m; \3 \' I% H+ L
  2. df -lh
    6 R& Q% U* C8 f
  3. 查看有几块硬盘:fdisk -l. u$ i. o3 C/ S; A3 Q# @6 D% z
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
, k1 f" K& ]# d3 j& F9 X    /dev/sda3              3723848    705968   2828716  20% /
9 d3 |; O9 j" C& M& ?& ]8 L) t    /dev/sda1               101089      9274     86596  10% /boot
$ }( F9 _1 @  r( G! H& n    none                     14520         0     14520   0% /dev/shm6 [4 u! d2 i0 w6 e* C
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
. U9 ~8 T/ c- g6 ?  N+ V; }
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel* c4 [! e$ \+ Q
    Building a new DOS disklabel. Changes will remain in memory only,
) j/ B, D+ U3 L( C( J- P    until you decide to write them. After that, of course, the previous
1 [1 F& m! W! M1 o    content won't be recoverable.. N* P9 _: K2 T# k
    The number of cylinders for this disk is set to 8322.! K, B, S+ V2 I
    There is nothing wrong with that, but this is larger than 1024,
/ K) o* J0 ^3 b* J) w    and could in certain setups cause problems with:
1 P# M8 K- b2 g# [. q% n- Y    1) software that runs at boot time (e.g., old versions of LILO)' d% c2 ?2 A" j# ^4 `
    2) booting and partitioning software from other OSs
9 m; g- m$ N9 X% C+ Y4 U& V       (e.g., DOS FDISK, OS/2 FDISK)! S) }5 v- V& g2 G
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)5 R& w8 U8 y, }! W8 t
    Command (m for help): p6 @$ {' y1 ]! J7 `
    Disk /dev/hda: 4294 MB, 4294967296 bytes  K' Z5 k* j4 @
    16 heads, 63 sectors/track, 8322 cylinders
7 X" R; }, d& h* Q: B/ y    Units = cylinders of 1008 * 512 = 516096 bytes7 D% Z$ @( u( i+ w
       Device Boot    Start       End    Blocks   Id  System6 F7 E) u! V; y
    Command (m for help): m
# k, a8 O, O9 ]; |, v7 }5 z" w4 ]    Command action& q! s6 N/ @+ K! Z; Q6 S3 Y' h
       a   toggle a bootable flag9 Q# E1 f- P3 P8 I# D
       b   edit bsd disklabel! U2 T+ Y2 }5 Y
       c   toggle the dos compatibility flag3 w. L; C& M2 c5 ~) F
       d   delete a partition
' K/ h2 }: \( @       l   list known partition types
& J# U8 Q. A0 q" C( M       m   print this menu2 c+ z2 `9 h8 q; T$ f& z, J
       n   add a new partition
3 t8 G9 }* W& W+ k5 w6 d+ R       o   create a new empty DOS partition table1 D* p% \* F! a9 ~3 r2 t
       p   print the partition table& d# D& t; ~! e9 Y$ t6 J; w
       q   quit without saving changes
2 @  Q% L* m3 x       s   create a new empty Sun disklabel
% J8 M* b. j/ q       t   change a partition's system id
5 c( W9 m3 o" J, l' P, b9 t* a       u   change display/entry units
2 o/ f1 V6 @! V( Z* P& v       v   verify the partition table1 L4 H$ t' a3 @% `7 z
       w   write table to disk and exit
8 j, X! P+ y3 d4 e/ a, u% L       x   extra functionality (experts only), K! t' u0 n$ x! t0 e* P- w! L
    Command (m for help): n
# N6 g$ y' K+ ]0 F    Command action
* y) `: V' h* l$ p& i) E       e   extended/ s9 w! A3 W- M/ M6 }
       p   primary partition (1-4)3 }$ ^" D3 E; x9 D& Q/ v
    p
# d& B+ A: g/ E4 j4 }; a' q' e    Partition number (1-4): 1
9 k! n5 H, @7 X* U4 _; S! m, v2 S; l    First cylinder (1-8322, default 1):
5 u/ H$ E' y# K' n8 S    Using default value 1" H% o5 A8 L  T6 \6 o3 }
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G1 Z0 j! b, h7 k& y
    Command (m for help): p
* w% a" ]! }$ O; K2 r' o    Disk /dev/hda: 4294 MB, 4294967296 bytes7 s* m/ H* P+ q( q# N- T* b; |3 [
    16 heads, 63 sectors/track, 8322 cylinders; Y% H6 {& V: M3 m
    Units = cylinders of 1008 * 512 = 516096 bytes# P  t: i" d6 ]
       Device Boot    Start       End    Blocks   Id  System
: O4 z/ M# \* e8 T5 g; Z& R1 y/ `    /dev/hda1             1      1000    503968+  83  Linux1 H) I6 O' J' V! M( \& o5 r8 q
    Command (m for help): w
+ b5 {( Q' H! b+ i* M    The partition table has been altered!
' ]+ \( y5 k/ _    Calling ioctl() to re-read partition table.
- [) i+ u' \$ O# [: |    Syncing disks./ Z' U7 P. q7 B% j2 s2 }
    //格式化新分区2 v2 Q0 Y+ I8 W
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)& }3 n0 |: d" h0 f+ I9 D2 ^! b
    Filesystem label=
! G+ u/ u0 [1 o) Q8 N* [    OS type: Linux
- Y: u6 {: s8 i    Block size=1024 (log=0). M& M0 S3 ^/ N$ W: k3 s
    Fragment size=1024 (log=0)8 _5 N7 H' o2 c. @
    126480 inodes, 503968 blocks
" w$ {* X9 U6 ~4 c    25198 blocks (5.00%) reserved for the super user
1 J3 O/ q( x+ N2 O    First data block=1! T9 v' D; w# ^% |
    62 block groups4 q  L! U  f2 P  q) Z, G& k
    8192 blocks per group, 8192 fragments per group
+ D! O4 S+ \& O0 ]9 n/ m2 i: v    2040 inodes per group! Y3 r+ x9 |& ^9 |% c4 O
    Superblock backups stored on blocks: 4 V9 _: q; c0 K" Q- w# q+ A
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409& Q% W) n* H; E+ V( O1 W/ D! R
    Writing inode tables: done                            * U+ B' I  [' D. t. p- k
    Creating journal (8192 blocks): done
! o+ ^3 |7 Q& N' P! o" {    Writing superblocks and filesystem accounting information: done
* u; r1 F1 Z' h3 g% J+ q0 L# M    This filesystem will be automatically checked every 30 mounts or
3 F# ~. L* j% c, m2 O- M1 q; I    180 days, whichever comes first.  Use tune2fs -c or -i to override.
7 P4 f, a9 i. h7 p
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
4 b6 p2 }2 f/ n6 t& s    /dev/sda3              3723848    705992   2828692  20% /  t/ Q4 V  t3 P! [' [1 V5 [8 s- y2 d1 `  J
    /dev/sda1               101089      9274     86596  10% /boot. a: {  k8 O1 T+ q& i, q
    none                     14520         0     14520   0% /dev/shm* ~" }" X: ~' ?7 k) ~! i
    //挂上新分区
+ |' ]' C9 z* T; X2 F5 o
  1. mount /dev/hda1 /home
    ! w2 O+ m* ~  F; r. Z( \; k
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
: o: M3 J; C8 W8 }1 M& @    /dev/sda3              3723848    705992   2828692  20% /
: O6 u% C+ M9 F- u+ k# o7 B    /dev/sda1               101089      9274     86596  10% /boot5 h' F8 A% T$ ~7 L8 E! X
    none                     14520         0     14520   0% /dev/shm
- X9 X. H: ^4 D- x8 x0 Q6 ]: f9 v( I    /dev/hda1               488006      8239    454569   2% /home
3 {3 }. Z3 }0 I; ]! ^- g/ ]0 i6 i4 j0 v( i
自动挂载:
" _' _, T% Q- i* C5 \
  1.           vi /etc/fstab8 ]! a* Q9 ]* H; g. o3 ]

  2. # c' X# K  Q, b8 p. ]" w
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    2 f4 `8 d. X# ?/ n* w: B( E% R
  4. * S; x; D. B; X1 y9 ^4 j; \
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:8 j- k7 v! W: g& M/ Q$ z* c( ~
  1.           mount /dev/sdb5 /mnt/ljp1' g' w9 M: F* D! g: l7 p* L1 N

  2. ! m% ~: `5 g3 n, y! g; z/ J' P6 E
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

! `, u3 B, S  e1 S6 ^' L
: O, ~& D& k, X1 f. K" i+ b# w7 D+ f$ q8 Q5 b* _8 _# t1 p' p) x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-1 16:33 , Processed in 0.019203 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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