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

 找回密码
 立即注册
查看: 2711|回复: 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)
% Q' p# [2 ]! D      or: fdisk /dev/sdc  (for the third SCSI disk)6 ?$ W" r, ?1 ^, D- N7 G
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
9 y$ q+ L5 q( ?# I% E      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)! W  ~* ~6 g1 q
      ...
0 u" M8 J3 r0 P- O
  1. df -k' M3 c5 j$ ~0 e9 Q: M* K
  2. df -lh* j, ^9 Z! U' c4 h
  3. 查看有几块硬盘:fdisk -l/ B/ V% h$ P# }6 f6 K
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点! a7 c; ]& S  t4 S5 }& w: R
    /dev/sda3              3723848    705968   2828716  20% /
& v6 C  d5 X8 v    /dev/sda1               101089      9274     86596  10% /boot
9 I* S$ m& X- G    none                     14520         0     14520   0% /dev/shm
/ E+ ^, O: Z9 Q    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用) p$ w; R: X3 G0 m7 x7 w+ F0 s
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
0 Y; t7 J/ r5 e7 s8 T    Building a new DOS disklabel. Changes will remain in memory only,
- S! @# m, U$ l: L/ C3 |    until you decide to write them. After that, of course, the previous# [* L# B# `) L* q! s* Y
    content won't be recoverable.
; L& G5 d6 |/ S0 ^$ U    The number of cylinders for this disk is set to 8322.! B# ^) {5 b2 z  u
    There is nothing wrong with that, but this is larger than 1024,
  R9 v8 ?1 k+ @+ H1 ^/ ]    and could in certain setups cause problems with:7 p: q+ _! u& @* Y$ _7 D
    1) software that runs at boot time (e.g., old versions of LILO)
* K* k* x8 j* j1 X3 w: N    2) booting and partitioning software from other OSs' H* U1 P8 p$ X  ^( ?. v) e7 M
       (e.g., DOS FDISK, OS/2 FDISK)
2 O' Z( `/ p; B2 x5 W    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite), ~5 O9 K6 K+ X, `( s
    Command (m for help): p' {) c) A6 d2 H& R" u7 E. P
    Disk /dev/hda: 4294 MB, 4294967296 bytes) ^' E7 I9 l4 G2 K6 {8 N& G
    16 heads, 63 sectors/track, 8322 cylinders
# l4 Y! @5 K, f* x& m9 Q  M    Units = cylinders of 1008 * 512 = 516096 bytes7 [. V: h3 R% W
       Device Boot    Start       End    Blocks   Id  System
7 {! {8 W5 Z& n6 W* {8 `    Command (m for help): m! y; p8 }1 G7 X1 p4 ?
    Command action
/ N0 n- G3 n% M/ [5 y3 H( z       a   toggle a bootable flag# M$ K% S  k+ [. @! ?
       b   edit bsd disklabel
% h  @5 j2 R  @1 c1 [       c   toggle the dos compatibility flag6 A+ N8 C. M+ h% T$ q9 V
       d   delete a partition) X0 B: z: i+ H. H
       l   list known partition types9 [  {" L. m# D; B. d
       m   print this menu
/ E7 D0 p9 r# M7 R7 a* Q       n   add a new partition$ ^2 J: r4 j  Z' @1 i$ S! o5 u
       o   create a new empty DOS partition table
3 r# K' N) @4 z) U* R8 r5 A: p2 _       p   print the partition table6 A) \) V' S7 M( n1 [
       q   quit without saving changes- J; |3 O) z4 q5 K  d3 [, J( X- V& u
       s   create a new empty Sun disklabel! a6 u' a% y" a% G
       t   change a partition's system id
$ W, e" N/ ~2 n  h       u   change display/entry units
2 F1 p* h0 p3 D4 e# L) n* c! O       v   verify the partition table6 L" V* C8 o8 B8 ~7 T, o
       w   write table to disk and exit7 n$ U2 ]$ S, J. e  E) }; H9 R2 n
       x   extra functionality (experts only)% n( r# {' j8 o( g4 w2 h$ K2 F/ K
    Command (m for help): n
) r  r( d2 f5 O4 Y+ J    Command action, R0 F  Z, X* G+ B, K# \* @
       e   extended+ Y- X' I3 c$ Y$ l, j0 A( C$ w
       p   primary partition (1-4)( G: k- |: `  O8 h6 F
    p  @! c" e$ @! ?4 }0 w6 ?- _
    Partition number (1-4): 1
, H1 Y- h' [- U! H! n3 t, ~    First cylinder (1-8322, default 1): . s# l3 k6 C- H/ R
    Using default value 1' w# z# A9 l! X# ?
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
0 r  u4 c# f0 a. e. ^9 K* A: f0 d    Command (m for help): p
" S- h6 |5 X3 i2 h& q    Disk /dev/hda: 4294 MB, 4294967296 bytes( h) J3 v7 U6 d% ^! r' X2 G
    16 heads, 63 sectors/track, 8322 cylinders
( _' d0 B. q) ~1 _1 B) \    Units = cylinders of 1008 * 512 = 516096 bytes% _  C6 g0 G7 _1 N" ~% [' o0 {
       Device Boot    Start       End    Blocks   Id  System* p1 q; t3 u) k) F# j- a
    /dev/hda1             1      1000    503968+  83  Linux
. o! P3 [. }1 @0 `( X    Command (m for help): w
( r+ q0 Q2 q3 H  E7 ~5 o0 N, K    The partition table has been altered!3 c, I; X. H9 D3 O$ I- h+ N  W; Y
    Calling ioctl() to re-read partition table.
1 g: u. N' i5 w" |    Syncing disks.
# g) Q; g8 v; o    //格式化新分区
) O( ?/ ^7 x' z7 @
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
2 N9 N# k  n" d8 Q    Filesystem label=# {9 z% o3 y; h( t$ k- n" j2 I$ k6 v
    OS type: Linux2 E- g! B  m( J1 @6 P
    Block size=1024 (log=0)
" \) ?/ i: h  Y' ^; J    Fragment size=1024 (log=0); b. Z* T( m  [0 C& v+ e% g9 K& }
    126480 inodes, 503968 blocks
& Z8 H7 @$ g6 @* y1 |    25198 blocks (5.00%) reserved for the super user
' a8 |; B2 e/ n  c    First data block=1
6 _3 n5 E! ^% P* S3 D    62 block groups9 {2 ]* b# l* ^8 Z( N
    8192 blocks per group, 8192 fragments per group5 m5 u6 H3 s& _# K. d
    2040 inodes per group
+ |( O% y7 @9 |: O2 }5 D0 g    Superblock backups stored on blocks: 2 E7 ~( I& z$ y1 z# H4 `$ C
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- i" Z# P! F% k' z    Writing inode tables: done                            1 f0 Y" K6 ^# \+ [9 C5 Q+ y7 n# n
    Creating journal (8192 blocks): done
" M) ^. c  O4 O- e; P    Writing superblocks and filesystem accounting information: done; c/ T2 G1 s, q
    This filesystem will be automatically checked every 30 mounts or1 A  k5 p# K9 |5 F
    180 days, whichever comes first.  Use tune2fs -c or -i to override.6 f8 V8 X1 @. o$ d8 E" S
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  J3 `( P6 h: m
    /dev/sda3              3723848    705992   2828692  20% /
! Q4 h/ `* f0 x: z9 C    /dev/sda1               101089      9274     86596  10% /boot- z4 r# m, q0 O& [5 b/ t
    none                     14520         0     14520   0% /dev/shm
1 k* ~* a/ x$ _# f4 z    //挂上新分区
% v3 c+ y% u' e  }. s% _0 M
  1. mount /dev/hda1 /home
    1 {; Q% X9 D9 n; |7 x7 d+ p0 A5 c0 b
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
1 i, S, B. g2 u* D    /dev/sda3              3723848    705992   2828692  20% /" C/ g! n# y1 u( P4 t/ r/ c
    /dev/sda1               101089      9274     86596  10% /boot
: a/ H, F1 i  ~1 a9 j& Z! }    none                     14520         0     14520   0% /dev/shm- R/ Z3 n8 P4 K, y& m  A
    /dev/hda1               488006      8239    454569   2% /home7 M0 Y; R& d+ ~5 J0 {* {3 B* z$ ^

3 \2 ], d7 m2 c# W自动挂载:
1 F# P% q" ]$ Q" _& R; C
  1.           vi /etc/fstab9 T/ q  j1 `: m) Y* m. t+ z
  2. + V) @7 t7 n# u
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 08 H# l% S7 \. O$ Z

  4. & u/ v; R7 w! a- N
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
; Z8 X! f" K8 t5 t* e% J7 j
  1.           mount /dev/sdb5 /mnt/ljp1
      d8 q( Y* x0 @. [; [& t. U

  2. , @. J3 m! m- u5 d* \- J! A& C7 {
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

# ?: j9 S/ P  Z2 I* U. Z: `& o) _- @1 A3 I3 ]+ b# `( H, b

% U1 h, H& s+ z
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-26 22:55 , Processed in 0.029695 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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