Absolute startaddress (sector)
Hello,
Can someone tell me how I can find what the absolute startaddress is of a given file? (eg /etc/fstab) (on my harddisk in sectors) ? Thanks |
If by sectors you mean LBA or block address, debugfs may be what you want.
Try this: Find the device that /etc/fstab is on (mine is dev/mapper/vg00-lv01): Code:
# mount Code:
# debugfs -R 'stat /etc/fstab' /dev/mapper/vg00-lv01 Code:
# dd if=/dev/mapper/vg00-lv01 bs=4096 count=1 skip=75784 you would need this information, but I hope this helps. |
Quote:
This is what I am looking for ! Why I need this ? I am studying the working of Grub. And Grub starts the second stage after executing the first one. I ask myself : How is it possible that the first stage find the second one? => there must be a "hard coded" link in stage 1. (absolute block list I believe) I want to find this link in stage 1. And afterward : How do stage 2 find its menu.lst (grub.conf). This must also be "coded" : but now within the filesystem. I want to know fow stage 2 finds this menu.lst (I got one the grub> prompt, and I asked myself : where is grub looking for its menu.lst? When I give grub> configfile hd(0,6)/grub/menu.lst it starts this file. So the original link must be missing. I want to correct this by hand. OKe OKE I know I can correct this by reinstalling grub. I will do this when I understand how grubs works. |
For the record, I have to say that this is one of the most educational posts I've ever seen in the newbie forums and maybe even on the whole site. Thanks for the great tips tommylovell!
|
I tried to do this on "stage2"
And this is what I get : What will be the absolute startsector of this file ? Quote:
Who can help ? |
Maybe something like
Code:
DEVICE=/dev/sda7 |
Once grub is installed, I don't think you can think of stages 1 and 2 as files---they are not visible with normal filesystem tools. e.g.: Stage 1 is simply the first sector of the drive (or--in some cases--the partition)
|
the stage1 and stage1.5 code that is actually executed at boot time are not visible as files.
(The grub install copies /boot/grub/stage1 and possibly /boot/grub/e2fs_stage1_5 to new disk locations.) If /boot is in an ext2/3 filesystem, I think 'stage2' is executed from there. I'm sure you've probably seen this in the 0.97 Grub Manual: Code:
Chapter 10: GRUB image files 29 '/boot' ext2/3 partition, you would have: the 'stage1' in the MBR, sector0; and 'e2fs_stage1_5' in the "the area right after an MBR". On my system it's not there. I don't know where it is, but by virtue of the "block list", 'stage1' can find and pass control to it. 'e2fs_stage1_5' understands the ext2/3 filesystem, so it can easily find files. If you want the sector address from the beginning of the filesystem (i.e. partition), it's the blockaddress from debugfs times 8, as the blocksize is 4096 (on my system) and a sector is 512 bytes... Code:
[root@athlon4k6 ~]# debugfs -R 'stat grub/stage2' /dev/sda1 To find the absolute sector, you need to know where the partition starts. Code:
[root@athlon4k6 ~]# fdisk -lu /dev/sda And here it is accessed by absolute address. Code:
[root@athlon4k6 ~]# dd if=/dev/sda bs=512 count=1 skip=278519 | xxd | head Code:
[root@athlon4k6 ~]# xxd /boot/grub/stage2 | head |
All times are GMT -5. The time now is 02:20 PM. |