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

 找回密码
 立即注册
查看: 2729|回复: 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)
9 p8 j& X6 w9 d) E% P      or: fdisk /dev/sdc  (for the third SCSI disk)) ~- I( k1 }. Q  {, m
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)4 S) t4 r7 s/ c# c" T3 D
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)# [* Z! Q$ `6 p( ^; V/ {" h
      ...' Q; S+ u2 J8 r  u: [$ _9 }1 Y
  1. df -k
    , R8 ]* b! ]1 g* S# N
  2. df -lh
    1 e: |; I# M6 R1 p* }# e' H
  3. 查看有几块硬盘:fdisk -l* X9 q2 ]) ~$ W& R
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% p/ M9 W/ M2 q8 q9 m" X! O' Z
    /dev/sda3              3723848    705968   2828716  20% /
. {9 w: P& ^* H; [- n    /dev/sda1               101089      9274     86596  10% /boot
7 q9 S& ^/ T+ s5 ~4 f    none                     14520         0     14520   0% /dev/shm3 D, W! o7 J4 C
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用/ r7 B/ R# [6 h7 S3 Q
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
2 g; z' t7 ]2 v0 @. }* x, R    Building a new DOS disklabel. Changes will remain in memory only,
9 N: L8 ^+ ?+ B1 i1 F' ~9 R    until you decide to write them. After that, of course, the previous
! _! k; c+ P+ ^) r    content won't be recoverable.: Y' U1 U, U2 s0 S
    The number of cylinders for this disk is set to 8322.
1 ~3 F" U' z  `0 m    There is nothing wrong with that, but this is larger than 1024,
; r8 x+ D$ g; f    and could in certain setups cause problems with:8 _( o5 r% L5 E" s% B5 ^
    1) software that runs at boot time (e.g., old versions of LILO)+ W3 e& Y& H1 [
    2) booting and partitioning software from other OSs, [- l* Y; e, X/ \
       (e.g., DOS FDISK, OS/2 FDISK)
# e* u2 u# v# @5 ]0 |+ Q' b" P% D0 r    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)& z$ s1 F" L4 |# y% a# r
    Command (m for help): p8 `: ^4 H. N# i' b$ M
    Disk /dev/hda: 4294 MB, 4294967296 bytes# l) d. L) F4 v7 C
    16 heads, 63 sectors/track, 8322 cylinders; o% D1 `) r1 h& {
    Units = cylinders of 1008 * 512 = 516096 bytes, h. U/ s4 ~/ J& S7 q$ A; ~
       Device Boot    Start       End    Blocks   Id  System- ^) j% W  K2 p8 }
    Command (m for help): m
: `) u" W! ]8 @- k( x    Command action/ n9 U3 }$ w1 i6 m
       a   toggle a bootable flag
) w0 s1 g1 S. a+ N( S       b   edit bsd disklabel
% ~  ^$ R, U* a# e- |) x, V, u       c   toggle the dos compatibility flag8 K5 ]3 ~: w; }9 T1 R4 L2 ?' x  c" |
       d   delete a partition! ^) J2 n9 w' P+ [6 r) r1 I% x
       l   list known partition types
" v: z6 a  V  h       m   print this menu
/ _' a* Y* i( \9 U       n   add a new partition: G0 M$ B. Q; Y  S' V2 @1 ]. o
       o   create a new empty DOS partition table' f; Y+ \* u: P  H, Q( F
       p   print the partition table
+ p1 m- U3 p6 I) J9 N       q   quit without saving changes
/ h1 W1 U/ V5 v5 H7 {) B       s   create a new empty Sun disklabel0 t% k6 N5 [2 ~+ f2 N
       t   change a partition's system id
! Q5 F( e" e( s3 L! X! C5 o       u   change display/entry units3 t4 G. l* q' J' n; }9 `
       v   verify the partition table  B5 J0 ?' A1 l# A2 {( J
       w   write table to disk and exit
5 `/ a3 v' P" I& i8 E       x   extra functionality (experts only)
( C- `5 @$ x# c% Z    Command (m for help): n
" f% W. X4 i2 H2 v+ @* f$ B    Command action
- j1 @7 F# B$ t/ Q       e   extended
+ \+ [1 o$ [- ]3 m       p   primary partition (1-4)
3 C) C% j3 d1 |. O$ o    p
2 k$ v9 D+ f5 _9 ?; _! P3 M    Partition number (1-4): 1
8 n: a1 n3 ^+ s/ V* t    First cylinder (1-8322, default 1):
9 F4 H+ T" N. s- N5 H! H5 E    Using default value 1
/ i9 f- D. e6 p; Q* v+ W    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G& h8 Y6 M' @+ O; t# ~# ]6 h
    Command (m for help): p
. C; y; a! M$ X$ e    Disk /dev/hda: 4294 MB, 4294967296 bytes
, P% Y! }1 L0 ]0 K# E    16 heads, 63 sectors/track, 8322 cylinders
( i5 k3 z# V5 h" |# ^    Units = cylinders of 1008 * 512 = 516096 bytes
; h  v0 }& x6 i# f       Device Boot    Start       End    Blocks   Id  System0 O9 `& x6 S6 C8 Z6 H
    /dev/hda1             1      1000    503968+  83  Linux
. z5 S6 C/ A1 h1 ?$ I    Command (m for help): w8 @3 I0 a2 L, I( L- N7 C3 @
    The partition table has been altered!8 p8 w1 G; ]+ c5 r
    Calling ioctl() to re-read partition table.$ Y/ u& r* W6 ?0 C, E
    Syncing disks.. m% K9 u. b1 \- X
    //格式化新分区
) |5 {) S/ ^6 u8 e+ ?
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)5 X7 r6 q; W8 ^* Y. m. ~) ?
    Filesystem label=9 F( p, U6 G: [  a7 l. f
    OS type: Linux8 G/ X  P" N* Q) d% Z, l7 k  D% Q- V
    Block size=1024 (log=0)
* f1 [' h7 [% a  Y- [) [* f4 f    Fragment size=1024 (log=0)
+ z3 R+ F9 }; i& k- ~4 c, n" h    126480 inodes, 503968 blocks2 `+ K6 F0 v- D% V$ S: j
    25198 blocks (5.00%) reserved for the super user
- |; q3 O5 s9 E" f( _) l8 @( E    First data block=1
4 v4 @3 |* l* A# C2 ?& y    62 block groups& U8 F  q$ n/ L
    8192 blocks per group, 8192 fragments per group
1 m+ ]& W: B( m/ B, l    2040 inodes per group- H* t2 ^, T# D. x
    Superblock backups stored on blocks:
. S" Z1 ?- y2 K' R; P1 Z% s            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
$ p4 i& v7 o4 D' C  E9 S) r8 m    Writing inode tables: done                            ' t8 O# ^  v% ^* }* }
    Creating journal (8192 blocks): done
: f0 L  J/ z" t4 y4 H    Writing superblocks and filesystem accounting information: done: s( ~9 v) Q- S" H9 p) |
    This filesystem will be automatically checked every 30 mounts or
' {$ k- _; G# U3 G- P6 n    180 days, whichever comes first.  Use tune2fs -c or -i to override.4 t" o- t" n7 k1 z: u1 Q
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) D3 u. G% X5 l) Z  F. I6 ^6 ]    /dev/sda3              3723848    705992   2828692  20% /% w8 ?0 |) m) F! [5 A! L' |
    /dev/sda1               101089      9274     86596  10% /boot
! @0 `0 Z% r0 P$ t! M0 \' K    none                     14520         0     14520   0% /dev/shm" Y. B* D: I. u3 ?$ f5 S  a
    //挂上新分区& F- a3 E; `4 h. F& R
  1. mount /dev/hda1 /home
    4 q; z' O9 }* j2 V; }) J
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 T( f( z5 |: s: ?% H    /dev/sda3              3723848    705992   2828692  20% /7 x. U6 y! t8 n6 N
    /dev/sda1               101089      9274     86596  10% /boot( i; c- R$ M- X/ l& t! ?
    none                     14520         0     14520   0% /dev/shm
$ [+ l! m& ~- e% {    /dev/hda1               488006      8239    454569   2% /home6 g" ]6 Z. D6 x! N

! b8 ^( F1 @% m自动挂载:
4 e' F$ l: x- e5 D
  1.           vi /etc/fstab% J! O, |3 y: F2 F% Q4 T

  2. ' _# I) D* X5 d3 U' {
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0& H( f/ X5 @. `
  4. 8 C9 r) V' d: L3 q6 ?
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
. _5 e' g8 ?3 v( ?% F
  1.           mount /dev/sdb5 /mnt/ljp1
    # P  r) B: s, U' c1 n
  2. 4 f( P- @/ A: Q* o8 O3 L% A1 x* {1 b
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

1 A5 ], i' d) l1 a2 J* }: z
% y5 B0 K7 S+ x" z5 j' p: {6 e; n. D8 K+ U$ a) i$ \4 W' A
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-2 13:04 , Processed in 0.022534 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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