First and foremost, thanks to the DietPi Team for building an absolutely amazing OS with all these pre-built software packages - while I am somewhat new to Raspberry Pi’s and Linux coding in general, I do fancy myself a fast learner (meaning, please bare with me by ELI5).
So here’s the issue: I setup NextCloud and JellyFin on a 2GB Pi4, and attached an external SSD via a NESPi case which powers the SDD and the Pi. After the successful installation of these programs, I did a reboot and noticed that the SSD was not being mounted at boot as I had configured it to do in the DietPi Configuration. I ran the DietPi Device Manager’s “repair” tool and found the following error (to which I have no idea what it means):
There are differences between boot sector and its backup. This is mostly harmless. Differences: (offset:original/backup) 29:08/00
After 2 hours of searching Google, I came up with exactly nothing. I removed the SSD (safely) and ran a Windows Disk Check and Repair to no avail. I even tried removing the line in etc/fstab, rebooting, remounting, and still continue to get this error. Can anyone explain how I can fix this issue so that the SSD is automatically mounted to the same location each time a reboot is required?
ok by default DietPi will create the mount with option x-systemd.automount. Means the drive is not mounted during boot process already. It will be done as soon as someone is trying to access the drive. You could do a test and reboot the system. Once back online, try to access your drive cd /mnt/1B1E-0A70 and check if the drive was mounted now.
That is correct - from my searching around Google, I was able to come to the same conclusion, however because of the error listed above in my original post (which was an output of the “DietPi-Drive Manager’s” “Scan and Repair” feature), accessing it after boot still doesn’t mount it.
As you mentioned, I have completed 5 tests:
Reboot > Terminal > cd /mnt/1B1E-0A70
Reboot > PCManFM File Manager > /mnt/1B1E-0A70
Reboot > Attempt Connection from a Separate Linux Laptop via Samba
Reboot > Attempt Connection from a Separate Linux Laptop via JellyFin
Reboot > Attempt Connection from a Separate Linux Laptop via NextCloud
All of which failed to automatically “re-mount” the SSD upon attempting to access it. Instead, I am required to open the “DietPi-Drive Manager” and remount the SSD from there.
Again, from what I was reading from numerous articles, blogs, and forums, this seems to be caused by the error in the original post however I do not know what it means or how to fix it.
There are differences between boot sector and its backup. This is mostly harmless. Differences: (offset:original/backup) 29:08/00
That is actually not an error but more a warning, but probably it still breaks automount. How did you format the drive, i.e. did you use dietpi-drive_manager to format it?
The warning indicates that it is formatted with a GPT partition table (default as well with dietpi-drive_manager) but that it has a boot sector (which should be purged by dietpi-drive_manager). GPT partitions have a primary boot sector (and as well a primary partition table) and a backup of it at the end of the drive. This backup is missing or wrong in your case, likely because it is not used as boot drive .
The following can be used to re-create the backup section on GPT patitions: sgdisk -e /dev/sda
But it’s probably good to first verify my guess : fdisk -l /dev/sda
So the unmount command works, but when attempting to re-mount, it doesn’t. Additionally, you can see from running ‘fsck’, the same error pops up but this time I have options to correct the issue - which do you recommend that I select? See the output below.
root@MediaPi:~# umount /mnt/1B1E-0A70
root@MediaPi:~# mount /mnt/1B1E-0A70
root@MediaPi:~# umount /mnt/1B1E-0A70
umount: /mnt/1B1E-0A70: not mounted.
root@MediaPi:~# mount /mnt/1B1E-0A70
root@MediaPi:~# umount /mnt/1B1E-0A70
umount: /mnt/1B1E-0A70: not mounted.
root@MediaPi:~# dosfsck /dev/sda1
fsck.fat 4.1 (2017-01-24)
There are differences between boot sector and its backup.
This is mostly harmless. Differences: (offset:original/backup)
29:08/00
1) Copy original to backup
2) Copy backup to original
3) No action
Okay, boot sector and partition table are both on the first 512 bytes if the drive. So purging or changing that sector will purge the partition table as well. Do you have relevant data on that drive already? Else I’d suggest to reformat it. Is there a certain reason why you used FAT? If it must be mountable on Windows, one would usually use NTFS, else ext4.
But before you reformat, probably a faster fix could be 2) Copy backup to original.
Yes, I have around 500GB worth of media that I use with Jelly Fin. The weird thing is that this drive held the same content (as NTFS) before I reformatted it to FAT32 (and then reloaded the data back onto the drive), so it was a clean format (which I did just a few days ago). So why would there be any issues at this point? A mystery for sure…
The reason why I used FAT32 was for its compatibility with all operating systems as I currently have a mixture of OS’s that I use (Linux based, Windows based, Android based, iOS based, etc) and I wanted to ensure I could access this SSD from any of those devices. Do you recommend just sticking with NTFS? Also, as a side question, what are your thoughts on booting directly from the SSD rather than the MicroSD (obviously I would offload the media from the drive, and then have the DietPi-Drive Manager reformat for me)?
Should I go ahead with applying the second option first before taking other steps?
Ah okay, if Android and iOS need to have access as well, probably FAT32 is best as I’m not sure how well those deal with NTFS. exFAT would be an idea in case of an SSD, and should be fine with Android and iOS as well.
Can you plug the drive to Windows and run an file system check there? In case of FAT and NTFS I trust the Windows repair tools more.
If Windows repair does not help, back on Linux 2) Copy backup to original is worth to give a try, yes.
Actually, I did a command line CHKDSK 2 nights ago (which took literally all night because this thing was full of files and is 1TB) and resulted in 0 issues found, 0 issues fixed.
Before I run option #2, I just want to make 100% sure that this won’t format the drive, correct?
Option 2 will copy the backup boot sector to the original boot sector. So if the backup boot sector is broken, it will break the drive. It won’t format the data, but making them inaccessible. However, it’s possible to re-create the partition table which should make the data available as well. However I cannot give a guarantee for this.
Option 1 will do it the other way round, so it won’t make the drive mountable, if it is currently not mountable, but it will copy the possibly broken boot sector to the backup location, at least fixing/muting the fsck error about the mismatch. But I don’t think that this mismatch prevents the mount.
To re-create the partition table manually:
fdisk /dev/sda
d # this deletes a partition (not the data, just the reference in the partition table)
1 # delete partition 1
n # create new partition
1 # partition 1
# hit return to accept the first sector default, which should be 2048 bytes
# hit return to accept the last sector default, which should be the whole drive space
w # write partition table to drive
All this is written to the first 512 bytes of the drive only, while the actual data start with the file systems at byte 2048, so they should be readable perfectly fine after the procedure.
Yes, the drive does mount on Windows without issue.
So, I decided on going with the red pill, err, I mean option 2 to which the same issues arose. So I decided to go back to good ole’ NTFS format. And everything works as it should. Just an FYI - I decided to test a brand new SDD (MBR partition; FAT32 format) on the Pi to see if it would happen to this drive as well - sure enough, same issue. After some searching online (and getting more confused), it turns out that FAT32 formatted drives (not all, but some based on manufacturer) do not play well with DietPi’s (and more specifically, linux) automount feature.
While I do not know why this inherent issue is persistent with both a Kingston and Samsung SSD’susing Linux automount function, I do sincerely appreciate the assistance by both MichaIng and Joulinar. Can I buy either of you a coffee for your time and patience?