Bug 197733
Summary: | Unable to mount UFS 44bsd partitions | ||
---|---|---|---|
Product: | IO/Storage | Reporter: | Yannick Le Teigner (yannick.leteigner) |
Component: | Block Layer | Assignee: | Jens Axboe (axboe) |
Status: | NEW --- | ||
Severity: | low | CC: | richard |
Priority: | P1 | ||
Hardware: | All | ||
OS: | Linux | ||
Kernel Version: | 4.11.6 | Subsystem: | |
Regression: | No | Bisected commit-id: | |
Attachments: | Patch to recognize FreeBSD partitions using absolute addressing |
Description
Yannick Le Teigner
2017-11-03 13:32:38 UTC
Can you give the output of this: uname -a Can you also give the output of "partx --show /dev/nbd0" after removing the patch? Before the patch, Linux treated all 3 BSD partition types (FreeBSD, OpenBSD and NetBSD) as having absolute block addressing for the subpartitions. This may be the way that FreeBSD used to do things but in recent releases (Freebsd 10 and FreeBSD 11) relative block addressing is used. Another work-around might be to copy the partition somewhere and change the partition id from a5 (FreeBSD) to either a6 (OpenBSD) or a9 (NetBSD). The fdisk utility using the t command can change it. <-- without the patch: gentoo-vm ~ # uname -a Linux gentoo-vm 4.11.5 #7 SMP Wed Nov 1 21:36:27 -00 2017 x86_64 Intel Core Processor (Skylake) GenuineIntel GNU/Linux gentoo-vm ~ # partx --show /dev/nbd0 NR START END SECTORS SIZE NAME UUID 1 63 41929649 41929587 20G 55000000-01 5 63 7547376 7547314 3.6G 6 7547377 21384118 13836742 6.6G 7 21384119 23480594 2096476 1023.7M 8 23480595 41929586 18448992 8.8G <-- with the patch: gentoo-vm ~ # uname -a Linux gentoo-vm 4.11.6-gentoo #8 SMP Wed Oct 25 15:24:33 -00 2017 x86_64 Intel Core Processor (Skylake) GenuineIntel GNU/Linux gentoo-vm ~ # partx --show /dev/nbd0 NR START END SECTORS SIZE NAME UUID 1 63 41929649 41929587 20G 55000000-01 5 63 7547376 7547314 3.6G 6 7547377 21384118 13836742 6.6G 7 21384119 23480594 2096476 1023.7M 8 23480595 41929586 18448992 8.8G I've tried to use the workaround, and it seems to work! gentoo-vm ~ # ls /dev/nbd0* /dev/nbd0 /dev/nbd0p1 /dev/nbd0p5 /dev/nbd0p6 /dev/nbd0p7 /dev/nbd0p8 gentoo-vm ~ # fdisk /dev/nbd0 Welcome to fdisk (util-linux 2.28.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/nbd0: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x55000000 Device Boot Start End Sectors Size Id Type /dev/nbd0p1 * 63 41929649 41929587 20G a5 FreeBSD Command (m for help): t Selected partition 1 Partition type (type L to list all types): a6 Changed type of partition 'FreeBSD' to 'OpenBSD'. Command (m for help): p Disk /dev/nbd0: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x55000000 Device Boot Start End Sectors Size Id Type /dev/nbd0p1 * 63 41929649 41929587 20G a6 OpenBSD Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. gentoo-vm ~ # hexdump /dev/nbd0p7 | grep -w '0001 0000 0000 0000 0000 0000 1954 0001' 0002550 0001 0000 0000 0000 0000 0000 1954 0001 0004550 0001 0000 0000 0000 0000 0000 1954 0001 ... gentoo-vm ~ # mount -t ufs -o ufstype=44bsd /dev/nbd0p7 /mnt/img/ gentoo-vm ~ # df -h | grep nbd /dev/nbd0p7 1007M 2.0K 926M 1% /mnt/img I want to try and duplicate the problem, so I will test with old FreeBSD systems. I will install a machine with FreeBSD 6.0, see if it has the problem and then go from there. Success. I duplicated the problem by installing FreeBSD 6.0 on a Linux 4.4.88 x86 system (which apparently now includes the patch). Linux could not see the FreeBSD subpartitions. I then used fdisk to change the FreeBSD partition id A5 to A9 (NetBSD), rebooted Linux and then I saw the FreeBSD partitions. Here are a couple of ways to fix this issue. 1) Figure out an easy way to tell the difference between older FreeBSD partitions using absolute addressing versus newer FreeBSD partitions using relative addressing. 2) Create a Linux kernel parameter to turn off FreeBSD relative subpartition addressing. I will investigate and try fix 1) If it is not easy we can go with 2) Created attachment 260525 [details]
Patch to recognize FreeBSD partitions using absolute addressing
It turns out that there was a easy solution and attached is a patch.
The new patch checks the FreeBSD C partition offset and if it is zero then
relative addressing is used.
That was quick! Patch is working fine on my machine with the original FreeBSD test image. :) Thanks! After more research, I determined that Linux stopped reading FreeBSD UFS partitions when FreeBSD 9 was released. My original patch fixed version 9 and later versions but broke FreeBSD 8 and all earlier versions. This new patch will fix all versions of FreeBSD. The patch is applied to Linux 4.16 release candidate 1: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0a4b6e2f80aad46fb55a5cf7b1664c0aef030ee0 Look at block/partition/msdos.c Hopefully the patch will filter back to older systems after 4.16 is formally released. Thanks to Jens Axboe and Linus Torvalds. Version 4.16 is out and contains the patch: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/block/partitions/msdos.c?id=5f15684bd5e5ef39d4337988864fec8012471dda Versions 4.15.16, 4.14.33, 4.9.93, 4.4.127 and 3.18.103 now contain the patch too: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?h=linux-4.4.y&id=52a9a9b18d395b65406e2a05ea4bb6ffd2620c12 |