SQL Server on Linux Mint

Why Linux?

To start with, I think everyone agrees that Linux is core skills, and no doubt every IT professional should be familiar with it. Almost all enterprise software solutions are tailored for Linux. So not going into deep why I started learning Linux.

It took me more than a year to get confident enough to get rid of windows 10 from my personal laptop and load it with Linux. Why did I do this?

Well, I believe learning comes in the face of challenge. With Linux inside VMs on Windows 10 machines, I realized that I am always avoiding doing tough tasks on Linux, and ended up doing the same on windows. This way, I never got to know Linux the way a System Admin should know.

Server vs Desktop linux?

Obviously, I wanted GUI on Linux since I was planning to install the same as base os on my laptop. Since hardware & Softwares drivers are tuned to support GUIs on the Desktop. That gave me a compelling reason to install Linux Distro. After all, I also love games, watching movies with local video players, installing various software.

Why Linux Mint?

When I started, I had a better understanding of RHEL than any other Linux. So the first choice was Fedora. But, the recent announcement by RedHat to end the CentOS distribution kind of switch off my interest in Fedora. Now I wanted a desktop entirely Open Source. I had little to no experience with Arch Linux. The only option left was Debian based desktop.

Here I had a lot of research to do. I visited distowatch.com to get an idea of major linux distributions. Linux Mint topped the list. I tried both Ubuntu & Linux Mint and found Linux Mint suitable to my need and feel. Plus, I loved the fact that Linux Mint comes with a pre-installed system backup/restore software, timeshift, using which I can perform System snapshots, and reset system to a particular snapshot as and when needed. Even when the system is not booting, I can utilize LinuxMint LiveOS to recover using timeshift. Believe me, I need this system backup/restore functionality as I am doing experience on a laptop almost all the time, and screw thing up more than I want to admit.

OS Installation – FileSystem

My laptop has 2 hard disks 250 GB & 2 TB. I used 250 GB hard disk for all OS related partitions.

/ – (root partition) – 30 GB
/boot – (boot partition) – 500 MB
/home – (home partition) – 146 GB
One extra partition of 30 gb for Experiments (mounted as /media/saanvi/extra-30)
Swap space of 16 GB

Partitions on Linux Mint

Post OS Installation

The very first thing I did is to perform a timeshift backup. Post that I did installations of a variety of software like chromium, vs code, open office, and few others.

Install SQL Server On Linux Mint

Installation of SQL Server on Linux Mint is not officially supported. But, following the installation guide for Ubuntu got me started.

All the steps are pretty straight forward. I ended up installing SQL Server 2019 with command-line tools.

After installation of SQL Server 2019, enable SQL Server agent following guide Install SQL Server Agent on Linux.

Since I love to access my local SQL Server from other machines either on the same local network and from remote machines through the internet, I opened firewall port TCP/1433.

# Open port tcp 1433 for any machine
sudo ufw allow 1433/tcp

Now, at this point, I have successfully installed SQL Server 2019 on path /var/opt/mssql. 

SQL Server Path on Linux

I love the StackOverflow sample database, which thanks to Brent Ozar, can be download in various sizes like 10/50/300/411 GB, I planned to restore the same on the newly installed SQL Server.

The problem for me happened to be free space on the root partition (30 GB). Here I had 2 solutions –

  • Move SQL Server installation directory from /var/opt/mssql to some other mount point with enough space
  • Create a new folder on another mount point, and set proper directory ownership, change default data and log file at sql server instance

I went ahead with the first solution. 

  1. Stop mssql-server service using sudo systemctl stop mssql-server.service .
  2. Copy directory /var/opt/mssql to a mount point with new space.  mkdir /study-zone/mssql; sudo rsync -aqxP /var/opt/mssql/ /study-zone/mssql/ 
  3. Rename existing directory /var/opt/mssql to /var/opt/mssql_old. sudo mv /var/opt/mssql /var/opt/msql_old
  4. Create a soft link on original path. sudo ln -s /study-zone/mssql /var/opt/mssql
  5. Start mssql-server service using sudo systemctl start mssql-server.service .
SQL Server service status on Linux

That’s it. With this, I got SQL Server services started from another path without any issue and restored large databases without space worry.

One Comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.