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

 找回密码
 立即注册
查看: 2665|回复: 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)% Z2 t" h8 w/ ^" E- A8 A* Q
      or: fdisk /dev/sdc  (for the third SCSI disk)# u6 I9 R  e/ d: R- q2 ?6 D- i6 B
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
  s: T; n6 N0 P3 z      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
0 ]( ]/ U. |! R/ c7 ^      ...
) |" ]% C3 v  d5 c2 V
  1. df -k
    7 d8 `4 |& o6 j
  2. df -lh# `: |7 i" E. n2 y1 t1 n5 G# O# B
  3. 查看有几块硬盘:fdisk -l5 x9 \: n4 j, @" e5 k# E
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
- f9 M1 [& Q$ c( P    /dev/sda3              3723848    705968   2828716  20% /
2 H; |0 q6 k# y. {7 D    /dev/sda1               101089      9274     86596  10% /boot
1 U& s4 V: G( w: e# C0 m* M    none                     14520         0     14520   0% /dev/shm) q0 j& C4 r+ K$ M8 n
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
) X2 P4 U9 Q9 U+ `6 T
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel1 J# }% k" K" C! M$ E
    Building a new DOS disklabel. Changes will remain in memory only,5 [6 {1 H% v: C
    until you decide to write them. After that, of course, the previous
# y: o! }0 r+ z: d4 B' Y. J    content won't be recoverable.
+ m% [6 i" o% h! G    The number of cylinders for this disk is set to 8322.  w9 M7 C/ x8 w( D; ]1 X& M# ]
    There is nothing wrong with that, but this is larger than 1024,
% y0 O( a6 @; E    and could in certain setups cause problems with:" B  O- W6 O) b  r( M6 r5 y
    1) software that runs at boot time (e.g., old versions of LILO)
1 e3 X4 P. C4 ~# ?    2) booting and partitioning software from other OSs
0 `# U& M" x8 `& m+ B6 c# P0 \       (e.g., DOS FDISK, OS/2 FDISK)# t: Y4 c& r4 J* e; L1 H
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)2 F$ D5 C! }# E( K+ p
    Command (m for help): p: e$ o: S9 [  E+ U& H2 A; {( q
    Disk /dev/hda: 4294 MB, 4294967296 bytes
$ ^) v1 x" @2 s- \5 n7 p# m    16 heads, 63 sectors/track, 8322 cylinders. W5 ?% \+ I3 V) o% M; E0 |( m! k
    Units = cylinders of 1008 * 512 = 516096 bytes1 r$ X) {3 }2 |+ N
       Device Boot    Start       End    Blocks   Id  System
( s, a5 ]* g! _; Q& x/ R% @) \    Command (m for help): m1 S8 {: _, r" l7 m
    Command action
+ j9 v4 E. s: H+ j2 i0 w! `1 ]" s       a   toggle a bootable flag
2 m8 w. H2 L) n- C/ [       b   edit bsd disklabel. {. h& p6 ]) K
       c   toggle the dos compatibility flag) ]) M  r) k; a/ c; F
       d   delete a partition' @% ?8 U5 ]; G0 @; Z6 Q* _
       l   list known partition types
# e4 V- G0 J( P5 z: C       m   print this menu
6 V% D& c1 g: K% X, c# u( g! P       n   add a new partition
# \: z, A' _4 D) @6 [       o   create a new empty DOS partition table
6 R$ p# T' r$ g; d) D8 s       p   print the partition table5 ^: c5 _! I* I7 B  K
       q   quit without saving changes0 r/ ?0 q7 J: A% u, N2 U
       s   create a new empty Sun disklabel
7 k, T) i! y1 D$ j       t   change a partition's system id9 ?1 Q* I$ z2 Q
       u   change display/entry units( @) X& J, f2 b: D5 n: U$ x/ O! N
       v   verify the partition table' b, v! |. H+ A1 @9 j. V
       w   write table to disk and exit. T; P- [# i( Y, A; n' V, m% _
       x   extra functionality (experts only)
, |6 d2 _4 R6 B4 h  X) Y8 L7 ]% S: l    Command (m for help): n" t! n- Z8 s& A% t
    Command action1 k9 L9 s6 |# C2 \, A1 R
       e   extended0 K0 [4 f& G) ~7 [3 ^, b
       p   primary partition (1-4)# L& w) V9 Y4 @; T/ @# K: S* s4 ^' S8 N
    p
$ K7 \9 |: [$ u    Partition number (1-4): 1
, J# W% p4 a5 v2 L- z    First cylinder (1-8322, default 1):   ~* m) t/ u9 a
    Using default value 14 O! {/ l& |7 Q; U- l: c
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G+ s4 p7 _2 q5 K% m
    Command (m for help): p
4 }1 Z& |4 ~, s) M6 X    Disk /dev/hda: 4294 MB, 4294967296 bytes
! S' g5 j- g0 Z- W    16 heads, 63 sectors/track, 8322 cylinders
8 w! G' r; g# i    Units = cylinders of 1008 * 512 = 516096 bytes5 d$ E- _9 q, m# y
       Device Boot    Start       End    Blocks   Id  System
+ G9 H9 N- }' z( x    /dev/hda1             1      1000    503968+  83  Linux, H, Z% a/ Z4 s) h
    Command (m for help): w- N1 ^6 E9 V: A
    The partition table has been altered!5 A& e" k* e, N- x2 H6 k
    Calling ioctl() to re-read partition table.! [9 ~; Q& \' {; R- R
    Syncing disks.( a1 N; G1 G+ `! ]4 R+ X1 I/ P
    //格式化新分区
( h+ f( W, {) J# [
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
) Q) G1 r8 C5 D/ E    Filesystem label=) Q8 X3 R# d+ b$ y
    OS type: Linux1 L# d8 |+ I4 x* X6 s
    Block size=1024 (log=0)' W$ V) P, g% u
    Fragment size=1024 (log=0)
8 Q3 ]$ R; q# d! H    126480 inodes, 503968 blocks
: ~4 z6 B- k2 L" x1 J9 \$ f    25198 blocks (5.00%) reserved for the super user# K2 \6 s  @/ p) `) ]
    First data block=1: g7 g" m2 E( Y4 N5 F) F* m
    62 block groups/ z) `% K: s/ C$ z  y
    8192 blocks per group, 8192 fragments per group4 B) p: q! w& ]0 R
    2040 inodes per group' J# q, R- e- R3 S. i+ j  e
    Superblock backups stored on blocks:
  C+ N; D6 p( ^5 i0 {            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
5 o: z7 a; j+ P5 ]! p    Writing inode tables: done                           
. e0 ]  s3 C* H1 [% i: d4 ?    Creating journal (8192 blocks): done
, i( f  f; F1 `8 r    Writing superblocks and filesystem accounting information: done2 b( k. F  U6 A
    This filesystem will be automatically checked every 30 mounts or
6 ?8 z5 I, `/ k6 X; ^- a7 U    180 days, whichever comes first.  Use tune2fs -c or -i to override.
/ E; _0 e+ m; C+ }* S& i4 F
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点9 v6 C5 a/ a5 d9 G. x" G
    /dev/sda3              3723848    705992   2828692  20% /* [" }/ _6 o; ~5 O8 ^
    /dev/sda1               101089      9274     86596  10% /boot
* C0 Z/ M7 c: v8 h    none                     14520         0     14520   0% /dev/shm
, m, l2 G6 m# u: ~5 U8 u( ~  C* b2 g6 B: i    //挂上新分区+ w, l) L( q" x  G* l% M
  1. mount /dev/hda1 /home$ b8 C: y: n9 K7 P7 V, S
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点: k' F( v, N! y: C# z! S& ~
    /dev/sda3              3723848    705992   2828692  20% /
' S9 W  l; `9 i# S) _, ~3 M    /dev/sda1               101089      9274     86596  10% /boot
" c2 ~3 [. E7 U1 R2 P, n' e    none                     14520         0     14520   0% /dev/shm
1 a7 U+ l" E! u    /dev/hda1               488006      8239    454569   2% /home
: a5 Z" y" U' `
! r  f3 s5 E# T5 p8 J自动挂载:& W: d1 a( t6 ~2 M: D& E
  1.           vi /etc/fstab
    / T0 ]6 d+ [+ \
  2. 7 k! n$ M' r1 n* Y
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0' @, K! a& b9 \# d9 x( G2 J1 U

  4. : O$ T, l' D3 k  y/ ~8 S
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
; G2 C: h* U- u
  1.           mount /dev/sdb5 /mnt/ljp1
    9 s# v9 j1 H) q
  2. % F! L# L& K# v! M0 {  v
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
* c+ u8 R1 R7 n" z& c2 b2 x4 S- G

9 s/ K: B( F6 F! w+ [' {0 m# t& J6 p7 K+ k4 I0 c
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-10 18:52 , Processed in 0.013787 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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