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

 找回密码
 立即注册
查看: 2584|回复: 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)/ j7 x6 z  T& s6 t6 m' O
      or: fdisk /dev/sdc  (for the third SCSI disk)& k1 J. f6 c& m& ^8 n0 [6 l
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)" n5 D8 O  F5 \3 J. F3 _
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
% Y) M4 Z: v' H3 }# t: H      ..." n# U2 y, G2 Z% v6 Q
  1. df -k
    . r) H5 M" }. Y4 e) j
  2. df -lh
    / X: u9 ^8 t/ ]5 W
  3. 查看有几块硬盘:fdisk -l; M$ a9 Y1 g2 @' d
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
6 X( f; D' j$ G- r% t8 a    /dev/sda3              3723848    705968   2828716  20% /, {& m/ T; U  r+ W; w
    /dev/sda1               101089      9274     86596  10% /boot
8 w) Z- S* F5 {    none                     14520         0     14520   0% /dev/shm% }5 i* a( y7 Q& M0 w& |* ~
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
& T9 p1 r" O* c# R+ a5 p) e' }" \
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
' p. A! I4 P5 {3 \    Building a new DOS disklabel. Changes will remain in memory only,
& H* h, j4 p# I- c# t0 t; Q# F' ?    until you decide to write them. After that, of course, the previous
) t; z9 D$ C. v0 D. o2 e    content won't be recoverable.
; k3 Q5 @) l, h8 e1 s    The number of cylinders for this disk is set to 8322.0 p$ z7 G1 a% p+ i5 J- V
    There is nothing wrong with that, but this is larger than 1024,
# s$ R- v. q/ {; U" P1 K    and could in certain setups cause problems with:
1 f+ ]9 D' `6 X7 M8 W    1) software that runs at boot time (e.g., old versions of LILO)9 p# d9 N6 _8 n+ {2 b4 l
    2) booting and partitioning software from other OSs8 D, J- Q5 r( i$ e
       (e.g., DOS FDISK, OS/2 FDISK)
* M# R) j% w+ u+ ]    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# D3 X2 h3 m8 m4 s, H% i
    Command (m for help): p& F* Q9 \: j4 m
    Disk /dev/hda: 4294 MB, 4294967296 bytes
$ b5 {" x  S' W# q+ ]% i    16 heads, 63 sectors/track, 8322 cylinders
- w* Q1 ^; |- {1 s9 e" w/ J6 v2 k+ J0 B    Units = cylinders of 1008 * 512 = 516096 bytes
& @5 n" a8 F! n       Device Boot    Start       End    Blocks   Id  System
2 ?4 l9 G- n5 e/ {% p; G% G    Command (m for help): m% c) L, N% v$ T3 S- i: s% b
    Command action
9 r# `- j5 \; b7 \6 |/ G       a   toggle a bootable flag
7 u2 e: F' g6 ~1 U8 ~       b   edit bsd disklabel
8 M# W) X4 Y; Z' X0 C0 ^       c   toggle the dos compatibility flag
% o, q8 b) j- S! R2 w5 ]9 x       d   delete a partition
8 B" v# y4 H( }7 X' n1 F       l   list known partition types
7 f: g. U, {0 m       m   print this menu' h5 B. t  O; D6 M
       n   add a new partition9 _1 a8 c  M- y
       o   create a new empty DOS partition table
0 ?* U, w6 L$ N1 k3 o5 j  E9 U       p   print the partition table2 P: n! ~7 b3 A' X$ X' _6 F
       q   quit without saving changes. E  K* }; i+ q
       s   create a new empty Sun disklabel
+ o* c# m3 l: X; I0 I$ i+ h       t   change a partition's system id
. e5 o# R: q3 K) e5 `6 @; m/ r4 C3 ~       u   change display/entry units0 B, ^; G5 H  w5 W
       v   verify the partition table
+ K( y0 T! p# Q- [/ O1 c9 s       w   write table to disk and exit; e; E/ X1 `8 ^
       x   extra functionality (experts only)- U& v1 k( W0 ~( }  Y: A
    Command (m for help): n
0 K( R/ H) I, q8 ?! ?+ W; s    Command action
+ E0 w, i  J3 C3 F$ l& N       e   extended
5 r: Z* U& P6 K/ Z' c8 M8 ?       p   primary partition (1-4)
+ y( D3 Q& @% |2 p2 k    p
' w" e1 b  ]9 s! v    Partition number (1-4): 11 P$ ~( {3 f4 Q% }1 G( m9 a0 ]# U
    First cylinder (1-8322, default 1):
& x6 e4 J5 C1 i7 r% c  v" b    Using default value 1) b0 t0 e' G  T) I, c
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
6 z5 Q. B2 `4 [; D% a+ b2 _; l    Command (m for help): p
0 i( ?, ?7 V. P% {# o  G1 n    Disk /dev/hda: 4294 MB, 4294967296 bytes! E: F3 C' F/ w/ L
    16 heads, 63 sectors/track, 8322 cylinders
& X2 C  m& w8 N, G) L+ o% P    Units = cylinders of 1008 * 512 = 516096 bytes
: ^6 x7 y9 b  ~3 J       Device Boot    Start       End    Blocks   Id  System
1 |7 B# {7 U% K* u    /dev/hda1             1      1000    503968+  83  Linux
  C8 Q2 u9 [% A' [) P    Command (m for help): w
0 X2 G" w. C7 t    The partition table has been altered!
7 M' u6 I6 p) l3 w4 i# u& d    Calling ioctl() to re-read partition table.
2 d# {7 i/ [, y" v    Syncing disks.
- c2 \1 g* O9 @# O" R& A* u    //格式化新分区* `9 }( N* O8 _% p/ s# k% `5 C
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)3 l% J# M7 o0 P& g  N. _
    Filesystem label=8 d3 |* I, P% {: {
    OS type: Linux8 ?8 w% z" Z+ O( S
    Block size=1024 (log=0)5 H8 I) l! s, O+ h5 q
    Fragment size=1024 (log=0)
: y  j: {. d! [) l( A3 G- L    126480 inodes, 503968 blocks
( ^) Y) N6 V- |2 w% i' g( H* x( P    25198 blocks (5.00%) reserved for the super user
* {6 }, J: C$ w1 M- o    First data block=1
) |! v+ n* L$ E0 `8 a( G    62 block groups
, h* T: S6 K, r2 |2 S5 Y    8192 blocks per group, 8192 fragments per group
! j/ y8 v+ P2 \2 a7 f; i. N    2040 inodes per group
& z- n; ?2 ]2 W. e2 X2 X    Superblock backups stored on blocks: ( ^% P7 ]9 O( ]6 v' ~/ V4 m6 `
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409+ d: J8 A/ F1 d2 C
    Writing inode tables: done                           
) B! j% P9 q3 P" B5 \$ A    Creating journal (8192 blocks): done
, G# m. a3 K5 ]% j    Writing superblocks and filesystem accounting information: done
; b9 ]' I( g8 m7 O    This filesystem will be automatically checked every 30 mounts or& `. z6 u( [# U' w
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
: r$ [) w8 b' N
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. v  Y# U4 }" k* |
    /dev/sda3              3723848    705992   2828692  20% /
8 ~/ R1 [, x: F5 C8 u    /dev/sda1               101089      9274     86596  10% /boot
% p; `  x* R+ |0 y5 r; @    none                     14520         0     14520   0% /dev/shm) P7 t% [* P+ V
    //挂上新分区- q; o( [3 m. k$ {, a3 q( {7 B6 S
  1. mount /dev/hda1 /home7 m3 @4 a  m9 ]$ g/ o/ e
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
) q3 X) T; o+ u2 B( R    /dev/sda3              3723848    705992   2828692  20% /
' K! S! w  o7 G) \5 o) c. A    /dev/sda1               101089      9274     86596  10% /boot
+ m+ |4 T( \/ }9 |- b6 K    none                     14520         0     14520   0% /dev/shm  ?- i7 v2 Y0 ~, C$ h& V
    /dev/hda1               488006      8239    454569   2% /home0 y* @" D! h: ]6 C

6 l* k# L. c" x自动挂载:4 N) B: z# `6 r( B. S6 f" W
  1.           vi /etc/fstab
    : u  r* A6 X; P5 l- C

  2. 6 Y7 V3 P2 l; c- [9 U$ _' L
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0  q' j2 U$ _( w8 b
  4. 8 K, P. l) [$ X7 c% N  m; x
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
) X1 X8 @- V" P3 k' s2 c
  1.           mount /dev/sdb5 /mnt/ljp1: a3 @: K6 J3 d8 P+ ]

  2. $ U5 |5 j* m% {, F# L
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
6 p  f) g0 s2 ^5 d! \5 y' ^
' B/ @5 x- A1 E* M% H( ?% r
/ l0 d2 _9 m! Z
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-23 21:10 , Processed in 0.010370 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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