How can I mount a specific block range from a block device (or byte range from a file), or at least expose it as a loop device without loading the full MBR/GPT ?
I have a few use relevant use cases :
Given a hard drive with a broken MBR/GPT, I want to mount a partition whose start/end sectors are known (as well as block size of course), but
dd
'ing it first isn't an option, due to partition size for exampleI have a backup image of a full disk (with partition table) in a file, i want to mount a specific partition from it without exposing all partitions as devices
I want to do some ill-advised steganography by hiding a FS in a block device or file with start/end offsets to make it less obvious (I know it's not a good option due to entropy and access mappings, that's not the point here)
Last use case is more of a hack inspired by first and second use cases, which are actual problems I encountered.
I found a few related questions, like those :
- How to map only a part (byte- or block-based) of a device file or regular file to a loop device?
- https://stackoverflow.com/questions/3520459/linux-hard-disk-direct-access-without-any-fs-from-c-program
But the (valid) answers to these questions are often to dd
partition or recreate MBR which is not an option here.