BtrFS on removable drive(s)? (maybe gparted?)

I like that BtrFS is self-healing and supports compression, but I’m not sure how to use it on removable drives (5TB USB3 backup drives). I mean, normally one uses fstab to declare compression use, but external drives aren’t normally included in fstab. I normally use Dolphin auto-connection-detection to mount these drives, but that doesn’t give the options for BtrFS during the mount process. Is there a standard way to do this (KDE)?

As a second question, I’ve noticed that there are two options when creating drives: “label” and “name.” Gparted supports both of these, but only during creation of a new partition table. Label and name both need to be declared as the same or else Dolphin doesn’t give a connection between “Devices” and “Removable Devices” in the “Places” panel (this may be a “bug”?). I guess my question is about the optimal way to set/update both ‘label’ and ‘volume’ on a removable storage device so that I don’t have to go back and create a new partition table (with Gparted) to get these synched (for non-confusing use in Dolphin). I hope that’s making sense…

I realize both these questions may be affected by LEAP version number - and if they are, please mention it!

Patti :slight_smile:

I would suggest a read of the man page for mkfs.btrfs and the btrfs wiki at

mkfs.btrfs -L "btrfs_test" /dev/sdb1

btrfs-progs v5.9 
See for more information.

Label:              btrfs_test
UUID:               3c94fc07-b94f-494a-80cc-1419eb25afd4
Node size:          16384
Sector size:        4096
Filesystem size:    14.76GiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP             256.00MiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Runtime features:   
Checksum:           crc32c
Number of devices:  1
   ID        SIZE  PATH
    1    14.76GiB  /dev/sdb1

 mount | grep sdb
/dev/sdb1 on /mnt type btrfs (rw,relatime,space_cache,subvolid=5,subvol=/)

sdb      8:16   1  14.8G  0 disk 
└─sdb1   8:17   1  14.8G  0 part /run/media/username/btrfs_test

Screenshot from 2020-12-29 11-53-07.png

TY for the links - my head is fuzzy from internetting and reading things that don’t talk about removable drives. :slight_smile:

Well all you need to do is ensure it’s finished writing (issue the sync command and let it finish before unplugging) before unmounting, treat any device as removable, or any removable as not… it’s just a ‘device’ connected to the computer interface, SATA, USB, eSATA etc… along with a mount point. I can hot swap or unbind SATA devices here, does that mean their removable when physically mounted in the computer? :wink:

My eyes! My eyes! :X

Increase the font or zoom in your browser :wink:

Hi Malcom - I learned about “sync” and USB’s a while ago (from this forum) - it’s a pretty big, but avoidable, gotcha (at least in KDE) for dummy (overworked? simple?) folks like me (but I’ve finally trained myself on this!). I was noticing that if label/name on the USB device were both well-defined, then the mount path in Dolphin (and in the file tree) uses that name persistently (rather than the big device ID string). This minimizes confusion (and associated errors) for brain-challenged multi-taskers like moi. Now the only question is how to make sure compression is turned-in when a BtrFS USB drive is mounted (in Dolphin). If a drive has a persistent label/name combination, maybe that could be done in fstab? I guess I could try to bing if that’s possible.

Then Mount with -o compress or -o compress-force your eyes :wink: your eyes :wink:

I expect you should be able to craft a udev rule to do all this with your specific devices.

My brain, my brain!! :beat-up:

I did see the mount options - and their use in fstab, etc. - so if I learn about “udev rules” I can train Dolphin to deal?
(learn something every day…)

Yes, look at using the likes of the UUID to idenify your disk device, look at the system udev rules (/usr/lib/udev/rules.d/) then put your rule in /etc/udev/rules.d/ and should be good to go.

I see a user here has a script:

Woah, thanks! Good stuff!

I doubt you should need to know much about formatting and mounting a removable drive…

I don’t think it makes any sense for a removable drive to be a subvolume, you’ll likely want to create a new BTRFS volume for anything removable.

Ordinarily, compression should be set as a mount option, I would expect not in a udev rule but maybe in your Dolphin connection string (at least that’s how I’d approach it)…

As for whether you should create an fstab entry, that would depend on whether you wanted the drive/disk mounted on boot and not when Dolphin connects…


Reading the question before you reply is also useful.

mount | grep sdb
/dev/sdb1 on /mnt type btrfs (rw,relatime,space_cache,subvolid=5,subvol=/)

Ans where is compression option that OP asked for?

I added several of my external drives to /etc/fstab such as:

**erlangen:~ #** grep WD25 /etc/fstab               
UUID=2f0030b8-7257-4cba-be3e-b33154cda052  /**WD25**                   ext4   noauto                        0  0 
**erlangen:~ #**

systemd automatically generates the following unit from the fstab entry:

**erlangen:~ #** systemctl cat WD25.mount  
**# /run/systemd/generator/WD25.mount**
# Automatically generated by systemd-fstab-generator 

Documentation=man:fstab(5) man:systemd-fstab-generator(8) 

**erlangen:~ #**

The following service asks for mounting the disk and copies /home to disk:

**erlangen:~ #** systemctl cat backup-home-WD25.service  
**# /etc/systemd/system/backup-home-WD25.service**
Description=Backup /home to USB disk 

ExecStart=/usr/bin/rsync -a --exclude=.cache /home/ /WD25/backup/home/ 
**erlangen:~ #**

Oooo… that sounds like a good idea. Now I have to research “Dolphin connection string” - see what’s available there…

Thank you - I guess I also need to research “fstab mount USB drive” - that might find something useful. Now that I think about it, it seems like a good idea not to mess around too much with KDE/Dolphin configurations because those may go away on updates, recoveries, etc. But fstab is almost always something you mess with, even between distros, and it’s really standardized. Still, making sure name/label are the same (when creating a partition table on a USB drive) is also a more or less permanent way of avoiding at least some of the confusion that can crop up in GUI linux interfaces (KDE/gnome/…) for removable devices. I remember when “by-ID” replaced /dev/sdaX, etc., way back in - what? OS11.x?
Not too much of a problem for Wizards, Gurus, and Shamans, but a headache for simple folk like myself. rotfl!

I still have to use MAN pages to be able to run diff! lol!lol!

(…though I did finally learn vi enough for survival when necessary!) rotfl!

Thanks again, Karl - it looks like the fstab method might work but I’m not sure since my USB drives are encrypted with LUKS (using the opensuse partitioner).

Created an encrypted filesystem on an USB stick and added it to /etc/fstab:

**3400G:~ #** grep /ENCRYPTED /etc/fstab    
UUID=70f9f54d-5c7b-4ff3-919c-185ba3f08b16  **/ENCRYPTED**              ext4   user,noauto                   0  0 
**3400G:~ #**

/ENCRYPTED is displayed in the sidebar of dolphin. Upon clicking I get prompted for the password and dolphin readily opens the folder.

OK, after messing around for a while - here is what I came up with which seems to work just fine (at least under OpenSuSE):

  1. Create a** new Partition Table** with gparted on empty USB device - set both “label” and “name” to be the same (I used BtrFS-3) - also format the drive BtrFS. Apparently, in order to get label and name the same, you have to use gparted. (It may not be possible to do this in the OS YaST partitioner.)
  2. Open **YaST Partitioner **and edit the new USB device.
  3. Choose options: Format Partition BtrFS; encrypt partition; mount (to create a working fstab entry) to location (I used: /run/patti/BtrFS-3) - also be sure to add fstab options: nofail,noauto
  4. (Also choose mounting by uuid - I think that’s default - I also selected “mountable by user” - this may not be necessary)
  5. I also added the fstab options: compress=lzo
  6. It will ask for encryption password
  7. Finish / OK …

After this, the drive should be formatted and fstab modified. Here’s my fstab afterward:

UUID=c4029cb5-c200-4462-98e1-31a604c209fe  /run/patti/BtrFS-3  btrfs  user,nofail,noauto,autodefrag,compress=lzo  0  0

Now, in Dolphin, it behaves just like any other (LUKS encrypted) USB drive you insert. EZ to mount, and it maintains it’s label as BtrFS-3 in the Dolphin “places”!

UNFORTUNATELY - I have no idea where the UUID in that fstab line came from. When I use blkid to correlate an identifiable UUID with the device mounted by fstab - the UUID listed in fstab doesn’t appear. (!!!)

So it seems YaST partitioner creates a UUID somehow. Is the YaST-created UUID an alias for a luks-UUID? I don’t know.

I guess this means you may not be able to edit fstab yourself and create an entry using the UUID which utilities like blkid give you.

Curiouser and curiouser