It sounds like you're experiencing an issue where the device ID (likely referring to the st_dev field in the output of commands like stat or ls -i) for files on the mounted filesystem at /var/mnt/misc is alternating between 54 and 55 on each boot. This behavior is related to how Linux assigns device numbers to block devices, and it's not uncommon, especially if the underlying storage device is not consistently detected or ordered by the kernel. I'll explain the likely cause and provide steps to diagnose and potentially resolve it.
Understanding the Problem
Device ID in Context: In Linux, the device ID (st_dev) for a file is part of the file's inode metadata and represents the device number of the filesystem where the file resides. This number is derived from the major and minor numbers of the block device (e.g., /dev/sda1) that the filesystem is mounted on. The major number identifies the device driver (e.g., 8 for SCSI/SATA disks), and the minor number identifies the specific device instance.
Why It Alternates: Even though your /etc/fstab entry uses a UUID (which ensures the correct filesystem is mounted regardless of the device name), the underlying block device's major or minor number can change on each boot. This can happen due to:
Device Detection Order: During boot, the kernel detects and assigns device numbers based on the order in which devices are discovered. If there are multiple storage devices (e.g., SATA, NVMe, or USB), the order can vary, leading to different minor numbers for the same physical device. For example:
On one boot, your device might be assigned as /dev/sda1 with a minor number resulting in st_dev = 54.
On the next boot, it could be reassigned (e.g., due to a different detection order) to something like /dev/sdb1, changing st_dev to 55.
Btrfs-Specific Behavior: Btrfs filesystems can span multiple devices, but since your fstab entry specifies a single UUID, it's likely a single-device setup. However, Btrfs still relies on the block device's device number, so changes in the underlying device assignment can affect st_dev.
System Factors: This could be exacerbated by factors like:
Removable or hot-pluggable devices (e.g., if /var/mnt/misc is used for external storage).
Virtual environments (e.g., VMs) where device assignment can change.
Kernel or udev configuration issues that don't enforce consistent device ordering.
The alternation between 54 and 55 suggests a small, predictable change in the device number, which is often due to minor variations in device detection rather than a major issue with your fstab entry. Using UUID in fstab is a good practice for ensuring the correct filesystem is mounted, but it doesn't guarantee a consistent st_dev value.
Steps to Diagnose and Fix
Here's a step-by-step approach to identify the root cause and mitigate the issue. The goal is to make the device assignment more consistent or reduce reliance on st_dev.
1. Verify the Current Setup
Check the current mount and device details:
code
mount | grep /var/mnt/misc
This should show something like:
code
/dev/sda1 on /var/mnt/misc type btrfs (rw,relatime,space_cache,subvolid=5,subvol=/)
Note the device path (e.g., /dev/sda1). If it changes between boots, that's likely the cause.
Check the device ID of files in the mount:
code
stat /var/mnt/misc/somefile
Look at the Device field (e.g., Device: 36h/54d or Device: 37h/55d). Confirm it's alternating as expected.
Inspect the block device properties:
code
ls -l /dev/disk/by-uuid/e0042b6d-0dea-4c28-b94f-d09c16ae55ca
This should symlink to the actual device (e.g., /dev/sda1). Use udevadm to get more details:
code
udevadm info --query=all --name=$(readlink -f /dev/disk/by-uuid/e0042b6d-0dea-4c28-b94f-d09c16ae55ca)
Look for properties like ID_SERIAL, ID_MODEL, or ID_REVISION. These can help identify if the device is being detected inconsistently.
Look for errors indicating device detection issues or mount failures.
2. Common Causes and Quick Fixes
If the Device is Removable or External: If /var/mnt/misc is intended for a USB drive or other removable media, the alternating device ID might be expected due to varying connection states. In this case:
Consider using a more robust mounting mechanism, like udisks or automounting with gvfs (since you have x-gvfs-show in fstab), which can handle removable devices better.
If consistency is critical, avoid relying on st_dev for applications (e.g., use file paths or inodes instead).
Ensure Consistent Device Naming:
Linux uses udev to manage device nodes. By default, /dev/disk/by-id/ or /dev/disk/by-label/ can provide persistent names based on hardware attributes like serial numbers.
Check if a persistent name is already available:
code
ls -l /dev/disk/by-id/
Look for a symlink matching your device (e.g., /dev/disk/by-id/ata-ST1000LM035-1RK172_W73234AB6789). If it exists, update your fstab to use this instead of UUID for potentially more consistent device numbers:
Replace sd*1 with the appropriate kernel name (e.g., from udevadm), and serial with the actual serial number.
Reload udev rules and trigger them:
code
sudo udevadm control --reload-rules
sudo udevadm trigger
Use /dev/mydevice in your fstab.
Kernel and Module Tweaks: Sometimes, device ordering can be influenced by kernel parameters or module load order. Try adding a boot parameter to enforce consistent device probing:
3. Mitigating the Impact
Don't Rely on st_dev for Identification: If applications or scripts depend on a consistent st_dev, consider alternative ways to identify filesystems:
Use the mount point (e.g., /var/mnt/misc) directly.
Use filesystem UUIDs or labels for lookups (e.g., via blkid or in code).
For Btrfs, you can use subvolume IDs or paths for more granular identification.
Test with a Fixed Device Number: As a workaround, you could mount the filesystem using a loop device with a fixed minor number, but this is complex and not recommended for production:
Create a file-based image of your Btrfs filesystem (if possible) and mount it with losetup to assign a static device.
Example (for testing):
code
dd if=/dev/zero of=/path/to/image.img bs=1M count=1024
mkfs.btrfs /path/to/image.img
losetup -f --show --find /path/to/image.img # Assigns a loop device
mount /dev/loopX /var/mnt/misc
This isn't practical for your current setup and might not address the root cause.
4. When to Seek Further Help
If the device is a fixed internal disk, this behavior might indicate a hardware or kernel issue. Check for firmware updates or try booting with a live USB of a different Linux distribution to see if the problem persists.
If the alternation is causing functional problems (e.g., broken applications), provide more details like:
The output of lsblk -o NAME,MAJ:MIN,UUID,MOUNTPOINT
The kernel version (uname -r)
Any error logs from boot
I can offer more tailored advice based on that.
In summary, the alternating device ID is likely due to changes in the block device's major/minor number during kernel detection, and using UUID in fstab doesn't fully prevent this. Focus on ensuring consistent device naming with udev or reducing reliance on st_dev. If this is a removable device, it might be an inherent limitation. Let me know if you have more details for further assistance!
Edit /etc/default/grub and add scsi_mod.use_blk_mq=1 or libata.force=1:1.5Gbps (adjust based on your hardware) to the GRUB_CMDLINE_LINUX_DEFAULT line.