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

 找回密码
 立即注册
查看: 2768|回复: 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)
, d0 u0 `) T4 r2 D      or: fdisk /dev/sdc  (for the third SCSI disk)
) t+ L4 ~, C1 Q3 c3 h6 |& y/ _      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
' h, t9 ]. i# g2 [6 b      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)7 {/ t1 P% Y2 z, W- u  G1 |
      ...0 z7 W8 y. V+ T5 h0 v
  1. df -k. ?$ P- @. C. F2 x7 V' V; g
  2. df -lh
    2 Z! {4 R2 E6 z- u
  3. 查看有几块硬盘:fdisk -l
    8 ?2 B4 K8 M$ C% }1 X  l3 X/ i
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% g0 T, h! \. d3 g& f; o    /dev/sda3              3723848    705968   2828716  20% /7 R3 s& a) p. ?& {4 ~3 N7 O& Q
    /dev/sda1               101089      9274     86596  10% /boot
7 O  K, j+ w6 z0 l% w' f2 f    none                     14520         0     14520   0% /dev/shm" g6 `. X! z+ k: v" }. S% F
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用  P' G9 }) O1 g2 q/ w" z6 p
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
4 x% S$ z0 @; s5 \    Building a new DOS disklabel. Changes will remain in memory only,
' U1 m$ `7 o7 b3 L    until you decide to write them. After that, of course, the previous$ X, G, p" L* d# s! `
    content won't be recoverable.
8 H( u* a; N5 m$ X$ M2 {    The number of cylinders for this disk is set to 8322.1 Z% r. s- Q: S. Z( [% U
    There is nothing wrong with that, but this is larger than 1024," s* d3 o4 k5 c5 V1 k! j
    and could in certain setups cause problems with:
5 F; ?6 n1 C2 r* k5 j    1) software that runs at boot time (e.g., old versions of LILO)
  Y. u/ v: J: n    2) booting and partitioning software from other OSs
$ Z& j1 x# n- G       (e.g., DOS FDISK, OS/2 FDISK): @* j) M" }% H! t3 `: L
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
# M9 Q' O) ]' h, m. Z    Command (m for help): p5 f8 E8 B, U6 Z- Z
    Disk /dev/hda: 4294 MB, 4294967296 bytes7 R' i" C* R: w2 ^
    16 heads, 63 sectors/track, 8322 cylinders, x* Y; D0 x. c  k
    Units = cylinders of 1008 * 512 = 516096 bytes
- p- d& P- L( R- @       Device Boot    Start       End    Blocks   Id  System
. c# C; M, r2 M. ^. V7 W    Command (m for help): m3 a/ L; t% n* K* m: y, _1 L/ X
    Command action
3 ]1 i$ ]& A( b( c5 u       a   toggle a bootable flag0 ]9 Q( w! A* @! l2 \; s3 M
       b   edit bsd disklabel4 H/ Z4 o( B# _. n" \8 D$ k
       c   toggle the dos compatibility flag% k/ Z8 S/ M$ [3 H7 t( W; E
       d   delete a partition
; Z% J$ e5 `0 o* D0 s       l   list known partition types
8 f. ^9 D3 h. w1 s# K8 @       m   print this menu
' s6 v& o5 m9 W       n   add a new partition
  L! S' J; h- \       o   create a new empty DOS partition table: A0 |6 B5 R! e) p1 k$ G. L0 `' g
       p   print the partition table
  d& {- z# k1 ?4 _       q   quit without saving changes' m' @. _  b6 }1 ]6 E4 `
       s   create a new empty Sun disklabel
6 g. z, j% ^2 ?7 c* h       t   change a partition's system id
$ v- }) M8 Y* d       u   change display/entry units
0 t' F1 c$ u- l2 O$ n/ p; q       v   verify the partition table
- L9 {1 ]; U2 M+ p+ F       w   write table to disk and exit
6 y; R9 Y+ ?! ?: P. s       x   extra functionality (experts only)# s' Z  `0 W5 ~' x
    Command (m for help): n; [$ U: i# H: r
    Command action. x" ?, P7 V  m
       e   extended0 z, e" @/ o$ u/ E" ?4 N. ]
       p   primary partition (1-4)
$ \8 \% _- }6 V    p+ j* k. b8 Z! h7 ]& m
    Partition number (1-4): 1
# h; j9 y7 |* c5 @; e+ {( _    First cylinder (1-8322, default 1):
- \; Q; ~+ j+ y    Using default value 1
; u# A( c# B7 p2 f  o# G: ~% d! p    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
3 N+ m* F$ |) ?& G7 v9 @1 D    Command (m for help): p: i4 q( V* d6 G; y; ~
    Disk /dev/hda: 4294 MB, 4294967296 bytes
, t7 c, r( ~, ~9 h6 H- ?. G    16 heads, 63 sectors/track, 8322 cylinders
" n* M# t+ s& q' W: T/ v/ ~6 Y    Units = cylinders of 1008 * 512 = 516096 bytes. e9 W! ^; j% N- b+ N
       Device Boot    Start       End    Blocks   Id  System* c9 f$ G; i' i
    /dev/hda1             1      1000    503968+  83  Linux, g" q  U( c" l* i
    Command (m for help): w
1 n( `* Z, ~- W2 H3 ^) H- r. B+ ?) q2 g    The partition table has been altered!
, u0 D9 y  R! l8 ?    Calling ioctl() to re-read partition table.
. o2 M# R3 ^6 O* Q    Syncing disks.
' W& @4 D. |9 O$ b, N    //格式化新分区$ [6 m3 h; ~% y; V( K
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
$ P% c$ ~0 S  z    Filesystem label=
2 b$ j. F  M# a( n& P% [" h' Z    OS type: Linux$ O9 V& h  S) j& D7 }4 S
    Block size=1024 (log=0)1 J7 b0 K6 R0 B
    Fragment size=1024 (log=0)! F+ C0 g# m' v: g. h
    126480 inodes, 503968 blocks
; {$ E3 F' R3 c& F9 x2 A  Y    25198 blocks (5.00%) reserved for the super user* D5 z' w0 R" F+ X" _8 k
    First data block=1
' P% O+ \& H0 N  Q) C    62 block groups/ @: R' }0 Q5 ~/ R8 C$ ?) \
    8192 blocks per group, 8192 fragments per group
/ f% ~9 Q4 z* a    2040 inodes per group9 g9 j# R6 r$ a: i; c2 U% \
    Superblock backups stored on blocks:
. d- s) x3 g5 Y7 w4 j            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014099 T* s8 X/ L3 y9 T  |9 U1 U
    Writing inode tables: done                           
1 S( ]2 ^: s5 Y1 k    Creating journal (8192 blocks): done. Q% Z4 v6 S1 G& z: D0 a
    Writing superblocks and filesystem accounting information: done) m- U+ g+ o9 N, f2 v' F; J! x
    This filesystem will be automatically checked every 30 mounts or$ D& o( ], ^% @% f
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
: j3 p# ?% ^: h% {( f) c
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 `2 X  p$ m) ?; [. R4 C1 N
    /dev/sda3              3723848    705992   2828692  20% /
: [* |8 f4 l* t( `7 k. o, Y2 A    /dev/sda1               101089      9274     86596  10% /boot
, X9 \" l0 {. S    none                     14520         0     14520   0% /dev/shm
( M; G9 e( B8 P' m' @; O; t    //挂上新分区
) [! J+ R3 k' g
  1. mount /dev/hda1 /home% L' F! s( b' y1 P1 k
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
( ^* C7 _1 T! s8 q7 e2 ~# l" \    /dev/sda3              3723848    705992   2828692  20% /
0 b6 j; G+ }+ J! r' G$ u    /dev/sda1               101089      9274     86596  10% /boot
. g- `9 [) H) o6 b/ R; a    none                     14520         0     14520   0% /dev/shm
0 r/ |" ^! u. x. w* D    /dev/hda1               488006      8239    454569   2% /home5 n+ E1 N1 M/ v

) N4 Z& b' S/ B自动挂载:
) m% H' t+ f6 o  ^. S% p
  1.           vi /etc/fstab
    " e1 i; l" s* w$ m

  2. 1 v% T. k: T: |
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    ! C* l& m. p0 Z! z6 k

  4. 3 m# S0 j% Q% @# {4 Z* X
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:4 k1 Y% d8 q) W
  1.           mount /dev/sdb5 /mnt/ljp1
    . {* b: |& I$ a

  2. 4 b$ `: E, i- V" I
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
" M" F! H! \, K- g0 o
2 m2 |4 k9 H+ s

; [2 U7 H3 F& g3 W
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-12 08:35 , Processed in 0.014413 second(s), 10 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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