您的位置:首页 > 运维架构 > Linux

linux 块设备驱动(五)——块设备应用层的操作

2016-03-31 10:36 645 查看
一:加载好sbull驱动

root@CarRadio:/#ls/dev/sbull-lbrw-r--r--1rootroot254,16Mar2508:25/dev/sbullroot@CarRadio:/#

可以看到sbull文件属性是一个块设备,主设备号是254,次设备号是16

二:对设备进行分区

root@CarRadio:/#fdisk/dev/sbull[266.720648]sbull:unknownpartitiontableWelcometofdisk(util-linux2.24.1).Changeswillremaininmemoryonly,untilyoudecidetowritethem.Becarefulbeforeusingthewritecommand.Devicedoesnotcontainarecognizedpartitiontable.CreatedanewDOSdisklabelwithdiskidentifier0xb90ed7e4.Command(mforhelp):mHelp:DOS(MBR)atoggleabootableflagbeditnestedBSDdisklabelctogglethedoscompatibilityflagGenericddeleteapartitionllistknownpartitiontypesnaddanewpartitionpprintthepartitiontabletchangeapartitiontypevverifythepartitiontableMiscmprintthismenuuchangedisplay/entryunitsxextrafunctionality(expertsonly)Save&ExitwwritetabletodiskandexitqquitwithoutsavingchangesCreateanewlabelgcreateanewemptyGPTpartitiontableGcreateanewemptySGI(IRIX)partitiontableocreateanewemptyDOSpartitiontablescreateanewemptySunpartitiontableCommand(mforhelp):n//输入n添加一个新的分区Partitiontype:pprimary(0primary,0extended,4free)eextendedSelect(defaultp):p//主分区Partitionnumber(1-4,default1):1//该分区NO.1Firstsector(1-1023,default1):1//该分区起始扇区Lastsector,+sectorsor+size{K,M,G,T,P}(1-1023,default1023):1023//该分区结尾扇区Createdanewpartition1oftype'Linux'andofsize511.5KiB.Command(mforhelp):w//保存并退出Thepartitiontablehasbeenaltered.Callingioctl()tore-readparti[303.589984]sbull:sbull1tiontable.Syncingdisks.



查看分区:笔者做了两个分区

root@CarRadio:/#ls/dev/sbull*
/dev/sbull/dev/sbull1/dev/sbull2
root@CarRadio:/#

二:格式化文件系统

root@CarRadio:/#mkfs.ext4/dev/sbull2
mke2fs1.42.4(12-June-2012)
Filesystemlabel=
OStype:Linux
Blocksize=1024(log=0)
Fragmentsize=1024(log=0)
Stride=0blocks,Stripewidth=0blocks
64inodes,504blocks
25blocks(4.96%)reservedforthesuperuser
Firstdatablock=1
Maximumfilesystemblocks=524288
1blockgroup
8192blockspergroup,8192fragmentspergroup
64inodespergroup

Allocatinggrouptables:done
Writinginodetables:done

Filesystemtoosmallforajournal
Writingsuperblocksandfilesystemaccountinginformation:done

三:挂在文件系统

root@CarRadio:/#mount/dev/sbull1/tmp/mnt/sbull/mount:mounting/dev/sbull1on/tmp/mnt/sbull/failed:Invalidargumentroot@CarRadio:/#mount/dev/sbull2/tmp/mnt/sbull/[832.527053]EXT4-fs(sbull2):couldn'tmountasext3duetofeatureincompatibilities[832.557133]EXT4-fs(sbull2):couldn'tmountasext2duetofeatureincompatibilities[832.588127]EXT4-fs(sbull2):mountedfilesystemwithoutjournal.Opts:(null)root@CarRadio:/#root@CarRadio:/#

以上完成了该块设备应用层的挂在操作,接下来就可以直接在/tmp/mnt/sbull目录里面操作了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: