[转]Linux中如何读写硬盘上指定物理扇区
读指定物理扇区:
dd if=<源设备> of=<输出设备或文件> skip=<指定扇区值> bs=512 count=1
写指定物理扇区:
dd if=<输入设备或文件> of=<输出设备> seek=<指定扇区值> bs=512 count=1
实例:
我们以文件/root/Linux-2.6.32.36-0.5/REPORTING-BUGS为例,该文件大小为4K。
通过debugfs,可以看到REPORTING-BUGS文件所占用的文件系统块号为584933,/dev/sda1分区文件系统类型为ext4,默认块大小4K。
则REPORTING-BUGS文件所在584933转换为扇区(512字节)为584933×8=4679464
而分区/dev/sda1的起始物理扇区为2048,因此REPORTING-BUGS文件在sda硬盘上的物理扇区起始位置为584933*8 + 2048=4681512。
通过dd命令读取指定4681512物理扇区,然后查看读取的数据,直接读写硬盘物理扇区的方法得到验证。
root@ubuntu:~/linux-2.6.32.36-0.5# ls -l REPORTING-BUGS
-rw-r–r– 1 root root 3371 2011-05-30 07:39 REPORTING-BUGS
root@ubuntu:~/linux-2.6.32.36-0.5# pwd
/root/linux-2.6.32.36-0.5
root@ubuntu:~/linux-2.6.32.36-0.5# du -s REPORTING-BUGS
4 REPORTING-BUGS
root@ubuntu:~/linux-2.6.32.36-0.5#
root@ubuntu:~/linux-2.6.32.36-0.5# debugfs /dev/sda1
debugfs 1.41.14 (22-Dec-2010)
debugfs: cd /root
debugfs: ls
debugfs: cd linux-2.6.32.36-0.5
debugfs: ls
debugfs: bmap REPORTING-BUGS 0
584933
debugfs:
root@ubuntu:~# dd if=/dev/sda of=test.dump skip=4681512 bs=512 count=1
root@ubuntu:~/linux-2.6.32.36-0.5# fdisk -lu
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000444d0
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 40894463 20446208 83 Linux
/dev/sda2 40896510 41940991 522241 5 Extended
/dev/sda5 40896512 41940991 522240 82 Linux swap / Solaris
root@ubuntu:~/linux-2.6.32.36-0.5#
root@ubuntu:~# cat test.dump
[Some of this is taken from Frohwalt Egerer's original linux-kernel FAQ]
What follows is a suggested procedure for reporting Linux bugs. You
aren’t obliged to use the bug reporting format, it is provided as a guide
to the kind of information that can be useful to developers – no more.
If the failure includes an “OOPS:” type message in your log or on
screen please read “Documentation/oops-tracing.txt” before posting your
bug report. This explains what you should do with the “Oops” information
to root@ubuntu:~#
root@ubuntu:~/linux-2.6.32.36-0.5# pwd
/root/linux-2.6.32.36-0.5
root@ubuntu:~/linux-2.6.32.36-0.5# cat REPORTING-BUGS
[Some of this is taken from Frohwalt Egerer's original linux-kernel FAQ]
What follows is a suggested procedure for reporting Linux bugs. You
aren’t obliged to use the bug reporting format, it is provided as a guide
to the kind of information that can be useful to developers – no more.
If the failure includes an “OOPS:” type message in your log or on
screen please read “Documentation/oops-tracing.txt” before posting your
bug report. This explains what you should do with the “Oops” information
to make it useful to the recipient.
Send the output to the maintainer of the kernel area that seems to
be involved with the problem, and cc the relevant mailing list. Don’t
worry too much about getting the wrong person. If you are unsure send it
to the person responsible for the code relevant to what you were doing.
If it occurs repeatably try and describe how to recreate it. That is
worth even more than the oops itself. The list of maintainers and
mailing lists is in the MAINTAINERS file in this directory. If you
know the file name that causes the problem you can use the following
command in this directory to find some of the maintainers of that file:
perl scripts/get_maintainer.pl -f <filename>
转自 http://ilinuxkernel.com/?p=236
[转]Linux中如何读写硬盘上指定物理扇区的更多相关文章
- 使用HDTune规避硬盘上损坏的扇区
如何使用HDTune扫描磁盘上的错误在网上已经有很多帖子了,但扫描到之后如何用HDTune来规避硬盘上损坏的扇区呢? HDTune并不能直接规避,而是需要重新划分磁盘的卷.HDTune一行有50个小方 ...
- linux中利用iptables+geoip过滤指定IP
1. 前提条件 iptables >= 1.4.5 kernel-devel >= 3.7 2. 安装依赖包 代码如下 复制代码 # yum install gcc gcc-c++ m ...
- Linux中添加新硬盘后对硬盘的分区以及挂载
转自:https://www.linuxidc.com/Linux/2018-06/152958.htm 我将使用VM来进行模拟 先使用df看下我的电脑硬盘信息: df -h 可以看到只有一个sda1 ...
- Linux中检查本地系统上的开放端口列表的方法
在 Linux 中很少有用于此目的的实用程序.然而,我提供了四个最重要的 Linux 命令来检查这一点. 你可以使用以下四个命令来完成这个工作.这些命令是非常出名的并被 Linux 管理员广泛使用.n ...
- linux中使sqlplus能够上下翻页
安装包链接:https://pan.baidu.com/s/1WsQTeEQClM88aEqIvNi2ag 提取码:s241 rlwrap-0.37-1.el6.x86_64.rpm 和 rlwra ...
- 在linux中禁用一块硬盘
笔记本采用固态加机械的硬盘组合使用中完全用不到机械部分 但它总是在启动后运行并发出响声 1 启动后的禁用 无需重启 (sdx是你的磁盘 udev的更新可能会导致磁盘重新出现 在向系统添加/删除磁盘也 ...
- linux中添加一个用户到指定用户组的两种方式,修改一个用户到指定用户组的一种方式
添加一个用户到指定用户组: gpasswd –a 用户名 组名usermod –G 组名 用户名 //第一种:gpasswd –a 用户名 组名 [root@localhost ~]# id user ...
- linux中mysql连接不上,服务启动失败等问题解决
confluence问题解决方式 1)针对confluence访问页面报500与连接失败等问题 首先我们登陆部署confluence的服器 10.15.4.115 2)重启mysql服务,发现重启失败 ...
- 关于linux中移动目录和到指定目录和移动目录中的数据到指定目录
#这里表示将目录node-v12.13.1-linux-x64移动到/usr/local/中重命名为node,所以node目录可以不存在[root@alone ~]# mv node-v12.13.1 ...
随机推荐
- CF1042E Vasya and Magic Matrix
感觉不会期望. 首先把所有格子按照权值从小到大排一下序,这样一共有$n * m$个元素,每个元素有三个属性$x, y, val$. 下文中的下标均为排序后的下标. 这样子我们就可以推出公式: $f_i ...
- 8.使用hydra对端口进行爆破
如果对开启端口的服务不清楚,请看我之前写的文章:https://www.cnblogs.com/bmjoker/p/8833316.html 2018,网站的防护(sql,xss...)的安全保护也已 ...
- 20169219 linux内核原理与分析第二周作业
"linux内核分析"的第一讲主要讲了计算机的体系结构,和各寄存器之间对数据的处理过程. 通用寄存器 AX:累加器 BX:基地址寄存器 CX:计数寄存器 DX:数据寄存器 BP:堆 ...
- ExecuteNonQuery(),ExecuteScalar(),ExecuteReader的用法-转
using System.Data.SqlClient;...SqlConnection conn = new SqlConnection(@"server=ws7\leosql;datab ...
- win10外接显示器时有些应用和里面的字体显示比较模糊
打开系统设置 - 选择显示 - 选中外接的显示器 - 点击 "高级缩放设置" 进去后将 "允许 Windows 尝试修改应用,使其不模糊"打开,然后关闭应用再 ...
- d190305面试题01总结
题目一: 题目二: 题目三: 类中的某个成员变量可以被他和他的子类访问,应该用protected 知识点: 1.类中public修饰的属性,方法可以被该类,子孙类和外部类访问. 2.类中protect ...
- 软件包管理(rpm&yum)
一.rpm包管理器 rpm是一个功能强大的包管理工具,可用于构建,安装,查询,验证,更新和卸载软件包. 用法: rpm [OPTION...] 配置文件: /var/lib/rpm/ 已安装rpm包的 ...
- 解决request中文乱码问题
因为request请求都是ISO-8859-1,而jsp页面是采用UTF-8编码,所以当传递的参数有中文时,页面会出现乱码,但是可以将取到的数据通过String的构造函数使用指定的编码类型重新构造一个 ...
- 牛客假日团队赛1 A.蹄球锦标赛
链接: https://ac.nowcoder.com/acm/contest/918/A 题意: 为了准备即将到来的蹄球锦标赛,Farmer John正在训练他的N头奶牛(方便起见,编号为1-N,其 ...
- BZOJ1816(二分)
反思 由于受我第一次遇到的构造最多三角形的题的影响,这种几个分成一组最多多少组的题我老是往贪心上想. 事实上一般贪心也能贪,但这道题,还有突然想起的前些天做的cf140C,都是用二分可以更简单地解决, ...