Linux系统硬盘分区 格式化 挂载的方法
2019/10/10/17:47:08 阅读:1920 来源:谷歌SEO算法 标签:
SEO知识
在windows中安装好硬盘之后我们只要分区与格式化就可以了,但在linux中还要多一步硬盘挂载了,下面本文章就全面的介绍linux下安装一块磁盘的过程,其实就包括了硬盘分区 格式化 挂载,希望文章能帮助到各位.
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--phpfensi.com
- /dev/fd0/media/floppyautopamconsole,exec,noauto,m
- anaged00
热门评论