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

 找回密码
 立即注册
查看: 2611|回复: 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)
  s" r% x3 H, n5 @' J      or: fdisk /dev/sdc  (for the third SCSI disk)
1 c) _% A; x1 ^% N1 l9 {0 m      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
/ m* ]5 f1 {: y5 L' z1 ^0 x      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
2 T, D  \9 k" {. g4 n3 e      ...
; @" h% E  {& t8 m, S
  1. df -k0 q# l( I# Y, G/ O
  2. df -lh
    8 Z4 D  n7 ]! y5 j  z
  3. 查看有几块硬盘:fdisk -l
    $ Y/ O  D# D8 h" D4 _0 }
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点8 Y6 K( ?2 d2 U
    /dev/sda3              3723848    705968   2828716  20% /
5 N$ U4 G+ m  i+ e! N6 V1 x+ R    /dev/sda1               101089      9274     86596  10% /boot
9 \; ]! s  a# q3 A4 c. L    none                     14520         0     14520   0% /dev/shm$ x8 k/ p9 k8 R3 U/ @, @' M
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
+ K0 |# _5 \% g- r8 ^+ x
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel- A8 D- s# N% G- l) X/ o( H" \( O' F
    Building a new DOS disklabel. Changes will remain in memory only,: [' j( o) \4 d0 [
    until you decide to write them. After that, of course, the previous& y% F2 ?, w$ U3 V) g) [
    content won't be recoverable.0 o/ \3 x% Y9 N  u8 D
    The number of cylinders for this disk is set to 8322.2 k0 C% U$ I; I7 r1 {
    There is nothing wrong with that, but this is larger than 1024,* p9 c2 t2 o* C
    and could in certain setups cause problems with:. N, q0 X# d( r
    1) software that runs at boot time (e.g., old versions of LILO)
1 `; ~+ s8 C( q" j! |$ {9 v: P9 f    2) booting and partitioning software from other OSs- M1 w4 R" J# q% G
       (e.g., DOS FDISK, OS/2 FDISK)1 N/ x9 w$ J8 K- J2 R, [, C5 h
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)- [! k+ k: B+ w
    Command (m for help): p
) f* c" _! J5 `* W    Disk /dev/hda: 4294 MB, 4294967296 bytes8 J& B3 I5 O# V, h- l
    16 heads, 63 sectors/track, 8322 cylinders+ H7 r; `0 E8 U  v- m  T
    Units = cylinders of 1008 * 512 = 516096 bytes! c' c2 L% R- |0 W* z5 K( o
       Device Boot    Start       End    Blocks   Id  System
" J6 A8 [, @$ y3 c( t2 l    Command (m for help): m
& p, x3 s& C4 j$ w# ^    Command action
5 \! Z/ o+ U7 x* e       a   toggle a bootable flag" K: O1 i$ n7 R0 d2 `) a, X7 ]
       b   edit bsd disklabel
6 q: g% N2 ]. k  W" J( d: r       c   toggle the dos compatibility flag5 X* k% o% @% G! g! P$ r
       d   delete a partition
$ v  v% d; V; a3 i5 z; Q       l   list known partition types7 s0 u" v9 Z) u$ x; }6 u8 @" O
       m   print this menu, @$ B! @& Z: G& S7 Q' C- @4 v
       n   add a new partition* {! O' b1 g7 E& U( m# ]- r
       o   create a new empty DOS partition table
% D1 _$ I" ?: o7 A       p   print the partition table
8 |# ^  \5 [% Q! t, W$ v       q   quit without saving changes% S* O1 u" a7 U" Z7 M) t) f( V7 Q
       s   create a new empty Sun disklabel
+ |) G" I3 H' n% }       t   change a partition's system id* u0 U/ X/ E2 }( d
       u   change display/entry units0 F! x: X9 i7 A' P( [
       v   verify the partition table( Z$ P0 S8 ]1 p3 K- E
       w   write table to disk and exit
! c& s# Q" N' H       x   extra functionality (experts only)
6 U5 ?6 ]& A! S    Command (m for help): n
/ t! Z+ \0 }, A  u6 |/ {    Command action
/ i* i+ B" c$ P* z- }       e   extended
' ?5 o9 y2 x. W5 l+ }       p   primary partition (1-4)8 W+ R. p& n) j) F! k
    p9 p* G6 V# A8 C& w
    Partition number (1-4): 1
0 [& _  Q8 y  B2 Y/ ^/ K    First cylinder (1-8322, default 1):
5 @! Z1 }- x0 U$ q5 n2 c. O    Using default value 1
; e" _$ J4 s( X) M, {# w" X2 ^( C    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G: l: Q% A$ e& @7 ^
    Command (m for help): p; I9 v! j+ A5 ~
    Disk /dev/hda: 4294 MB, 4294967296 bytes+ E+ \; s3 X' ~; o
    16 heads, 63 sectors/track, 8322 cylinders
5 R1 i; w  o- S$ O/ }. w- X$ q, \, Q6 C/ p    Units = cylinders of 1008 * 512 = 516096 bytes0 M: Y5 A; Y8 T- s9 ?2 u; h
       Device Boot    Start       End    Blocks   Id  System5 v% Q4 C/ N' ^8 b" a
    /dev/hda1             1      1000    503968+  83  Linux
7 m/ O3 m! r$ y5 t    Command (m for help): w- q& {8 i$ k$ h) u
    The partition table has been altered!; I+ Y: m$ r2 q5 K( V. E
    Calling ioctl() to re-read partition table.; r1 U/ @# b+ j: g" \' T& M
    Syncing disks.5 t5 t5 d8 ]& u$ M, E* N7 X, N& E
    //格式化新分区
$ \# P0 R8 G$ |& B' \0 X
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)$ i2 A# c+ t+ l, l% _
    Filesystem label=# x; V7 v4 Q0 w# H) B9 {3 ?6 }7 c  d
    OS type: Linux
$ @# d1 g! i/ P& w5 Z1 d    Block size=1024 (log=0)2 C7 ^% u( X8 K8 S' n
    Fragment size=1024 (log=0)
- ?: {0 ~2 `  s. Y" M$ n    126480 inodes, 503968 blocks
0 x( h6 o5 E' W- Y7 c* G1 i' P    25198 blocks (5.00%) reserved for the super user- R$ ]- D2 k, E. w) w; r' p+ C
    First data block=1) W+ H" W' q: w
    62 block groups
; J$ P% R- D* c% b$ V    8192 blocks per group, 8192 fragments per group
9 F& o2 L0 B. a* }0 s0 w    2040 inodes per group5 K0 ]2 x$ s/ m: ~6 \, s% a! S3 @
    Superblock backups stored on blocks:
, D: u. @& T- V6 W            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
" B  W, Y/ R5 Q4 p5 k/ E0 g  T    Writing inode tables: done                            9 T5 W4 v8 Z& V1 r0 o+ Q
    Creating journal (8192 blocks): done6 O1 p3 A" O/ @# ^+ h( G8 i
    Writing superblocks and filesystem accounting information: done
! W7 k# i- t# ^1 {; _$ z6 s    This filesystem will be automatically checked every 30 mounts or
8 o+ K7 w4 R) F! a. S    180 days, whichever comes first.  Use tune2fs -c or -i to override.$ L! [3 W) i" G. q8 Y8 E
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  _. i" r1 [; H  u# j
    /dev/sda3              3723848    705992   2828692  20% /- x2 j3 A1 H/ g% L; N; {+ M
    /dev/sda1               101089      9274     86596  10% /boot
( @+ h4 ]9 R) R0 V/ n    none                     14520         0     14520   0% /dev/shm9 N& k& [" {: t7 ?4 Y
    //挂上新分区; L5 W% n9 p7 y  a
  1. mount /dev/hda1 /home! Q1 U9 P+ J, C, H/ e% {) [) l, i
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- @& G; A7 ]! W8 z1 ~
    /dev/sda3              3723848    705992   2828692  20% /
  ^  L+ g' z9 X# W, u& y    /dev/sda1               101089      9274     86596  10% /boot: O% j/ y+ I7 H( d3 Q4 k6 \
    none                     14520         0     14520   0% /dev/shm
' ~/ N' `- c4 q& _. w# e3 |% W    /dev/hda1               488006      8239    454569   2% /home2 G' L* z/ e" l3 W0 C
7 V$ s  B& ]* p) m# c2 c# ?/ z. k0 a2 z
自动挂载:
' u* p2 e) l. G" t% H4 e$ O
  1.           vi /etc/fstab! g! \9 u( X1 B' [! v6 b6 i
  2. 9 d& ~) L" B% L0 u" v6 h/ |
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 _$ ]5 k1 T7 w! l9 \
  4. " m. u; H, ^* k$ h6 K8 m
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:* I" w! I, `* {" R; d
  1.           mount /dev/sdb5 /mnt/ljp1/ V3 H1 m2 Q6 S' m- ~8 C2 D
  2. " Z; ]6 }) m& v/ Q1 w
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

# `6 \& a8 N: X# t- b$ |9 E
% r; ^2 d- S  q6 [* I& W1 G# `- t( P7 G; u
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-29 07:40 , Processed in 0.014360 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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