Skip to content
Pontiac76 edited this page Jun 8, 2024 · 2 revisions

About - The LONG document

This Wiki is about how I kinda-sorta automated (Maybe work my way up to FULLY automating...) how to create images on a Linux system for NetDrive to work remotely.

Who this is aimed at

  • New to Linux Users: Could be a struggle
  • Lightly seasoned Users: Could use a bit more salt, but, shouldn't be that difficult to navigate
  • True Linux Adminstrators: You should have written this doc! ;) Easy peasy.

Why I no do sudo..

I am not a fan of the sudo command. I won't use it if I can get away with it. I try not to install it on any of my machines anymore as I see it as a pretty severe security issue.

The reason is simple. If someone figures out my "obscenely simple" login name and password via sheer luck, watching over my shoulder, or, brute forcing it to get to my machines, #1, I'm an idiot and I deserve the damage to be done. #2, since they know my password, they can just sudo to the root account and run amuck. I'd much rather do the work I need to do in the root acount with a more complex password and shut down the session when or lock the computer. This ensures that there is less of an easy path to get to root. I don't typically use a Linux machine "locally" unless I'm standing at my server rack, or if I'm in WSL on my machine. Otherwise, I'm SSH'n all day long.

Building a Linux machine

I personally prefer Debian over anything other full on distribution, and as I run my servers headless, I save resources by not using gnome, kde, or any other flavour of graphical eye candy. Console 100% of the way.

I'll be writing this outline for Debian 12.5 (Bookworm), but, the concepts should be pretty close to whatever OS you wish to use.

Initialization

Get your Linux machine built, there's plenty of documents and videos out there on how to do that. I'd not recommend WSL in this case as I'm not sure that you can route internet traffic INTO it. If you can, great, but, out of scope for this document, as I don't want to run a server on my primary use gaming rig.

In this doc, I'm assuming you're either going to build a Debian based container, or use Docker to get a container going, or, build a full fledged OS on some real hardware, or in some kind of hypervisor. Whatever you use, you're on the hook for the networking aspect.

Heads up!

There's going to be three users involved here. When you install Debian, you're asked to set the root password, setup your own account, and then we'll add a new account later in this document.

The reason for this is when you're building a new Linux machine, there could be some assumptions that since you're creating your first user, you might want to have an easier path to root. For the security conscious, you might not want to do that. So we'll create a new account SPECIFICALLY to handle the NetDrive software.

The root user is going to be doing the heavy lifting on creating the images and the users and such. Standard users do not have enough access to use the mount command with the way we're using this.

HINTS BEFORE WE BEGIN

  • When getting things connected, start LOCAL.
    • Get your DOS machine talking to another computer just by pinging it with the mtcp tooling. This verifies network connectivity.
    • Get your DOS machine talking to your netdrive server.
      • If this is failing, chances are, your server has a firewall up and running. Disable it, or, allow the required UDP ports to be open (2002 by default)
        • Again, you're on the hook for networking.
  • If you're going to expose this to the internet, poke holes on your Firewall if you can.
    • If you can't because of the kind of ISP you're using, then, you'll need to investigate how to tunnel from the outside world in. Currently, CloudFlare does offer such a service for free, but I've not used it. Doing that is way outside the scope for this.
  • You may want to setup several netdrive services on one machine, which is entirely possible. You just need to setup netdrive to run on different ports. That way you can have one image setup for your own stuff, another for public "read only" type access, and another for friends/colleagues use.
    • NOTE: There are ZERO credentials when getting a DOS machine to talk to a netdrive image. No logins, no passwords, no security AT ALL. Be careful with what you're doing!

The Server

In my case, I built a Debian 12.5 (Bookworm) Virtual Machine on my ProxMox server. The basics of the system build are:

  • 1 Socket
  • 2 Cores
  • 16 Gig RAM
  • 64 Gig HDD
  • NIC enabled

But that's just me. You can EASILY get away with something like:

  • 1 Socket
  • 1 Core
  • 4 Gig RAM
  • 10 Gig HDD

  • 100mbit NIC

Debian should run fine with 4 Gig of RAM so long you don't start using it to playing games. So.. don't. That's not the intent of this machine. Keep it slim, Jim.

I brought the VM up and online with a Debian 12 netinst ISO image. You can get away with a full fledged ISO. You do you in this case.

The Base Server Software

You'll need a few things

apt update
apt upgrade
apt install unzip mtools screen
mkdir /mnt/netdrive

Keeping it simple, unzip is your standard "unzipping" tool for files. mtools includes a bunch of tooling to allow you to mount the files we make with netdrive. screen is an application that lets you keep things running outside of your SSH session when you get disconnected.

Create a new user

Because... you really should. Really.. you should...

If you're not using the root account, switch.

su -

Enter the password you set for the root account (Not your personal)

As the root user:

adduser netdrive

Follow the prompts, which should mostly just be hitting ENTER on all the questions it asks. Pick a password that only you will know. You want this account to be as LIMITED as possible. We're NOT going to be using your personal account you created during the Debian install, nor are you going to be running this as root.

For now, switch to the netdrive user.

su - netdrive
cd ~
mkdir pimages rimages fimages
exit

This is going to make three directories. One for Private images, Read Only images, and Friends Images. We also go back to the root account.

The Software

There are a few things we need to do to get this show started. First, go to https://www.brutman.com/mTCP/mTCP_NetDrive.html and download the Servers ZIP file. Inside the zip, you'll want to find the linux_x86\netdrive application, and get it onto your Linux machine. Here's how I do it;

In your brand new, and updated Linux machine, as the netdrive user copy the following set of commands and paste into your Linux machine.

cd /tmp
wget https://www.brutman.com/mTCP/mTCP_NetDrive.html
wget https://www.brutman.com/mTCP/`cat mTCP_NetDrive.html | grep href | grep Servers | cut -f2 -d"\""`
unzip mTCP_NetDrive_*_Servers.zip
cp -v `find . -type d | grep linux_x86`/netdrive ~
cd ~

Note the back-ticks. It's a backwards single back-tick, or the unshifted tilde key (~) on standard U.S. non multi-lingual type keyboards. You'll see that character on the the second wget and on the cp line. This is ASCII character 96, so, you're manually tying this in, and not doing a copy/paste, press and hold the ALT key, then type 0096, then let go of the ALT key.

whhaaaahhh???

The first wget downloads the web page that the files we need are at.

The second is actually a two-parter. Inside the back ticks, it's "catting" or reading the file you just downloaded, looking for all references to HREF (In lower case), then looking for the word Servers (Case sensitive) and then getting the content between the quotes. This is just going to grab the Servers file and drop it wherever you're at, and won't go old unless Michael wises up to this. ;)

The next set of activities are:

  • Unzip the file from the second wget
  • Copy the relevant netdrive executable to your home directory.
  • Go back to your home directory.

The files dumped to /tmp are small enough to be not that much of a worry. Rebooting the machine will clean those files up. /tmp is a temporary file system out of the box.

NetDrive Prep

I'm eventually going to write a script for this section so it's easier to use. This is just a step-by-step on what the script is going to do, with parameters and such.

Now that we have netdrive at the ready, let's get into making some images. First, we need to be the root user.

su -
cd /home/netdrive/

Next, we need to make an image. For the first run, we'll make a 10-meg image to the Private directory

./netdrive create hd 10 fat16b pimages/test.img
chown netdrive:netdrive pimages/test.img

Now we mount this test image.

mount -o loop pimages/test.img /mnt/netdrive
cd /mnt/netdrive
touch this.txt

We made the /mnt/netdrive directory much earlier in this document. The -o loop is required (Even though some say it's not, it is required here) that's sourced to your pimages/test.img and mounted to /mnt/netdrive. We then go into that drive and create a text file to validate that we've made the file.

At this point, we're in a kind of precarious position. We can't mount the image yet, because we're still toying with it. But this just is proof that the spoon does exist. We've written a file into an image.

Now, to finish up and get a DOS machine hooked into this....

cd ~
umount /mnt/netdrive
exit

This gets us out of the netdrive directory, and we can safely unmount. If you get an error saying that the mount is in use, find out why using tools like lsof or something of the sort. Either that, close out of all your SSH sessions and log in again getting back to the netdrive user.

Connection time!

You need to get the current IP address for your system. Run this as any user:

ip ad | grep "inet " | grep -v 127.0.0.1

Note that there is a space after inet intentionally.

This should return a single IP address.

Now run netdrive for your personal images:

cd ~
./netdrive serve -image_dir pimages -port 2002

You should see that mTCP NetDrive server is running.

Going over to your "already networked and configured with TCP netdrive applications" DOS machine, run the following:

netdrive connect {your_server_ip}:2002 test.img d:
d:
dir

Replacing {your_server_ip} with whatever the inet address was shown on the server above.

You should now see "THIS.TXT" as a zero-byte file.

When you're done, on the DOS machine, disconnect from the D drive

c:
netdrive disconnect d: