I used to create two partitions on pendrives that would be used either on Windows or GNU/Linux.

The first partition I'd format with ntfs, the second one with ext4. This way Windows would not see the second partition and would not ask to format when plugged in.

Since one of the last updates to Windows 10, this trick does not work anymore.

These pendrives I'm talking about are given to teachers at schools that use random GNU/Linux distributions but at home use Windows 10. When they get back to the school from home they realize that the ext4 partition is gone, as they just clicked 'yes' when Windows asked to format the partition.

I have tried to hide the second partition with parted, but I don't find the right switch.

What should I do in order to hide/protect the ext4 partition on the pendrive from Windows 10?

  • It seems Microsoft is really trying hard to make it difficult for linux. Is it important that the second partition has ext4 (or some other linux file system)? Do you need to preserve links or permissions? Maybe it would work withUDF? You can try according to this link, tanguy.ortolo.eu/blog/article93/usb-udf -- an alternative would be to use USB drive with a mechanical switch (microswitch) to make it read-only. – sudodus Sep 26 '17 at 8:39
  • 1
    This is a windows question and windows problem. Please use superuser.com And I bet if you are admin on windows 10 you are always allowed to format USB. And thus will always get it prompted. Answer is likely to add ext4 support to windows. – Rinzwind Sep 26 '17 at 8:57
  • 2
    @Rinzwind, It seems to me that the problem is that Windows has changed from ignoring linux partitions to prompting the user the format them. This has happened in my son's Windows 10 too. The problem is how to protect linux file systems. – sudodus Sep 26 '17 at 9:00
  • They started using a different method for adding drive letters it seems. Nothing we can do about that. This needs to be fixed or taken care of on Windows – Rinzwind Sep 26 '17 at 9:05
  • UDF is accepted by Windows (no prompting to format), and it is possible to modify and store linux style permissions. I was testing it a couple of minutes ago. – sudodus Sep 26 '17 at 9:08

1. UDF can replace ext4 to protect a partition with linux style

  • The problem is that Windows 10 has changed from ignoring a second partition with the linux ext4 file system to prompting the user the format it.
  • Windows 10 does not prompt the user to format UDF, the Universal Disk Format.

UDF is described in the following links,

UDF provides a workaround that helps protect a partition with linux style

  • links and
  • individual permissions for files and directories.

It is even possible to use UDF in the casper-rw partition of a persistent live drive, illustrated by the following screenshot of Lubuntu 16.04.1 LTS,

enter image description here


  • Install udftools if necessary

    sudo apt-get install udftools
  • Create a partition table with gparted or gnome-disks

  • Erase confusing data with dd (risky!)

    sudo dd if=/dev/zero of=/dev/sdxn bs=1M count=1  # wipe first MiB

    where x is the drive letter and n is the partition number. Check and double check that everything is correct before you press the Enter key to run the dd command line!

  • Create UDF file system (risky!)

    sudo mkudffs -b 512 --media-type=hd --lvid=my-label /dev/sdxn

    where x is the drive letter and n is the partition number. Check and double check that everything is correct before you press the Enter key!


But it might be difficult to find good tools to repair UDF. Maybe Windows can fix some errors. So it is important to backup the content regularly, so that the content is not lost, if the file system gets damaged.

2. ext4in a file and loop mount to use it

If you must have ext4, you can put it in a file and loop mount to use it from linux. I don't think that Windows will bother to look in the file.

This method is the same as for a casper-rw file for persistence.


  • Create mount points (only once)

    sudo mkdir -p /mnt/lp1
    sudo mkdir -p /mnt/sd1
  • Mount the partition, where you intend to create the file.

    sudo mount /dev/sdxn /mnt/sd1

    where x is the drive letter and n is the partition number.

  • Create a file. In the FAT32 file system the maximum file size 4 GB, but in NTFS and UDF, the size is limited by the size of the partition.

    The following command line will make an empty file with the size (bs * count, in this case 1MiB*8KiB) = 8GiB.

    sudo dd if=/dev/zero of=/mnt/sd1/linux-fs bs=1M count=8K
  • Create an ext4 file system in the file

    sudo mkfs.ext4 /mnt/sd1/linux-fs
  • In order to use the file in linux, loop mount it (you can provide a script or desktop file for the end users),

    sudo mount -o loop /mnt/sd1/linux-fs /mnt/lp1

    or maybe you would prefer something like this,

    sudo mount -o defaults,users,loop /mnt/sd1/linux-fs /mnt/lp1
  • I assume that you already create a structure of directories, ownerships and permissions in the ext4 partition, and the same structure should work in this ext4 file too.

The content will be available via the mount point /mnt/lp1, which means that you and an end user can read and write files and directories, just like an ext4 file system in a partition. But Windows does not prompt the user the format it.

  • My UDF flash drive seems to work in Windows10 but has not been visible in Ubuntu since was first created? Do I need to loop mount the partition to see it? – C.S.Cameron Sep 26 '17 at 19:30
  • 1. A partition with UDF should be visible in Ubuntu after visiting Windows. You mount it like you mount any partition with sudo mount <device> <mountpoint>, but I'm checking now with my persistent live drive, and it auto-mounts the UDF partition with the label 'casper-rw'; 2. A file system that is inside a file should be loop mounted. I don't think it will auto-mount (unless as part of booting a persistent live system) ; Summary: In both cases, Windows did not prompt to format any of them or destroy them. Linux can see and use them, my test files and directories were there and available. – sudodus Sep 26 '17 at 19:55
  • 1
    Creating the partition in Linux would not automount it when plugging in the device, so I opted to format it in Windwos with "format <driveLetter>: /fs:UDF /q" which automounted automaticcaly in Manjaro and Ubuntu. Symlinks and permissions are preserved just fine. Anyone interested please note that Windows XP has no UDF support. Thanks a lot! – Joe Oct 3 '17 at 11:21
  • @Joe, You found a good solution, and I'm glad I could help you along the way :-) – sudodus Oct 3 '17 at 11:56
  • Now I have a new problem, since files that I hide under windows no longer show up in linux, not even "ls -a", I could probably remount the usb drive with the unhide option, but this is not something I would be able to tell any of the teachers I hand out these usb drives... – Joe Oct 8 '17 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.