linux磁盘第一个扇区分析,[转]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

使用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中移动目录和到指定目录和移动目录中的数据到指定目录

#这里表示将目录node-v12.13.1-linux-x64移动到/usr/local/中重命名为node,所以node目录可以不存在[root@alone ~]# mv node-v12.13.1 ...

Linux中使用sendmail发送邮件,指定任意邮件发送人

一.使用任意发件人发送邮件 echo .com -s .com 其中s表示主题.

随机推荐

关于Xcode6创建的工程在Xcode5打开

Xcode6创建的工程在Xcode5打开- 4.0只显示3.5大小的问题 只需要在工程里添加Default-568h@2x.png,即可以解决

一个等待页面加载完毕的loading动画

1 html 部分

nodeschool.io 9

~~ JUGGLING ASYNC ~~ 其实就是一个循环,在循环里面输出的顺序,和排列后在外面的顺序不一样,这是为什么呢? 用第三方async包,直接报错了…… This problem is th ...

JS 数组的基础知识

数组 一.定义 1.数组的文字定义 广义上说,数组是相同类型数据的集合.但是对于强类型语言和弱类型语言来说其特点是不一样的.强类型语言数组和集合有以下特点. 数组强类型语言:1.数组里面只能存放相同数 ...

SQL优化的四个方面,缓存,表结构,索引,SQL语句

一,缓存 数据库属于 IO 密集型的应用程序,其主要职责就是数据的管理及存储工作.而我们知道,从内存中读取一个数据库的时间是微秒级别,而从一块普通硬盘上读取一个IO是在毫秒级别,二者相差3个数量级.所 ...

java转换流

转换流是把字节流转换成字符流,比如往一个文件中写内容,原本是一个字节一个字节的写,转换为字符流后,我们可以一个字符串,一个字符串的写,书写中文很方便 转换流class: OutputStreamWri ...

C 语言---漂亮的宏定义

写好C 语言,漂亮的宏定义很重要,使用宏定义可以防止出错,提高可移植性,可读性,方便性等等.下面列举一些成熟软件中常用得宏定义. 1.防止一个头文件被重复包含 #ifndef COMDEF_H #de ...

IO 异常:The Network Adapter could not establish the connection 怎么解决

IO 异常:The Network Adapter could not establish the connection 怎么解决

DirectX11 初探XMVECOTR&XMMATRIX

初探DX11的数学库:向量XMVECOTR,矩阵XMMATRIX |XMVECTOR(XNA数学库的向量) DirectX中的一个核心数据类型为 XMVECTOR对它的运算可以使用SIMD指令集加速( ...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值