linux 块设备驱动(五)——块设备应用层的操作
一: 加载好sbull驱动
root@CarRadio:/# ls /dev/sbull -l brw-r--r-- 1 root root 254, 16 Mar 25 08:25 /dev/sbull root@CarRadio:/#
可以看到sbull文件属性是一个块设备, 主设备号是254,次设备号是16
二:对设备进行分区
root@CarRadio:/# fdisk /dev/sbull [ 266.720648] sbull: unknown partition table Welcome to fdisk (util-linux 2.24.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xb90ed7e4. Command (m for help): m Help: DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag Generic d delete a partition l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table Misc m print this menu u change display/entry units x extra functionality (experts only) Save & Exit w write table to disk and exit q quit without saving changes Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty DOS partition table s create a new empty Sun partition table Command (m for help): n //输入n 添加一个新的分区Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p //主分区 Partition number (1-4, default 1): 1 //该分区NO.1 First sector (1-1023, default 1): 1 // 该分区起始扇区 Last sector, +sectors or +size{K,M,G,T,P} (1-1023, default 1023): 1023 //该分区结尾扇区 Created a new partition 1 of type 'Linux' and of size 511.5 KiB. Command (m for help): w //保存并退出 The partition table has been altered. Calling ioctl() to re-read parti[ 303.589984] sbull: sbull1 tion table. Syncing disks.
查看分区:笔者做了两个分区
root@CarRadio:/# ls /dev/sbull*
/dev/sbull /dev/sbull1 /dev/sbull2
root@CarRadio:/#
二:格式化文件系统
root@CarRadio:/# mkfs.ext4 /dev/sbull2
mke2fs 1.42.4 (12-June-2012)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
64 inodes, 504 blocks
25 blocks (4.96%) reserved for the super user
First data block=1
Maximum filesystem blocks=524288
1 block group
8192 blocks per group, 8192 fragments per group
64 inodes per group
Allocating group tables: done
Writing inode tables: done
Filesystem too small for a journal
Writing superblocks and filesystem accounting information: done
三:挂在文件系统
root@CarRadio:/# mount /dev/sbull1 /tmp/mnt/sbull/ mount: mounting /dev/sbull1 on /tmp/mnt/sbull/ failed: Invalid argument root@CarRadio:/# mount /dev/sbull2 /tmp/mnt/sbull/ [ 832.527053] EXT4-fs (sbull2): couldn't mount as ext3 due to feature incompatibilities [ 832.557133] EXT4-fs (sbull2): couldn't mount as ext2 due to feature incompatibilities [ 832.588127] EXT4-fs (sbull2): mounted filesystem without journal. Opts: (null) root@CarRadio:/# root@CarRadio:/#
以上完成了该块设备应用层的挂在操作,接下来就可以直接在/tmp/mnt/sbull目录里面操作了
linux 块设备驱动(五)——块设备应用层的操作的更多相关文章
- 【转】深入浅出:Linux设备驱动之字符设备驱动
深入浅出:Linux设备驱动之字符设备驱动 一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用驱动程序: 字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据 ...
- Linux 设备驱动开发 —— platform设备驱动应用实例解析
前面我们已经学习了platform设备的理论知识Linux 设备驱动开发 —— platform 设备驱动 ,下面将通过一个实例来深入我们的学习. 一.platform 驱动的工作过程 platfor ...
- 字符设备驱动、平台设备驱动、设备驱动模型、sysfs的比较和关联
转载自:http://www.kancloud.cn/yueqian_scut/emlinux/106829 学习Linux设备驱动开发的过程中自然会遇到字符设备驱动.平台设备驱动.设备驱动模型和sy ...
- [kernel]字符设备驱动、平台设备驱动、设备驱动模型、sysfs几者之间的比较和关联
转自:http://www.2cto.com/kf/201510/444943.html Linux驱动开发经验总结,绝对干货! 学习Linux设备驱动开发的过程中自然会遇到字符设备驱动.平台设备驱动 ...
- 乾坤合一~Linux设备驱动之块设备驱动
1. 题外话 在蜕变成蝶的一系列学习当中,我们已经掌握了大部分Linux驱动的知识,在乾坤合一的分享当中,以综合实例为主要讲解,在一个月的蜕茧成蝶的学习探索当中,觉得数据结构,指针,链表等等占据了代码 ...
- 深入浅出:Linux设备驱动之字符设备驱
一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用驱动程序: 字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据,读取数据需要按照先后数据.字符设备是面向流 ...
- linux设备驱动之字符设备驱动模型(2)
在上一篇中我们已经了解了字符设备驱动的原理,也了解了应用层调用内核函数的机制,但是我们每次操作设备,都必须首先通过mknod命令创建一个设备文件名,比如说我们要打开u盘,硬盘等这些设备,难道我们还要自 ...
- Linux 设备驱动之字符设备
参考转载博客:http://blog.chinaunix.net/uid-26833883-id-4369060.html https://www.cnblogs.com/xiaojiang1025/ ...
- 蜕变成蝶~Linux设备驱动之字符设备驱动
一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用驱动程序: 字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据,读取数据需要按照先后数据.字符设备是面向流 ...
- 深入浅出:Linux设备驱动之字符设备驱动
一.linux系统将设备分为3类:字符设备.块设备.网络设备.使用驱动程序: 字符设备:是指只能一个字节一个字节读写的设备,不能随机读取设备内存中的某一数据,读取数据需要按照先后数据.字符设备是面向流 ...
随机推荐
- NOIP2017赛前模拟(5):总结
题目: 1.刮刮卡 已知n(n<=1000000)张刮刮卡按顺序排列,刮开可以获得B元现金和B个积分,购买刮刮卡需要A元,某人若按照顺序刮开的话··当B的总和小于A时便会停止刮卡(即花出去的钱多 ...
- C#递归删除进程及其子进程
/// <summary> /// 结束进程和相关的子进程 /// </summary> /// <param name="pid">需要结束的 ...
- C#函数多返回值的方法
C#以前都是不支持多返回值,当需要返回多个值的时候,就会感觉比较麻烦,通常的做法有 1.采用ref,out 关键字返回 2.定义类或者结构体 返回对象 C# 6.0出来了新的语法 Tuple 支付返回 ...
- UVA 116 Unidirectional TSP(DP最短路字典序)
Description Unidirectional TSP Background Problems that require minimum paths through some domai ...
- poj 3468 线段树成段更新
A Simple Problem with Integers Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 54012 ...
- 【BZOJ1579】Revamping Trails(分层图,最短路,堆)
题意:每天,农夫John需要经过一些道路去检查牛棚N里面的牛. 农场上有M(1<=M<=50,000)条双向泥土道路,编号为1..M. 道路i连接牛棚P1_i和P2_i (1 <= ...
- 【POJ1144】Network(割点)(模板)
题意:给定一张无向图,求割点个数 思路:感谢CC大神http://ccenjoyyourlife.blog.163.com/的讲解 割点的定义就是某个联通块中删去此点连通性发生变化的的点 有两种割点: ...
- 下拉菜单的option的value属性值问题
下拉菜单的所有option都必须有value值,如果没有value会将标签中间的值传上去: 比如: <span class="el_spans">试卷级别:</s ...
- Linux 之 MySQL主从同步
MySQL主从同步 参考教程:[千峰教育] 1.架设两个虚拟服务器,都安装好mysql. 2.关闭防火墙和Selinux. service iptables stop setenforce 0 3.修 ...
- js-在url后面添加时间戳清除浏览器打开页面的缓存
这个解决办法还是在网上搜出来的,我还没有测试呢: 我有想既然可以添加时间戳,那可以添加随机数吗?我感觉是可以的,尽管没有测试过. 2018-3-13 几天前我就这个问题询问过我们的后台,加时间戳能否真 ...