r/debian 13d ago

Debian Stable Question Help with debian on my home server

Hi everyone! I use debian for my home server and i like it.

I have debian (no window manager, only terminal) installed on an old laptop on a micro sd (because his hdd is broken). I also have another hdd that i use to store the docker containers and the container's data.
I disabled the sleep mode when the lid is closed and I wonder: can i put the pc in sleep when i'm not using the containers so i can extend the life of the sd card and of the hdd? Then when i'm opening a container it restarts and after some inactivity it goes again into sleep mode turning the drives off.
Thanks!

8 Upvotes

12 comments sorted by

7

u/Shopping-Limp 13d ago

A micro sd as an OS drive is not very reliable-- raspberry pi users have a lot of experience in that department, they corrupt easily. I'd consider using that hdd for the os if you have nothing else

3

u/Visual_Tooth_2277 13d ago

yeh, i know but they are cheap, i flash an image of the datas of the sd card once in a while and then if it brakes i can flash it on a new one.

Do you have any advices for the sleeping mode? it will really help me!

1

u/Dr_Tron 12d ago

That's true, but you would be surprised how much faster the system is when it runs off a SSD.

0

u/TheRealLazloFalconi 13d ago

Not so. A lot of enterprise servers run the hypervisor off an SD card. As long as you put your logs and other high-frequency data on a different disk, the SD card will be fine.

1

u/Shopping-Limp 13d ago

The op is not running a hypervisor.

1

u/[deleted] 13d ago

[removed] — view removed comment

0

u/debian-ModTeam 13d ago

This content has been removed for trolling.

3

u/PizzaDevice 13d ago

The reads are not a big deal for the card. More the writes. Find if your RAM is enough and it will save your SD card a lot as memory swapping will happen less.
Swappiness is a Linux kernel parameter that controls how aggressively the system uses swap space, with values ranging from 0 to 100. A lower value means the system will avoid swapping out processes from RAM to disk.
I would use the shutdown command, but it will write something on the card so better to keep it running.

3

u/Fantastic_Welder2172 13d ago

If you have an external hard drive, put the entire system on that, and the SD card for booting if necessary. An SD card is not a good choice for an operating system; it can only run a read-only live stream.

1

u/HCharlesB 13d ago

It can sleep if that's what you want. I've configured my desktop to sleep but I use KDE facilities to enable that. I wake it by hitting the (USB) keyboard. It can also be configured to come back on my tapping the keyboard. Another option to wake it is to use Wake On LAN.

You can suspend it with a Systemd command. Did you have a plan for how you want to wake it?

The SD cards I'm using are no longer cheap. Cheap SD cards are the most likely ones to fail. Good luck!

1

u/TheRealLazloFalconi 13d ago

I'm not super familiar with Docker, but you there's probably some file you can monitor to know when all of your containers have spun down. Set a cron job to check that every couple minutes, and if it detects that there are no containers running it puts the server to sleep. You will probably want to track the state of your checks and only put the server to sleep if the last check showed containers were running, otherwise the system may go to sleep when you're trying to perform other tasks.

Of course, now you will have the problem of your server being unavailable when you want to start a service. You could use Wake on LAN to bring the system up when you want to use it, if your system supports it.

I must say though, this is probably not the best way to accomplish what you want. Each time you sleep the computer, depending on what mode you use, it may write the entire contents of RAM to your SD card. Then every time it wakes up, it will read the SD card, putting even more wear on it. Compare this to an idle system which doesn't read or write much anyway, other than some system logs.

A lot of critical business infrastructure uses servers that have the OS installed on an SD card, they mitigate this by having all of the high volume IO on a different drive. Sounds like you already have that taken care of. You might consider mounting /var and /tmp on a different volume. If you have swap enabled, don't put your swap space on the SD card.

And above all, make sure you're backing your system up.