Install linux on 2018 Mac mini

I really want to install linux on my 2018 mac mini, in order to run webodm under Docker. Under linux, Docker can access virtual memory effectively, in a way that it cannot under macOS or Windows, and so I can usefully allocate 128 GB of RAM to Docker even though my mini has 64 GB of physical RAM. I looked into this, and the directions for installing Ubuntu from Canonical seemed really complicated, and I didn’t find a clear recipe that didn’t involve experimentation. It seems that Arch linux is more straightforward to install, but then I see that Docker is experimental (not supported) under that flavor of linux.

The only reason I would want to install linux is to run Docker + webodm, but, honestly, if there are headaches in doing this, I’ll just continue to rent time from machines on the web (which is cheaper than buying a new intel machine). I don’t need a new “hobby.”

Can anyone give me encouraging words (and advice) on installing linux on my mini?

EDIT: I put the wrong Mac model in the title

I have settled on Linux Mint as being somewhat Mac-like and very easy to install, whilst also being Ubuntu-based. You can download it from https://www.linuxmint.com/ and make a bootable thumb drive with Etcher. Boot the Mini from this and follow instructions to install if you like, or simply play with it first running off the thumb drive. I have an old MBA from 2011 that runs Mint Cinnamon and feels as fast or faster than my M2 MBA running Sonoma. I’ve since installed it on an even older MBA (pre-Thunderbolt) for my son and he’s delighted.

I think the issue is that 2018 minis have a T2 chip. When those machines were new, the T2 caused problems with installing Linux, so older “how-to” guides are not as straightforward as newer ones, so be sure that you are using a recent set of instructions.

Thank you, especially to drmoss_ca. This just worked after disabling boot security. (Well, setting up the partitions for dual booting caused me angst, but was actually pretty straightforward).

If anyone is reading this in order to set up Docker + WebODM, be sure to read the install instructions for Docker carefully. One step is different for Linux Mint than for Ubuntu, and that caused me some head scratching. RTFM!

I have wanted to get WebODM running on my Mac Mini for a long time, and it was much easier than I would have thought, with these hints!

Blimey, I must be psychic or something. I too have recently installed Linux (Debian Bookworm) on my 2018 Mac Mini. Everything works except the SMC driver which bails after several seconds, so I had to blacklist it and don’t have fan control; I don’t know why, but the T2 support never made it into official Debian kernels and the support is only available unofficially, but for Sid (unstable) kernels. I want to run my Mini as a server/router now, and don’t need Bluetooth and Wi-Fi, so I’ll eat the inconvenience.

The other thing I can’t get to work is the Linux equivalent of starting up after a power failure. In previous Minis, you do it by probing a particular register in the LPC controller in the chipset. But that command doesn’t work no more, so I have to assume that something is different about the way this is done. I have here the Intel 300 series PCH chipset specs and will see if I can’t mumble my way to success, but on the off-chance that someone else is installing Linux on a 2018 Mini, besides me and the OP, I thought I’d hijack the thread to ask if anyone else has done this successfully. It really would make a fine Intel-based home server/router if I could make this work, just as I have on the 2012 Mini. Cheers in advance.

Have you tried sudo pmset autorestart 1 from the macOS environment?

Thank you! Now you can tell me something—is it correct that you installed Mint on a Mac with a T2 chip, and succeeded just by disabling boot security? I have a fleet of older Macs, including ones with T2 chips and so far I have only installed Mint on pre-T2 Macs. I’d like to know if I can update at least some of them to run Mint.
Chris

Maybe this will help with the fan: Fan - t2linux wiki

dr_moss, was that question directed to me? The answer is, Yes. I followed the install directions, which tell you to create a swap partition the size of memory (64 GB in my case). I was quite worried when I actually installed linux because the partition names appear to be different when viewed with Disk Utility and mint installer, but it turned out that I did it right. I have read since that it is recommended to use a swap file, not a swap partition, for flexibility, and I think for my use-case a swap of 2x memory would have been better.

However, I should be clear that I am only using linux for one program, and I have ethernet at home and a wired mouse, so I don’t know if WiFi, or Bluetooth, or sound, or anything else works, except for Docker.

Thanks, good to know!

Linux and macOS definitely name devices differently. Instead of /dev/disk*s# to represent partitions on volumes, Linux typically names them /dev/sd*#, where “*” is a letter representing the device and “#” is a number representing a partition number. (e.g. /dev/sda3 or /dev/sdc1).

For the curious the sd stands for “SCSI Disk”. It was originally reserved for drives connected to SCSI controllers, but was later used for most devices, since the drivers for most devices these days are designed to mimic SCSI devices, for more easier system integration. The exceptions you might see, especially on older PCs, are /dev/HD#*, for parallel-ATA hard drives and /dev/fd# for legacy floppy drives. A SD card (e.g. on an embedded device like a Raspberry Pi) will be /dev/mmcblk#p#, where the first “#” is the card slot number and the second is the partition number.

I would agree with that advice. Back in the old days of mechanical hard drives of smaller capacity, it was common to dedicate an entire hard drive device for swap, so system operation wouldn’t interfere with its head motion (which could cause performance issues).

Later on, when drives got faster and larger, a swap partition would be used, in order to ensure that all of the swap device’s blocks were adjacent, since fragmentation would kill performance (and for some old Unix systems wouldn’t be permitted at all).

Today, swap files are recommended because the OS has no problem dealing with a fragmented swapfile and with SSDs, there is no head motion to cause performance problems. And even if your system has an HDD, the fast seek times (compared to a few decades ago) and caching minimizes the performance problems that used to mandate a swap partition. And with swap files, it is no big deal to add and delete them as your system’s circumstances require (with some Unix-like operating systems, including macOS, dynamically creating and destroying them as needed).

It all depends on your usage patterns. The advice to use 2x RAM size was very important in the days where systems had relatively small RAM sizes (on the order of MB, not GB), because you might end up needing that much when running an app bigger than your system can otherwise handle.

With systems that have much more RAM (64GB in your case), this advice isn’t always the best. If you are overcommitting your memory by 128GB (2x your RAM size), then you are almost certainly running software that is too big for your system, and I would strongly recommend using a computer with more memory (which, of course, would not be a Mac mini) for that application.

Ultimately, you should set the swap size based on how much RAM you expect to need. This could range anywhere from zero up to the point where the performance hit from swapping becomes unacceptable. Some things to keep in mind:

  • When memory actually runs out (RAM is full and swaps are all full), the kernel will start killing processes. This can be a real problem if you need them to be running! So even if you don’t expect to need any swap space, you probably should create some, just in case memory usage temporarily spikes high enough to need it.

  • When viewing memory usage (e.g. with the top command), be sure you understand what you’re seeing. For instance, on one of my Linux PCs, I am seeing this:

    Tasks: 196 total,   1 running, 195 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  9.4 us,  2.3 sy,  0.0 ni, 88.0 id,  0.4 wa,  0.0 hi,  0.0 si,  0.0 st
    MiB Mem :   5862.1 total,    631.9 free,    696.3 used,   4533.9 buff/cache
    MiB Swap:  17166.0 total,  17085.0 free,     81.0 used.   4861.6 avail Mem
    

    This can be a bit confusing. Note the third line. There is 6GB of RAM in the system. Note how it says only 641.9 MB is free when only 693.3 MB is used. This is because of the 4533.9 MB assigned to “buff/cache”. This is RAM used to cache file system data. It’s not free, but it can be released by the OS at any time in order to make room for apps that may need it.

    The actual amount of memory that apps can request before swapping is actually 4861.6 MB (the “avail Mem” number to the right of the fourth line). Note that this number is not the sum of free memory and the “buff/cache”. This is because the system always wants to reserve some cache memory, and some memory is reserved for the kernel to use so it won’t crash if it gets to the point where it needs to start killing processes.

    I have created a 17 GB swap partition on this computer. Not because I ever expect to need this much, but because I’d rather suffer a big performance hit than see processes killed, should I do something that may require that much.

  • Although the performance hit from swapping to a modern SSD is minuscule compared to an HDD, large amounts of swap activity may create a lot of write-load to the SSD, shortening its lifespan. You may want to avoid the situation even if there is no significant performance hit.

    • Alternatively, if you want to connect an external SSD (USB or TB) to be used as a swap device, that might be a good idea. This way you can swap all you want and if it dies, it won’t take down the rest of your system. It won’t be as fast as swapping to the internal SSD, but may be good enough.
  • If you choose to enable hibernation (sleep-to-disk), then you will need a swap file at least as large as your RAM size. This is because Linux hibernation works by swpping-out everything and then powering off. Then on reboot, it swaps everything (or most of everything) back in.

    But if you don’t think you’ll ever use hibernation, then you don’t have to care about that.

  • I personally believe that if RAM is plentiful (as it appears to be for you - with 64GB), then you shouldn’t expect to swap at all. So I would suggest creating a small-ish swap file (e.g. 4 or 8GB), just to pick up the slack should it be needed), or (if you plan on using hibernation) one equal to the RAM size.

    I honestly think that if you need more than 64GB for your expected usage, then you should start researching buying a PC with enough RAM and not try to use a Mac mini for its tasks.

3 Likes

Thanks, David.

Regarding your advice, I have a particular program I want to run, webodm under Docker. I have (quickly) researched getting an intel box with 128 GB of RAM, and it is expensive. The mac mini is free. Recommendations from webodm discussions say that for larger runs, having swap of 2x RAM allows them to run, and doesn’t slow things down that much because this is just a small part of the (often multi-day) run. I have the disk space to allocate 128 GB of swap, but it would mean repartioning my disk to get rid of the swap partition. Currently I don’t need that much swap, but I might in the future.

Again, thanks for your advice.