From: Aastha Mehta <aasthakm@gmail.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: How do I find the physical block number?
Date: Wed, 16 Apr 2014 15:27:38 +0200 [thread overview]
Message-ID: <CAEx9m44NE7sFAcOdPMc=mhye=hkhLgVMfmu_mbP4wzp_bGh_rA@mail.gmail.com> (raw)
Hello,
I have created a 500GB partition on my HDD and formatted it for btrfs.
I created a file on it.
# echo "tmp data in the tmp file.." > /mnt/btrfs/tmp-file
# umount /mnt/btrfs
Next I want to know the blocks allocated for the file and I used
filefrag for it. I get some information as follows -
# mount -o max_inline=0 /dev/sdc2 /mnt/btrfs
# filefrag -v /mnt/btrfs/tmp-file
Filesystem type is: 9123683e
File size of /mnt/btrfs/tmp-file is 27 (1 block, blocksize 4096)
ext logical physical expected length flags
0 0 65924123 1 eof
/mnt/btrfs/tmp-file: 1 extent found
Now, I want to read the same data from the disk directly. I tried the
following -
block 65924123 = byte (65924123*4096) = 270025207808
# dd if=/dev/sdc2 of=tmp-file skip=270025207808 bs=1 count=4096
# cat tmp-file
I cannot read the file's contents but some garbage.
I read somewhere that the physical block number shown in filefrag may
actually be a logical block for the file system and it has an
additional translation to physical block number. So next I tried the
following -
# btrfs-map-logical -l 65924123 /dev/sdc2
mirror 1 logical 65924123 physical 74312731 device /dev/sdc2
mirror 2 logical 65924123 physical 1148054555 device /dev/sdc2
I again tried reading the block 74312731 using the dd command as
above, but it is still not the right block.
I want to know what does the physical block number returned by
filefrag mean, why there are two mappings for the above block number
and how I can find the exact physical disk block number the file
system actually writes to.
My sdc has the following partitions:
Device Boot Start End Blocks Id System
/dev/sdc1 2048 419432447 209715200 83 Linux
/dev/sdc2 1468008448 2516584447 524288000 83 Linux (BTRFS)
/dev/sdc3 419432448 1468008447 524288000 83 Linux
Thanks,
Aastha.
next reply other threads:[~2014-04-16 13:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 13:27 Aastha Mehta [this message]
2014-04-16 20:59 ` How do I find the physical block number? Aastha Mehta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEx9m44NE7sFAcOdPMc=mhye=hkhLgVMfmu_mbP4wzp_bGh_rA@mail.gmail.com' \
--to=aasthakm@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).