`
tianshibaijia
  • 浏览: 1128670 次
文章分类
社区版块
存档分类
最新评论

Linux 下挂载硬盘的 方法

 
阅读更多

装虚拟机时空间划小了,于是又加了5G的空间,折腾了半天,挂上去了。整理下弄个笔记,备用。

1.添加磁盘,查看磁盘状况

[root@db1/]#fdisk-l

Disk/dev/sda:10.7GB,10737418240bytes

255heads,63sectors/track,1305cylinders

Units=cylindersof16065*512=8225280bytes

DeviceBootStartEndBlocksIdSystem

/dev/sda1*15113059277537+83Linux

/dev/sda211501204843+82Linuxswap

Partitiontableentriesarenotindiskorder

Disk/dev/sdb:5368MB,5368709120bytes

255heads,63sectors/track,652cylinders

Units=cylindersof16065*512=8225280bytes

DeviceBootStartEndBlocksIdSystem

从查询结果看出,多了一个/dev/sdb的盘

2.用fdisk/dev/sdb进行分区

[root@db1/]#fdisk/dev/sdb

Command(mforhelp):n

Commandaction

eextended

pprimarypartition(1-4)

p

Partitionnumber(1-4):1

Firstcylinder(1-652,default1):

Usingdefaultvalue1

Lastcylinderor+sizeor+sizeMor+sizeK(1-652,default652):

Usingdefaultvalue652

Command(mforhelp):w

Thepartitiontablehasbeenaltered!

Callingioctl()tore-readpartitiontable.

Syncingdisks.

再次查看分区情况,多出来一个/dev/sdb1的区,这个1是我们在前面指定的,如果我们指定2,就变成sdb2了。

[root@db1/]#fdisk-l

Disk/dev/sda:10.7GB,10737418240bytes

255heads,63sectors/track,1305cylinders

Units=cylindersof16065*512=8225280bytes

DeviceBootStartEndBlocksIdSystem

/dev/sda1*15113059277537+83Linux

/dev/sda211501204843+82Linuxswap

Partitiontableentriesarenotindiskorder

Disk/dev/sdb:5368MB,5368709120bytes

255heads,63sectors/track,652cylinders

Units=cylindersof16065*512=8225280bytes

DeviceBootStartEndBlocksIdSystem

/dev/sdb116525237158+83Linux

[root@db1/]#

3.格式化/dev/sdb1分区

[root@db1/]#mkfs-text3/dev/sdb1

mke2fs1.35(28-Feb-2004)

Filesystemlabel=

OStype:Linux

Blocksize=4096(log=2)

Fragmentsize=4096(log=2)

655360inodes,1309289blocks

65464blocks(5.00%)reservedforthesuperuser

Firstdatablock=0

Maximumfilesystemblocks=1342177280

40blockgroups

32768blockspergroup,32768fragmentspergroup

16384inodespergroup

Superblockbackupsstoredonblocks:

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

Writinginodetables:done

Creatingjournal(8192blocks):done

Writingsuperblocksandfilesystemaccountinginformation:done

Thisfilesystemwillbeautomaticallycheckedevery30mountsor

180days,whichevercomesfirst.Usetune2fs-cor-itooverride.

4.创建目录并将/dev/sdb1挂在到该目录下

[root@db1/]#ls

backupdevinitrdmediaoptsbinsysusr

binetclibmiscprocselinuxtftpbootvar

boothomelost+foundmntrootsrvtmp

[root@db1/]#mkdir/u01

[root@db1/]#ls

backupdevinitrdmediaoptsbinsysu01

binetclibmiscprocselinuxtftpbootusr

boothomelost+foundmntrootsrvtmpvar

[root@db1/]#mount/dev/sdb1/u01

5.验证挂载是否成功

[root@db1/]#df-k

Filesystem1K-blocksUsedAvailableUse%Mountedon

/dev/sda191317727066884160101282%/

none45425604542560%/dev/shm

/dev/sdb151548524304048499561%/backup

6.设置开机自动挂载

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

#Thisfileiseditedbyfstab-sync-see'manfstab-sync'fordetails

LABEL=//ext3defaults11

none/dev/ptsdevptsgid=5,mode=62000

none/dev/shmtmpfsdefaults00

none/procprocdefaults00

none/syssysfsdefaults00

LABEL=SWAP-sda2swapswapdefaults00

/dev/sdb1/u01ext3defaults00

/dev/hdc/media/cdromautopamconsole,exec,noauto,m

anaged00

/dev/fd0/media/floppyautopamconsole,exec,noauto,m

anaged00

关于/etc/fstab 命令,详见:

Linux fstab 参数详解

http://blog.csdn.net/tianlesoftware/archive/2011/02/18/6194358.aspx

------------------------------------------------------------------------------

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics