bcachefs icon indicating copy to clipboard operation
bcachefs copied to clipboard

mount by filesystem uuid or label

Open piedar opened this issue 6 years ago • 14 comments

Looks like it's not yet possible to mount by filesystem uuid or label. ZFS implements this with zpool.cache and userspace daemons, but I think bcachefs can make it even easier.

It might require some redundant device metadata to answer questions like "to which filesystem does this device belong?" before actually mounting any filesystem. Then the kernel module could expose each filesystem's device pool as a disk alias to allow something like

mount -t bcachefs /dev/disk/by-uuid/<external-uuid> /mnt/pool

And the best feature: write-once /etc/fstab!

UUID=<external-uuid>    /mnt/pool    bcachefs    defaults    0 1

A filesystem's external uuid is stable, right? Otherwise this plan becomes much less foolproof.

piedar avatar May 28 '18 23:05 piedar

So at least on debian-based systems, mounting by UUID or label is actually handled in userspace by libblkid from util-linux.

If you want to try it out, I have a prototype version of util-linux with bcachefs support

modelrockettier avatar Aug 24 '18 07:08 modelrockettier

@modelrockettier @koverstreet How do I mount a bcachefs disk group (foreground and background) with /etc/fstab, so grub can pick it up accordingly? Please see my reddit post here.

$ sudo bcachefs format /dev/nvme0n1p3 /dev/sdc1 --foreground_target /dev/nvme0n1p3 --promote_target /dev/nvme0n1p3 --background_target /dev/sdc1
External UUID:			c093338c-b395-4581-8288-82be715bf2af
Internal UUID:			930086d9-59fa-476d-b306-8c3c3da8c57f
Label:				
Version:			9
Block_size:			4.0K
Btree node size:		256.0K
Error action:			remount-ro
Clean:				0
Metadata replicas:		1
Data replicas:			1
Metadata checksum type:		crc32c (1)
Data checksum type:		crc32c (1)
Compression type:		none (0)
Foreground write target:	1
Background write target:	2
Promote target:			1
String hash type:		siphash (2)
32 bit inodes:			0
GC reserve percentage:		8%
Root reserve percentage:	0%
Devices:			2 live, 2 total
Sections:			members
Superblock size:		872

Members (size 120):
  Device 0:
    UUID:			73140b61-5181-4c8a-8b05-af45e424f1ce
    Size:			222.9G
    Bucket size:		256.0K
    First bucket:		0
    Buckets:			912796
    Last mount:			(never)
    State:			readwrite
    Group:			
    Data allowed:		journal,btree,data
    Has data:			(none)
    Replacement policy:		lru
    Discard:			0
  Device 1:
    UUID:			3b13fcab-082b-497b-a2c3-ce6c4efdab50
    Size:			4.5T
    Bucket size:		256.0K
    First bucket:		0
    Buckets:			19077224
    Last mount:			(never)
    State:			readwrite
    Group:			
    Data allowed:		journal,btree,data
    Has data:			(none)
    Replacement policy:		lru
    Discard:			0
Creating config file /etc/default/grub with new version
grub-probe: error: failed to get canonical path of `/dev/nvme0n1p3:/dev/sdc1'.
/usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory
/usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
Installing for i386-pc platform.
grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.
/usr/sbin/grub-probe: error: failed to get canonical path of `/dev/nvme0n1p3:/dev/sdc1'.
dpkg: error processing package grub-pc (--configure):
 installed grub-pc package post-installation script subprocess returned error exit status 1
Processing triggers for initramfs-tools (0.132) ...
Errors were encountered while processing:
 grub-pc
E: Sub-process /usr/bin/dpkg returned an error code (1)

This is how my fstab looks like. I really dont know how to handle a bcachefs disk group in fstab.

cat /etc/fstab 
# UNCONFIGURED FSTAB FOR BASE SYSTEM
/dev/disk/by-partuuid/b04533a8-efe2-4884-a703-63ba54eb48ad /               bcachefs rw,relatime 0 0
/dev/disk/by-partuuid/0e80457c-d028-4efa-b126-2efda6371c6d /               bcachefs rw,relatime 0 0
/dev/disk/by-partuuid/7c7b8528-2eb1-40b9-8ba9-18c71a4c0463 /boot           ext4     rw,relatime 0 2
/dev/disk/by-partuuid/7d2bc4b3-5d08-4448-97cc-208177da9403 /boot/efi       vfat     umask=0077  0 1

tristan-k avatar Aug 30 '18 20:08 tristan-k

any news on this? it would be nice to have something like that, because its a mess if you use bcachefs with many disks (I've other setups with 120disks)

colttt avatar Sep 10 '19 09:09 colttt

I see a lot of commits on this issue, is it possible yet? Any update you could give us?

RlndVt avatar Mar 10 '20 18:03 RlndVt

I made a little tool to solve exactly this problem: https://github.com/yshui/bcachefs-mount

yshui avatar May 03 '20 20:05 yshui

@RlndVt All this commits are linked here because they contains the string #1 in their commit message, but they are all irrelevant. I think it's better to move this issue to bcachefs-tools

Edit: Ah, bcachefs-tools repo doesn't take issues. Maybe close this and reopen? @piedar

yshui avatar May 03 '20 20:05 yshui

I made a little tool to solve exactly this problem: https://github.com/yshui/bcachefs-mount

Cool! And it's in Rust, lovely.

I'd love to pull this into bcachefs-tools - and I'd love to use Rust for more userspace code, so I'm happy to add the Rust dependency. Would you like to merge this into the bcachefs-toos repo, so I can pull it in?

If you call it mount.bcachefs, mount(8) should call it automatically.

koverstreet avatar May 03 '20 21:05 koverstreet

Would you like to merge this into the bcachefs-toos repo, so I can pull it in?

I would love to. But I am not sure how the build systems would fit together.

If you call it mount.bcachefs, mount(8) should call it automatically.

This tool doesn't take the usual mount options. I intend to make it more mount(8) compatible, but it would take some time.

yshui avatar May 03 '20 22:05 yshui

Having the makefile call cargo build for the mount.bcachefs target should work fine.

I'd like to get this merged in, we can continue to make improvements.

koverstreet avatar May 03 '20 23:05 koverstreet

Any update on this?

tyler274 avatar Dec 02 '20 03:12 tyler274

Per https://www.reddit.com/r/bcachefs/comments/l74b4n/why_bcachefs_does_not_support_specifying_disk_by/

There's also a mount.bcachefs tool that supports mounting by UUID, it needs to be documented - also, it's written in rust so it's not built by default.

https://github.com/koverstreet/bcachefs-tools/tree/master/rust-src

    <uuid>          
            External UUID of the bcachefs filesystem

So is this done? It was hard to figure out with all the bad backlinks... if it's not I'll make a new issue.

andrewbaxter avatar Jun 01 '23 09:06 andrewbaxter

It seems like it was added (moved from somewhere else?) here a couple months ago: https://github.com/koverstreet/bcachefs-tools/commit/1f8fc31ddc1975a1f2e7c2fa8f7f611eab761680

andrewbaxter avatar Jun 01 '23 09:06 andrewbaxter

At least on NixOS mountng by UUID (ex mount -t bcachefs abcdefgh-abcd-abcd-abcdef /my/mountpoint) works using the package provided scripts. This works with everything - mount, fstab, and systemd AFAICT.

I made https://github.com/koverstreet/bcachefs/issues/551 for continuing discussion about mounting by label. I think this issue could reasonable be closed.

andrewbaxter avatar Jun 04 '23 18:06 andrewbaxter

At least on NixOS mountng by UUID (ex mount -t bcachefs abcdefgh-abcd-abcd-abcdef /my/mountpoint) works using the package provided scripts. This works with everything - mount, fstab, and systemd AFAICT.

I made #551 for continuing discussion about mounting by label. I think this issue could reasonable be closed.

It seems like it might need UUID= now per https://github.com/koverstreet/bcachefs-tools/blob/master/rust-src/src/cmd_mount.rs#L182

    let (devs, sbs) = if opt.dev.starts_with("UUID=") {
        let uuid = opt.dev.replacen("UUID=", "", 1);
        devs_str_sbs_from_uuid(uuid)?
    } else if opt.dev.starts_with("OLD_BLKID_UUID=") {
...

andrewbaxter avatar Dec 09 '23 03:12 andrewbaxter