I would like to make a strange flash drive: so that it had ext [234] and FAT32 at the same time.

But not with two partitions, but with one partition, that is, do something like ( /dev/sdf is a flash drive):

  1. We create the badblocks file, specify the blocks in a row in it, and the total volume of these bad blocks coincides with the FAT32 partition .
  2. Format the entire USB flash drive in ext [234] with the badblocks file ( mkfs.ext4 -b badblocks /dev/sdf ).
  3. Through fdisk ( fdisk /dev/sdf ) we create a single primary partition that is located in the area marked in the badblocks .
  4. Formatting /dev/sdf1 to FAT32

It is clear that in linux I have to mount such a flash drive with my hands, but under Windows it will pick up automatically.

Perhaps there is some HOWTO on this topic, I just did not find it on the first attempt.

    3 answers 3

    in order for the ms / windows operating system to mount the partition with its “native” fat file system, it doesn’t require the tweaks that are presented in the question.

    it is necessary and sufficient that this partition be the first on usb-storage (aka “flash drive”), which has a removable bit installed.

    all other sections, whatever the file system, for ms / windows (without any specialized tools) remain “out of sight” - only the first section is perceived.

    • I think you inattentively read the question. - Hi-Angel
    • @ Hi-Angel, I think the author’s final goal caught right. - aleksandr barakin
    • No, he wrote exactly what he wanted to do — perhaps for the sake of it — as if, a secret carrier in an explicit medium. If he wanted to make just two logical sections, he didn’t ask the exact question. - Hi-Angel
    • @ Hi-Angel, for the vast majority of users the mere fact of the existence of the second section of the extracted block device will be a secret. It’s not interesting for me to discuss who actually meant what . - aleksandr barakin
    • No, Windows will show the second partition as unallocated space (somewhere in disk utilities) . Why the hell would answer the question, even if “ it ’s not interesting what the author meant ” ©? - Hi-Angel

    I believe that we are talking about this reception . The method consists in switching between two partition tables, each of which has one partition. In one of them, when creating the file system, a section received a large sequence of "broken blocks" at the input, bypassing the location of the section from the second table.

    On the flash drive, only one of these two is visible at a time, switching occurs by ... rewriting the partition table.

    Disk layout

    It is assumed that in the normal state the flash drive contains a partition table, from which only the file system with the "green" space is visible. When "quietly and quietly", you can write another partition table (using a tip to keep it in the last sector of the disk, you just need to bypass it with other tools) and thereby gain access to the "secret partition", losing access to the main one. Having done the job, you can return the original partition table back by returning the flash drive to its normal state.

    What file systems will be on the external and internal partitions is completely unimportant (as long as the file system is able to bypass the "bad" blocks). Windows can easily see both partitions provided that the partition table is rewritten (and the operating system is aware of this fact) and a compatible file system on them (for example, FAT32). That is, if you forget to return the original partition table to its place, Windows in this case will successfully see the secret partition.

    This section should not be made large because the “bad blocks” within the file system are usually listed as “always busy” in all sorts of graphical tools. So if the disk is empty (there are no files and folders, including hidden ones), and a significant amount of space is occupied on it (much more than on the disk of the whole “raw place” minus the FS structure), then this may be a signal that that the disk has a similar thing.

      Here is a rather old, but fun instruction. Or not?

      • No, there is not exactly what you need - there is just how to create the correct partition table on a flash drive - chernomyrdin
      • And what is it for? A section within a section? Well, there is an extended partition in which you can make as many logical logical types as necessary. Section in the file to hide? This also exists, but judging from the question, both sections should be visible. It is not clear ... - Anton Reshin