this post was submitted on 19 May 2026
35 points (94.9% liked)

Selfhosted

59763 readers
948 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

  7. No low-effort posts. This is subjective and will largely be determined by the community member reports.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 3 years ago
MODERATORS
 

I'm running a Ubuntu server on my old laptop with an external HDD connected to it. The external HDD is powered independently from the laptop, as it is plugged into the wall.

During a power outage, my laptop remains operational due to its battery, but the HDD shuts down. When power is restored, my laptop does not automatically remount the HDD, and I have to reboot the system manually to access it.

Does anyone know how I can resolve this issue?

Edit: Not sure if this added context changes anything, but this is the HDD I'm using. It's a 3.5" HDD that gets its power directly from the wall.

all 49 comments
sorted by: hot top controversial new old
[–] irmadlad@lemmy.world 17 points 3 weeks ago (3 children)

I had one back in the day like that. My notes on that event are old so maybe someone can modify or clarify.

First you'll have to find the UUID of the external drive. (lsblk -f) Then create a mount file like: sudo nano /etc/systemd/system/mnt-data.mount. In the mnt-data.mount file, insert something like:

[Unit]
Description=External HDD Mount
Requires=dev-disk-by\x2duuid-<YOUR_UUID>.device
After=dev-disk-by\x2duuid-<YOUR_UUID>.device
After=local-fs.target

[Mount]
What=/dev/disk/by-uuid/<YOUR_UUID>
Where=/mnt/data
Type=ext4  # Change to ntfs, xfs, etc., depending on your drive format
Options=rw,noatime,nofail

Enable and reload:

sudo systemctl daemon-reload
sudo systemctl enable mnt-data.mount
sudo systemctl start mnt-data.mount

Verify status:

systemctl status mnt-data.mount

Should say 'active'. Reboot and test. Let me know if that works. Like I said, that was a while ago. If it works, it's just another reason why you should doccument your server setups. If it doesn't, well shucks I tried. LOL

[–] happy_wheels@lemmy.blahaj.zone 10 points 3 weeks ago (2 children)

This but put the entries in /etc/fstab instead.

[–] feannag@sh.itjust.works 6 points 3 weeks ago (2 children)

Wouldn't that just mount the HDD when the server boots? I think the issue is re-mounting it while the server remains up, hence the systemd service. But maybe I don't understand fstab fully.

[–] happy_wheels@lemmy.blahaj.zone 1 points 2 weeks ago

I wanted to provide feedback for THIS part only. :) not for OPs issue. I would have responded to OPs post if that were the case....

[–] klankin@piefed.ca 1 points 2 weeks ago

I think you can use the service to remount using the fstab entries/options. (Like "mount /dev/disk/by-uuid/XXX" and it'll automatically apply the options and mountpoint)

Arguably cleaner depending on your setup

[–] irmadlad@lemmy.world 2 points 3 weeks ago

I'll make an addenda to my notes. Thanks.

[–] IpsumLauren@lemmy.world 3 points 3 weeks ago

TIL about systemd mounts, thanks!

[–] Lenna@piefed.ca 2 points 3 weeks ago

My /etc/fstab file currently has the following:

UUID=412ea77a-96e1-427c-9f75-2aae2fe0dca1 /mnt/wd ext4 defaults 0 2

If I were to use the mnt-data.mount you've suggested, does that mean I need to delete what I already have in /etc/fstab and replace it with what you suggested?

[–] ohulancutash@feddit.uk 8 points 3 weeks ago (1 children)

That risks breaking the drive eventually. They don’t handle loss of power well. And if its being written to at the time, data loss and corruption is inevitable.

That said, no need to reboot to mount the drive.

sudo mount -a
[–] Lenna@piefed.ca 1 points 3 weeks ago (1 children)

I shall give this a try the next time it loses power. Thank you.

[–] OwOarchist@pawb.social 3 points 3 weeks ago* (last edited 3 weeks ago)

Then set up a cron job that periodically tries to read a file on the drive, and if that command fails, then execute sudo mount -a

Like, set up a root account cron job to run touch \external_drive\test_file.txt || mount -a at 5-minute intervals.

[–] IpsumLauren@lemmy.world 5 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

Remove the laptop battery.

/jk

I used to have a similar setup and the disk didn't last a year. All those power losses are going to break the disk eventually. Now I'm trying a cheap UPS.

[–] billwashere@lemmy.world 1 points 2 weeks ago (1 children)

Isn’t that the good thing about a laptop … essentially built in UPS?

[–] klankin@piefed.ca 1 points 2 weeks ago

Rig up the 12v barrel adapter right to the laptops battery

[–] Natanael@slrpnk.net 5 points 3 weeks ago (2 children)

I recommend a UPS, even a small one is fine for this. Spinning disks don't like frequent starts and stops, especially not unplanned powerless ones.

At least you should be running a journaling file system or something similar which tolerates power loss decently (you'll still see data corruption, but the file system won't die). If you run software that doesn't tolerate power loss well, then you absolutely need an UPS

[–] SpikesOtherDog@ani.social 1 points 3 weeks ago

Find a used one for sale. Bonus points if it has any kind of management. Replace the battery. If at all possible, have it unmount the drive at a certain percentage.

[–] Lenna@piefed.ca 1 points 2 weeks ago (2 children)

This is my HDD. Aren't these guys able to handle power losses since people usually plug them in to backup stuff, and then pull the plug once they're done?

And does ext4 count as a journaling file system?

[–] chris@l.roofo.cc 1 points 2 weeks ago

It's not good to power off a mounted drive. At least for the file system. I don't know about the drive itself.

[–] Natanael@slrpnk.net 1 points 2 weeks ago* (last edited 2 weeks ago)

It counts as long as barriers are on

https://archive.kernel.org/oldwiki/ext4.wiki.kernel.org/index.php/Ext4_Howto.html#Barriers_on_by_default

External drives expect you to ensure writes complete first. If you don't then smart software with copy-on-write and consistency checks can survive power loss (at the cost of losing recent changes). Other software which assumes a reliable drive can get wrecked.

Lots of file systems can not handle random power losses because they don't force continous integrity of the disk file system, that's why FAT formatted drives so often get corrupted

[–] warmaster@lemmy.world 3 points 3 weeks ago (1 children)

I can infer that you want suggestions for cost efficient backup power. Depending on the laptop model, it could power the HDD and in case of an outage it could draw power from the laptop's battery. It would decrease battery charge duration but it would be enough for a graceful shutdown to prevent data loss.

Alternatively, you could maybe use a battery pack.

[–] klankin@piefed.ca 1 points 2 weeks ago

Ive thought about trying this before, but do you have any experience with how to actually hook up the power supply?

Never thought breaking a drive was worth the risk, but theoretically you should be able to solder a buck converter to the laptops motherboard if the voltage requirements vary.

[–] Shimitar@downonthestreet.eu 3 points 3 weeks ago (1 children)

In short: buy a cheap ups power strip or a generous USB powebank capable to being under charge 24/7 and do not let the HDD switch off on power loss...

That is a guaranteed recepy to destroy your data and possibly the hardware as well as spinning disks don't like abrupt shutoff and that applies to data being written on SSDs as well.

Remounting after the power resumes is the last of the issues, easily fixed by a amount/mount command with the proper fstab setup.

[–] Lenna@piefed.ca 1 points 2 weeks ago (3 children)

Do you have a USB power bank you can recommend? My external HDD requires a wall plug and I've never seen a USB power bank where I could plug my HDD into it.

[–] GeorgimusPrime@lemmy.world 2 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

There are DC UPSes that can supply 12V and are typically used to keep wireless routers and security cameras running for a few hours during power failures. They plug into the mains and are about the size of a 3.5" HDD.

Most USB power banks power cycle when the switch between charging/supplying/pass through mode, so if you use them for computer equipment they will lose power for a few seconds when the mains comes on or off.

Edit: DC UPSes are also much cheaper than standard ones.

[–] Lenna@piefed.ca 1 points 2 weeks ago

Would this be something you're talking about? It's the cheapest one I can see on Amazon here in Canada.

[–] Shimitar@downonthestreet.eu 1 points 2 weeks ago

I was thinking of 2.5" inch USB drives powered by USB cables....

For 220v ones get a proper ups power strip. They are cheap about 50-60 bucks

[–] Landless2029@lemmy.world 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

You have a 3.5" based HDD (aka desktop drive). many people use 2.5" drives (laptop drives) since they get power from the PC with just usb

[–] Lenna@piefed.ca 1 points 2 weeks ago (1 children)

So that means it's not possible for me to power my 3.5" HDD with just USB, right?

[–] Landless2029@lemmy.world 2 points 2 weeks ago

100% correct. You need a wall adapter. As many have said we all recommend a UPS (Uninterruptible Power Supply) or battery backup for your stack.

You can get the cheapest one if it's just short term outage or brown outs (grid low volting).

Based on your wattage the capacity of the UPS will dictate how long it'll last during an outage.

[–] Ebby@lemmy.ssba.com 1 points 3 weeks ago (1 children)

Cheap and dirty solution would be a battery backup for the drive, but there are some big concerns about the setup. Drives don't like to go dark like that.

[–] Lenna@piefed.ca 1 points 3 weeks ago (1 children)

I had a laptop lying around and computer parts are too expensive now to build my own server, so that's what I went with. Is the concern you have involving loss of data?

[–] Ebby@lemmy.ssba.com 2 points 3 weeks ago

One concern, yes. Others such as parking heads. Don't want platters spinning down with drive heads hovering. Power spikes won't do the circuit boards any good.

Doesn't hurt to show servers some kindness even if it's a laptop in a closet.

[–] tal@lemmy.today 1 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

Does anyone know how I can resolve this issue?

I don't know why you'd need a reboot to remount the thing. Are you just not familiar with how to add something to /etc/fstab and mount it manually and are relying on some kind of auto-mounting system that only happens to run at boot, or is it giving some kind of error?

If an error, what happens when you do:

$ sudo mount -o remount /mnt/the-mount-point

?

[–] Lenna@piefed.ca 2 points 3 weeks ago (2 children)

auto-mounting system that only happens to run at boot

This is correct. I made my drive auto mount using /etc/fstab, and I believe that is only checked once during boot.

[–] tal@lemmy.today 1 points 3 weeks ago (1 children)

Nah, that's good. What I mean is, if it's in /etc/fstab, it should be possible to manually mount it without a reboot. Have you tried manually remounting it after power comes back?

[–] Lenna@piefed.ca 2 points 3 weeks ago (1 children)

Nope, I haven't tried that. But I will give it a try when the next power outage occurs. I actually didn't know I could manually remount until today. I'm still pretty new to selfhosting.

[–] tal@lemmy.today 2 points 3 weeks ago

Gotcha. Yeah, the stuff in fstab is just a convenience; it's equivalent to running a bunch of mount commands at boot. You might be able to just run "mount" again without the '-o remount" option. I was just listing that in case you were seeing some kind of errors in trying to manually mount it.

[–] tofu@lemmy.nocturnal.garden 1 points 3 weeks ago (1 children)

You can run mount -a to mount all fstab entries. You could put that in a cronjob I guess

[–] Lenna@piefed.ca 2 points 3 weeks ago (1 children)

If I were to make it run that command every 5 minutes, would there be any downsides?

[–] tofu@lemmy.nocturnal.garden 1 points 3 weeks ago

I don't know if it has side effects when there's issues with mounting or the like.

It would also interfere if you want to unmount it and forget to disable the cronjob.

[–] AbidanYre@lemmy.world 1 points 3 weeks ago* (last edited 3 weeks ago) (2 children)

Autofs might do what you're looking for. How often do you have power outages that it's a major concern?

[–] tal@lemmy.today 1 points 3 weeks ago

I was going to mention that, but also that while I'm sure that it'd handle power loss while it's unmounted the filesystem I don't know what happens if the backing storage goes away while it's in use.

[–] Lenna@piefed.ca 1 points 3 weeks ago

It doesn't happen often, but when it does happen I temporarily lose access to my media. But based on what others are saying here, it looks like it's possible to manually remount my drive instead of rebooting. So I'll give that a try.

[–] FreedomAdvocate@lemmy.net.au 0 points 3 weeks ago (1 children)

First step is to not use a laptop with a charged/charging battery in it as an always-on server. Terrible idea.

[–] Lenna@piefed.ca 0 points 2 weeks ago (1 children)

Could you please elaborate on why this is a bad idea?

[–] FreedomAdvocate@lemmy.net.au 1 points 2 weeks ago (2 children)

Having a battery that is constantly charging and kept at 100% is bad for the battery. Very bad. Batteries don’t like heat, and being kept on and in use endlessly generates heat constantly. Batteries should be avoided for things like this as they can swell and/or explode.

[–] Natanael@slrpnk.net 2 points 2 weeks ago

This depends entirely on the motherboard because many newer ones are fully capable of disconnecting the battery and maintaining it intelligently like smartphones does

[–] CovfefeKills@lemmy.world 0 points 2 weeks ago* (last edited 2 weeks ago)

Chill bro they have BMS's. I keep my always plugged in laptop at 60% battery for this reason but they aren't infants you don't need to baby them.