In order to optimally design our website and to show appropriate offers we are using cookies. By continuing to use our website you agree that we set cookies. More information

Mounting of additional hard drives in Windows

In this tutorial, we are going to mount an additional hard drive in Windows. As you may notice, we will do so in Windows Server 2012, but the procedure is basically the same with Windows Server 2008.

At first, we need to open a menu by right-clicking the Start button:


We must select Disk Management to open the Disk Management service. If Windows identifies a new hard drive, a pop-up menu opens:


For volumes smaller than 2 TB, we choose MBR, for larger disks, we select GPT. As the hard drive in our example only has a capacity of 100 GB, we'll go with MBR here. By clicking OK, the chosen partition table will be written to the hard disk. After that procedure, we will be sent to the main menu of the Disk Management service. Alternatively, one can reach this overview via Control Panel => Computer Management.


As we can see here, our new hard drive is listed as Disk 1. But before we can use it for storing data, we need to partition and format it. Therefore, we right-click the rectangle next to the box which says Disk 1 and choose New Simple Volume.


A wizard opens. It is quite self-explanatory and you can't do anything wrong by using the pre-selected and suggested values. Per default, the wizard uses the whole disk capacity for the new partition and formats it with the file system NTFS, which is recommended for Windows. Of course, you are free to change those settings, but in our example, we go along with them.


The name of our new partition is STORAGE, but of course you can name it as you wish.

Once you went through the wizard, the new hard drive will be ready to use. It will also be visible in the Explorer:



Process Controlling With Supervisor

If you run your own virtual or dedicated server, chances are that you want to run a specific program or a number of programs that make up the service you want to use or offer. If the program you want to run is part of the Linux distribution of your choice there usually is not much more to it than installing the package and configuring the program. However, if the program comes from an external source or you are writing it yourself, you need to make sure it is started automatically when the server is booting. Additionally, during development or early testing phases of your own program, there might be errors in the code leading to a crash of your application and you might want to make sure that it gets restarted automatically in such a case. A few years ago, the solution to the first issue was quite simple. All you needed to do was to create an init script that would then handle the starting and stopping of the server. However, recently many Linux distributions changed the way they handle the boot process. Some are still using init, others may be using upstart or even systemd now. Providing the files necessary for all of this systems can be quite a hassle and while upstart and systemd support restarting programs on unexpected termination, implementing this with init is possible but requires to change init's configuration itself.

For my own needs I have become attached to using supervisor for this task - the program and the documentation can be found on http://supervisord.org, but most Linux distributions provide pre-built packages in their repositories. Supervisor itself is a daemon that is run by the system's process management so it gets run by init or it's counterparts. To run your own program, you have to add it to supervisord's configuration and it will make sure that it gets started on boot and restarted in case it crashes.

As an example, I will be using a very small custom web application written in Python using the bottle framework. Since this article is not about web programming, I am keeping it simple:

1 from bottle import route, run
3 @route('/')
4 def index():
5     return 'Hello World'
7 run(host='', port=8080)

All this does is run a webserver on port 8080 and displaying Hello World in your web browser when you navigate to it. If the above code is saved to a file app.py, you can run it using python app.py and it will just run forever (or until it crashes). Now would be a good time to configure supervisor to run this application for us. Supervisor provides a command line tool called supervisorctl to check the status of configured applications and to start or stop them if needed. Running supervisorctl status will show you... nothing, as we did not set up anything yet. We create a new file called hello.conf which will contain everything supervisor needs to know to run our application and place it in /etc/supervisor/conf.d/. The most basic configuration defines a new program to run with a given name and a command to be executed as well as a user name that the program should be run with - if you leave this, your program will run as root which is almost always a bad idea:

command=/usr/bin/python /home/markus/app.py

Note that it is usually a good idea to provide absolute paths in such configurations. After the file has been saved, you can use supervisorctl reread to cause supervisor to reread its configuration file. If everything is right, the output of the command should tell you that a program named hello is now available:

# supervisorctl reread
hello: available

We can now start the program by running

# supervisorctl start hello
hello: started

Check the status again to see if its actually running now:

# supervisorctl status
hello                 RUNNING    pid 32675, uptime 0:00:46

As you can see, it tells us that the program is running, it's PID and the time elapsed since it's start. To simulate a crash, we will forcefully terminate the program and check if supervisor restarts it as expected:

# kill -9 32675
# supervisorctl status
hello                 RUNNING    pid 32686, uptime 0:00:04

The supervisor homepage gives you a lot more information about possible values to configure supervisor itself and the programs it runs. You can even configure the location of log files and automatic rotation for them in case they grow over a given size. More details about this can be found here: http://supervisord.org/configuration.html. Finally, no more reason to run your applications in detached screen sessions... 😉