In the context of verifying https://trello.com/c/lh0QdXbP/2737-1-verify-behavior-with-ptablefs-in-the-same-disk (internal link) it was needed to create a virtual disk with a filesystem and an empty partition table on it. Thanks to @wfeldt, I manage to prepare it following below steps:
-
With an Ext4 filesystem
# Create a 10GB virtual disk dd if=/dev/zero of=~/virtual-disk-1 bs=1M count=10240 # Create an Ext4 filesystem on it mkfs.ext4 -F ~/virtual-disk-1 # Add an empty msdos partition table (kudos to @wfeldt) echo -ne '\x55\xaa' | dd of=~/virtual-disk-1 bs=1 seek=510 conv=notrunc # Check everything looks "fine" file -k ~/virtual-disk-1 # ➜ ~/virtual-disk-1: DOS/MBR boot sector\012- DOS/MBR boot sector\012- Linux rev 1.0 ext4 filesystem data, UUID=3259616b-2345-40f4-b8ab-2ebfb3a05e17 (extents) (64bit) (large files) (huge files)\012- data
-
With a BTRFS filesystem: an Ext4 and BTRFS. When not using mentioned Linuxrc variable, errors are shown to the user.
# Create a 10GB virtual disk dd if=/dev/zero of=~/virtual-disk-2 bs=1M count=10240 # Create a BTRFS filesystem on it mkfs.btrfs ~/virtual-disk-2 # Add an empty msdos partition table (kudos to @wfeldt) echo -ne '\x55\xaa' | dd of=~/virtual-disk-2 bs=1 seek=510 conv=notrunc # Check everything looks "fine" file -k ~/virtual-disk-2 # ➜ ~/virtual-disk-2: DOS/MBR boot sector BTRFS Filesystem sectorsize 4096, nodesize 16384, leafsize 16384, UUID=f5040703-37de-4acd-9793-fa254abed8b9, 131072/1073741824 bytes used, 1 devices\012- DOS/MBR boot sector\012- data ``