科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道介绍Linux操作系统下添加新硬盘的方法

介绍Linux操作系统下添加新硬盘的方法

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

or: fdisk /dev/eda (for the first PS/2 ESDI drive) or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)

作者:赛迪网 来源:赛迪网 2007年10月8日

关键字: 方法 硬盘 操作系统 Linux

  • 评论
  • 分享微博
  • 分享邮件
 

在系统上增加硬盘操作办法

[root@gyhredhat root]# fdisk

Usage: fdisk [-l] [-b SSZ] [-u] device

E.g.: fdisk /dev/hda (for the first IDE disk)

or: fdisk /dev/sdc (for the third SCSI disk)

or: fdisk /dev/eda (for the first PS/2 ESDI drive)

or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)

...

[root@gyhredhat root]# df -k

文件系统 1K-块 已用 可用 已用% 挂载点

/dev/sda3 3723848 705968 2828716 20% /

/dev/sda1 101089 9274 86596 10% /boot

none 14520 0 14520 0% /dev/shm

对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用

[root@gyhredhat root]# fdisk /dev/hda

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

The number of cylinders for this disk is set to 8322.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/hda: 4294 MB, 4294967296 bytes

16 heads, 63 sectors/track, 8322 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types

m print this menu

n add a new partition

o create a new empty DOS partition table

p print the partition table

q quit without saving changes

s create a new empty Sun disklabel

t change a partition's system id

u change display/entry units

v verify the partition table

w write table to disk and exit

x extra functionality (experts only)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-8322, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G

Command (m for help): p

Disk /dev/hda: 4294 MB, 4294967296 bytes

16 heads, 63 sectors/track, 8322 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Device Boot Start End Blocks Id System

/dev/hda1 1 1000 503968+ 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

//格式化新分区

[root@gyhredhat root]# mkfs.ext3 /dev/hda1

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

126480 inodes, 503968 blocks

25198 blocks (5.00%) reserved for the super user

First data block=1

62 block groups

8192 blocks per group, 8192 fragments per group

2040 inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@gyhredhat root]# df -k

文件系统 1K-块 已用 可用 已用% 挂载点

/dev/sda3 3723848 705992 2828692 20% /

/dev/sda1 101089 9274 86596 10% /boot

none 14520 0 14520 0% /dev/shm

//挂上新分区

[root@gyhredhat root]# mount /dev/hda1 /home

[root@gyhredhat root]# df -k

文件系统 1K-块 已用 可用 已用% 挂载点

/dev/sda3 3723848 705992 2828692 20% /

/dev/sda1 101089 9274 86596 10% /boot

none 14520 0 14520 0% /dev/shm

/dev/hda1 488006 8239 454569 2% /home

[root@gyhredhat root]#

以下是为收集于网络,个人觉得非常不错

1. 检查所有硬盘分区

[root@web home]# fdisk -l

Disk /dev/hdc: 81.9 GB, 81964302336 bytes

255 heads, 63 sectors/track, 9964 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hdc1 * 1 3921 31495401 7 HPFS/NTFS

/dev/hdc2 3922 9964 48540397+ f Win95 Ext'd (LBA)

/dev/hdc5 3922 7840 31479336 7 HPFS/NTFS

/dev/hdc6 7841 9964 17060998+ 7 HPFS/NTFS

Disk /dev/hda: 60.0 GB, 60022480896 bytes

255 heads, 63 sectors/track, 7297 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 13 104391 83 Linux

/dev/hda2 14 7043 56468475 83 Linux

/dev/hda3 7044 7297 2040255 82 Linux swap

2. 检查新硬盘分区

[root@web root]# fdisk /dev/hdc

The number of cylinders for this disk is set to 9964.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

3. 删除老硬盘分区(hdc1,hdc2,hdc5,hdc6)

Command (m for help): d

Partition number (1-6): 6

4. 保存修改信息

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

5. 检查保存情况,直到所有老分区都删除

[root@web root]# fdisk -l /dev/hdc

Disk /dev/hdc: 81.9 GB, 81964302336 bytes

255 heads, 63 sectors/track, 9964 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hdc2 3922 9964 48540397+ f Win95 Ext'd (LBA)

/dev/hdc5 3922 7840 31479336 7 HPFS/NTFS

6. 重新创建硬盘分区

[root@web root]# fdisk -l /dev/hdc

Disk /dev/hdc: 81.9 GB, 81964302336 bytes

255 heads, 63 sectors/track, 9964 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): d

No partition is defined yet!

Command (m for help): n

Command action

e extended

p primary partition (1-4)

7. 选择主分区(?)

p

8. 选择硬盘分区号(hdc1中的1)

Partition number (1-4): 1

9. 选择硬盘分区的第一柱面(从第2个开始,从1开始不安全(?))

First cylinder (1-9964, default 1): 2

10. 选择硬盘分区结束柱面

Last cylinder or +size or +sizeM or +sizeK (2-9964, default 9964): 5000

11. 保存修改信息

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

12. 创建hdc2

[root@web root]# fdisk /dev/hdc

The number of cylinders for this disk is set to 9964.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (1-9964, default 1): 5001

Last cylinder or +size or +sizeM or +sizeK (5001-9964, default 9964):

Using default value 9964

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

13. 检查新硬盘创建信息

[root@web root]# fdisk -l

Disk /dev/hdc: 81.9 GB, 81964302336 bytes

255 heads, 63 sectors/track, 9964 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hdc1 2 5000 40154467+ 83 Linux

/dev/hdc2 5001 9964 39873330 83 Linux

Disk /dev/hda: 60.0 GB, 60022480896 bytes

255 heads, 63 sectors/track, 7297 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hda1 * 1 13 104391 83 Linux

/dev/hda2 14 7043 56468475 83 Linux

/dev/hda3 7044 7297 2040255 82 Linux swap

14. 建立新硬盘映射目录

[root@web root]# mkdir -pv /disk1

[root@web root]# mkdir -pv /disk2

15. 格式化新硬盘分区

[root@web root]# mkfs.ext3 /dev/hdc1

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

5020064 inodes, 10038616 blocks

501930 blocks (5.00%) reserved for the super user

First data block=0

307 block groups

32768 blocks per group, 32768 fragments per group

16352 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@web root]# mkfs.ext3 /dev/hdc2

mke2fs 1.32 (09-Nov-2002)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

4987360 inodes, 9968332 blocks

498416 blocks (5.00%) reserved for the super user

First data block=0

305 block groups

32768 blocks per group, 32768 fragments per group

16352 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 29 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

16. 增加新硬盘分区表信息

[root@web root]# vi /etc/fstab

LABEL=/ / ext3 defaults 1 1

LABEL=/boot /boot ext3 defaults 1 2

none /dev/pts devpts gid=5,mode=620 0 0

none /proc proc defaults 0 0

none /dev/shm tmpfs defaults 0 0

/dev/hda3 swap swap defaults 0 0

/dev/hdc1 /disk1 ext3 defaults 1 1

/dev/hdc2 /disk2 ext3 defaults 1 1

17. 挂上硬盘

[root@web root]# mount -a

18. 检查所有硬盘mount情况

[root@web root]# df -h

/dev/hda2 54G 1.4G 49G 3% /

/dev/hda1 99M 15M 80M 16% /boot

none 1008M 0 1008M 0% /dev/shm

/dev/hdc1 38G 33M 36G 1% /disk1

/dev/hdc2 38G 33M 36G 1% /disk2

    • 评论
    • 分享微博
    • 分享邮件
    闂傚倸鍊搁崐鎼佸磹妞嬪孩顐介柨鐔哄Т閻骞栧ǎ顒€濡肩紒鎰殜閺岋繝宕堕埡浣锋睏闂佸搫顑呴柊锝夊蓟閺囷紕鐤€閻庯綆浜炴禒鐐節濞堝灝鐏犻柕鍫熸倐瀵寮撮敍鍕澑闁诲函缍嗘禍鏍磻閹捐鍐€妞ゆ挶鍔庣粙蹇涙⒑鐠恒劌娅愰柟鍑ゆ嫹

    婵犵數濮烽弫鍛婃叏閻戝鈧倹绂掔€n亞鍔﹀銈嗗坊閸嬫捇鏌涢悢閿嬪仴闁糕斁鍋撳銈嗗坊閸嬫挾绱撳鍜冭含妤犵偛鍟灒閻犲洩灏欑粣鐐烘⒑瑜版帒浜伴柛鎾寸洴閹儳煤椤忓應鎷洪梻鍌氱墛閸楁洟宕奸妷銉ф煣濠电姴锕ょ€氼參宕h箛鏃傜瘈濠电姴鍊绘晶娑㈡煕鐎c劌濡介柕鍥у瀵粙濡歌閳ь剚甯¢弻鐔兼寠婢跺﹥娈婚梺鍝勭灱閸犳牠骞冨⿰鍫濈厸闁稿本绋撹ぐ瀣煟鎼淬値娼愭繛鍙壝悾婵堢矙鐠恒劍娈鹃梺鍓插亝濞叉牠鎮″☉銏$厱閻忕偛澧介惌瀣箾閸喐鍊愭慨濠勭帛閹峰懐绮电€n亝鐣伴梻浣规偠閸斿宕¢崘鑼殾闁靛繈鍊曢崘鈧銈嗗姂閸庡崬鐨梻鍌欑劍鐎笛呯矙閹寸姭鍋撳鐓庡籍鐎规洑鍗冲畷鍗炍熼梹鎰泿闂備線娼ч悧鍡涘箠鎼淬垺鍙忔い鎺嗗亾闁宠鍨块崺銉╁幢濡炲墽鍑规繝鐢靛О閸ㄦ椽鏁嬮柧鑽ゅ仦娣囧﹪濡堕崨顔兼闂佺ǹ顑呴崐鍦崲濞戙垹骞㈡俊顖濐嚙绾板秹鏌f惔銏e妞わ妇鏁诲璇差吋閸偅顎囬梻浣告啞閹搁箖宕版惔顭戞晪闁挎繂顦介弫鍡椼€掑顒婂姛闁活厽顨嗙换娑㈠箻閺夋垹鍔伴梺绋款儐閹瑰洭寮婚敐鍛婵炲棙鍔曠壕鎶芥⒑閸濆嫭婀扮紒瀣灴閸╃偤骞嬮敃鈧婵囥亜閺囩偞鍣洪柍璇诧功缁辨捇宕掑▎鎴濆濡炪們鍔岄幊姗€骞嗗畝鍕<闁绘劙娼х粊锕傛煙閸忚偐鏆橀柛鏂跨焸閹偤宕归鐘辩盎闂佸湱鍎ら崹鐢割敂閳哄懏鍊垫慨姗嗗墻濡插綊鏌曢崶褍顏€殿喕绮欐俊姝岊槼闁革絻鍎崇槐鎾存媴缁涘娈┑鈽嗗亝缁诲牆顕f繝姘亜缁炬媽椴搁弲锝夋偡濠婂啰效闁诡喗锕㈤幊鐘活敆閸屾粣绱查梺鍝勵槸閻楀嫰宕濇惔锝囦笉闁绘劗鍎ら悡娑㈡倶閻愯泛袚闁哥姵锕㈤弻鈩冩媴閻熸澘顫掗悗瑙勬礈閸犳牠銆佸鈧幃鈺呮惞椤愩倝鎷婚梻鍌氬€峰ù鍥х暦閸偅鍙忛柟鎯板Г閳锋梻鈧箍鍎遍ˇ顖炲垂閸岀偞鐓㈡俊顖滃皑缁辨岸鏌ㄥ┑鍡╂Ц缂佲偓鐎n偁浜滈柡宥冨妿閳藉绻涢崼鐔虹煉婵﹨娅e☉鐢稿川椤斾勘鈧劕顪冮妶搴′簼婵炶尙鍠栧畷娲焵椤掍降浜滈柟鍝勬娴滈箖姊洪幐搴㈢┛濠碘€虫搐鍗遍柟鐗堟緲缁秹鏌涢锝囩畼妞ゆ挻妞藉铏圭磼濡搫顫岄悗娈垮櫘閸撴瑨鐏冮梺鍛婁緱閸犳岸宕㈤幖浣光拺闁告挻褰冩禍浠嬫煕鐎n亜顏柟顔斤耿閺佸啴宕掑☉姘箞闂佽鍑界紞鍡涘磻閸℃ɑ娅犳い鎺戝€荤壕濂告煕鐏炲墽鈽夌紒妞﹀洦鐓欓柣鐔告緲椤忣參鏌熼悡搴㈣础闁瑰弶鎸冲畷鐔兼濞戞瑦鐝¢梻鍌氬€搁崐椋庣矆娓氣偓楠炴牠顢曢妶鍌氫壕婵ê宕崢瀵糕偓瑙勬礀缂嶅﹪寮婚崱妤婂悑闁告侗鍨界槐閬嶆煟鎼达紕鐣柛搴ㄤ憾钘濆ù鍏兼綑绾捐法鈧箍鍎遍ˇ浼存偂閺囥垺鐓涢柛銉e劚婵$厧顭胯閸ㄤ即婀侀梺缁樓圭粔顕€顢旈崼鐔虹暢闂傚倷鐒︾€笛呮崲閸屾娑樜旈崨顓犲幒闂佸搫娲㈤崹娲偂閸愵亝鍠愭繝濠傜墕缁€鍫熸叏濡寧纭鹃柦鍐枛閺屾洘绻涜鐎氱兘宕戦妸鈺傗拺缂備焦锚婵洦銇勯弴銊ュ籍闁糕斂鍨藉鎾閳ユ枼鍋撻悽鍛婄叆婵犻潧妫楅埀顒傛嚀閳诲秹宕堕妸锝勭盎闂婎偄娲︾粙鎰板箟妤e啯鐓涢悘鐐靛亾缁€瀣偓瑙勬礋娴滃爼銆佸鈧幃銏$附婢跺澶�

    重磅专题
    往期文章
    最新文章