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

 找回密码
 立即注册
查看: 2218|回复: 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)5 v4 j+ X9 j2 _% Z
      or: fdisk /dev/sdc  (for the third SCSI disk)" z9 d+ @2 x4 r0 ?
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive). P4 f) U" B  S1 o0 M- n; G
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)& r# T# u' P9 o
      .../ t4 O0 t1 m8 c' S1 s
  1. df -k8 K/ r: E: }% J0 X
  2. df -lh
    + n# H$ G) ?, m& h, i
  3. 查看有几块硬盘:fdisk -l
    ) c3 ?6 A9 M5 N& ~4 L# b% }' V
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点7 R% p$ L9 N* `1 p6 p3 G6 c. v3 X
    /dev/sda3              3723848    705968   2828716  20% /4 e: X/ \6 n. O& K/ \
    /dev/sda1               101089      9274     86596  10% /boot( \1 M% I, }1 c$ N" \% h; l5 _
    none                     14520         0     14520   0% /dev/shm
- p$ y3 A% ~% f    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用" ~* m0 K3 X+ m4 V8 P& t
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
0 O- M; p& f( t) T) ?( k    Building a new DOS disklabel. Changes will remain in memory only,
: |, w, E& Y7 A: O; q& [; _    until you decide to write them. After that, of course, the previous4 V$ W; w/ S; E  b4 D9 n8 f2 n
    content won't be recoverable.7 J5 ^, L6 [2 |4 K) I) O8 S3 Y
    The number of cylinders for this disk is set to 8322.
- a* n5 [9 F" ]$ x    There is nothing wrong with that, but this is larger than 1024,; c4 D/ A. |- e) r2 h
    and could in certain setups cause problems with:! j) o  u# ~% d
    1) software that runs at boot time (e.g., old versions of LILO)3 Q5 ^) r4 Q1 T: `* S! i
    2) booting and partitioning software from other OSs- \* i% ], l! }2 ]: k% f- L, c
       (e.g., DOS FDISK, OS/2 FDISK)
$ |; c6 k" L6 E) S- D5 Q7 u    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
- c! z& x) ]7 s2 [1 e3 J+ {    Command (m for help): p9 D( d9 m# M& C
    Disk /dev/hda: 4294 MB, 4294967296 bytes+ b9 F+ I$ t* ~2 P# K& Z
    16 heads, 63 sectors/track, 8322 cylinders
: b% I# y7 A' [* Z1 I    Units = cylinders of 1008 * 512 = 516096 bytes
9 U$ u' r) x) C9 I$ K3 n' P       Device Boot    Start       End    Blocks   Id  System. w% T1 I/ T8 e! l2 T2 U
    Command (m for help): m8 O/ ]. F. j# M
    Command action
: m% W- {2 Z. w9 G% |) r+ r8 j       a   toggle a bootable flag2 Y6 b& [3 P1 K
       b   edit bsd disklabel
) s& B, n" N2 [! u( v       c   toggle the dos compatibility flag
. n9 E2 z! m* |, g1 D: t9 Q       d   delete a partition& }: ?9 I5 P' p; o
       l   list known partition types
5 j1 h2 W  W; P* }8 W; o9 }       m   print this menu$ D; T/ f) ]4 y$ V& a7 z
       n   add a new partition# g& X( J. E+ a7 \  Q3 q% i6 U* c! T
       o   create a new empty DOS partition table! V8 f' _& t# d  {
       p   print the partition table, b+ x  y9 v7 s) \$ u: U) a
       q   quit without saving changes
* x; }' y5 F3 M% ~' H: s3 h       s   create a new empty Sun disklabel( S) ]; V% I0 ?4 H
       t   change a partition's system id
* Z, x2 M/ q/ m       u   change display/entry units$ G* I: a+ x' [' I
       v   verify the partition table( |, E) E; D: @) s8 X& [% u
       w   write table to disk and exit
, k0 ~" s% i; l7 \& ^! y+ W       x   extra functionality (experts only). K8 ]/ b6 j8 p4 R9 M
    Command (m for help): n! X- G! w. g3 Y+ Y
    Command action0 V, c, ~8 Z- V3 D2 O* I7 ?' \
       e   extended, y' K  y! h8 @7 Y. J
       p   primary partition (1-4)* C1 ~" t3 i* t! N
    p
. O4 v# T* [; D+ h! q8 P8 \6 Q. @    Partition number (1-4): 19 ?. U1 @* I# j' a
    First cylinder (1-8322, default 1):
* e& H+ a1 ~( T7 y    Using default value 1+ |8 D: V; t# P' t  s7 b, g  r
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G. t+ q/ g; k( j" P/ y) j. C
    Command (m for help): p3 d) C( |" b- N; c6 g: g  x
    Disk /dev/hda: 4294 MB, 4294967296 bytes6 o# Y+ \; Z% n" W, K) {+ c1 s
    16 heads, 63 sectors/track, 8322 cylinders
$ y9 n# O5 G# v( W" \% Z    Units = cylinders of 1008 * 512 = 516096 bytes. P+ N) _2 M, F$ B, y. d
       Device Boot    Start       End    Blocks   Id  System
+ h" ~7 l; h  R# I    /dev/hda1             1      1000    503968+  83  Linux
% [6 j6 a3 I0 P+ M    Command (m for help): w
% a1 `* D9 r& N. Q  B    The partition table has been altered!% b4 [6 J- [1 Z- `, b; n# U
    Calling ioctl() to re-read partition table.
. ^7 j) c: h1 I    Syncing disks.+ G/ |' D: v! R
    //格式化新分区% N4 z  }4 `4 k
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 ]/ p, s" ~5 G* \5 ~6 K    Filesystem label=4 g' K; `1 D- J, G# j  M% {
    OS type: Linux
7 U% R  p; V. h" Y    Block size=1024 (log=0)
. e$ s1 r1 a3 K0 |, L1 V; a; O    Fragment size=1024 (log=0), }% w$ E0 E5 E! W
    126480 inodes, 503968 blocks. y& f5 C8 K$ U( ~5 P# O( G# |
    25198 blocks (5.00%) reserved for the super user
/ _( ?! F: {2 g    First data block=1+ x" [9 Q% j# A2 s
    62 block groups
+ e( @7 \3 l2 Q* Q    8192 blocks per group, 8192 fragments per group! \% D7 n: h( C4 w- ?- Z) h
    2040 inodes per group) G5 _# F  h; f
    Superblock backups stored on blocks: ! H/ L, B5 m- K$ r& D3 F
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409. a. S8 ]" n, G! K8 m4 G
    Writing inode tables: done                            " g* \% Z2 ~. u8 m7 m! L
    Creating journal (8192 blocks): done% ~. {2 F7 k0 }* u, E0 G7 W
    Writing superblocks and filesystem accounting information: done
6 S  P$ j; u" M# W( s! J    This filesystem will be automatically checked every 30 mounts or# z8 E0 l6 N* r  a  Z
    180 days, whichever comes first.  Use tune2fs -c or -i to override./ j+ f  l0 M- F  a1 K
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点6 W: x4 d$ t7 a) V+ C( W
    /dev/sda3              3723848    705992   2828692  20% /4 I' h& N8 S0 n8 E4 ?' B
    /dev/sda1               101089      9274     86596  10% /boot, u  H. g8 q" ?
    none                     14520         0     14520   0% /dev/shm4 m' k: ?; }+ h7 c3 ]
    //挂上新分区2 Z, C+ |! G( P; K
  1. mount /dev/hda1 /home+ F% r$ U. \" l( H+ B; z2 F+ K
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点% O. b- y' P3 u- O' d  e+ t* o
    /dev/sda3              3723848    705992   2828692  20% /0 ]5 g! H* [) b$ ~8 v; u: y/ c
    /dev/sda1               101089      9274     86596  10% /boot
4 U2 T% [0 m5 q    none                     14520         0     14520   0% /dev/shm
9 Q3 G* I( ~1 K8 {% i  t/ h    /dev/hda1               488006      8239    454569   2% /home
0 Q& ^' \! o1 K. Z- ]9 V5 b5 h9 e2 b! b/ Y: K9 l/ C
自动挂载:
' ?+ W* q6 U9 e- R, w5 C: I. z+ W
  1.           vi /etc/fstab* S) |$ O3 h# S8 S8 R  h- B
  2. + H$ U" R  ]/ \8 a
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    * ^: I7 f) \8 j( F
  4. + u- B/ J0 Y# k  w& C7 A* E
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:5 W3 k6 s6 H+ ^5 W* ?
  1.           mount /dev/sdb5 /mnt/ljp1
    ( |7 s; g& L9 t' v0 S2 s+ ~
  2. 3 Q8 t" @: I+ d2 Y) A
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
) z7 K3 ^" H% M% p. k
9 r) q. N% v0 a* b- z5 y* [0 Z
3 `/ x4 N6 w; Z% ?# b
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-2 08:43 , Processed in 0.035019 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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