Showing posts with label OpenBSD. Show all posts
Showing posts with label OpenBSD. Show all posts

Thursday, February 2, 2017

Accelerate an OpenBSD NFS server

The nfs server on openbsd has been super slow.  I thought it was the result of wifi + an old computer until I tried an scp download.  the difference was several orders of magnitude.  Anyway, the solution was to cut down the size of the data packets used by the protocol.

Here's my /etc/fstab - the change is in bold.  Apparently there's a sweet spot of not-too-small and not-too-big.  These sizes are measured in bytes, by the way.  That's a packet size of 4 kb that I'm specifying.
one:/home/admin/storage     /storage  nfs  rsize=4096,wsize=4096  0 0

Wednesday, February 1, 2017

NFS server on OpenBSD

I still use OpenBSD for my server, so here goes setting up an NFS on it.  This is a fantastic resource.

Note: if having trouble with the vi text editor, I listed a few simple commands elsewhere on the blog.  For now, a few quick reminders:
i        -->       enters Insert mode (where you can enter text)
[ESC]    -->       enters command mode
:w       -->       saves the file (have to be in command mode)
:q       -->       exits the file (have to be in command mode)

Let's call the shared folder 'storage'.  We'll put it in the home directory of the user 'admin'.  We have to create the user, and the folder.
useradd -b /home/faculty/ -s /bin/bash -m admin
passwd admin
Let's use the password
Password!
since this is a local machine, and I'm assuming that the folks on the LAN are friendly.

Next, make sure the new user owns their home directory.
chown -R admin: admin
And then create the shared directory inside /home/admin,
mkdir /home/admin/storage
and make sure that everyone can read/write to that spot.
chmod -R 777 /home/admin/storage
I think nfs can be activated by adding the following to rc.conf.local. (src; might not be updated, and I can't see more than the first bit)
vi /etc/rc.conf.local
add to the end of the file:
portmap=YES
nfs_server=YES
OR, I can run these two commands.  There's this thing about multiple server instances, so that I can handle concurrent requests, that I can control with the following commands...I just don't know if the services will be enabled after a reboot.
rcctl enable portmap mountd nfsd
rcctl set nfsd flags -tun 4
Once the services are started, the /etc/exports file needs an entry.  This is how the machine knows to share the folder - and who to share it to.
vi /etc/exports
add to the bottom (this gives everyone accessing the folder root access),
/home/admin/storage -alldirs -mapall=root
Now the nfs service can be started
rcctl start portmap mountd nfsd
and in case you edited the /etc/exports file while the NFS was running, restart the service.
rcctl reload mountd

Mount

to mount the new network folder, you have to create your own location for the folder to present itself, and then set the folder to automount.

Also, don't forget to install the nfs software.  It came default on OpenBSD, but not so much on Linux Mint.
sudo apt-get install nfs-server -y
create /storage in the root directory
sudo mkdir /storage
give everyone all permissions
chmod 777 /storage
edit the fstab to automount the folder - we'll assume the hostname of the OpenBSD server is 'server1'
sudo nano /etc/fstab
and add this to the bottom of the file
server1:/home/admin/storage     /storage  nfs 
and remount everything
sudo mount -a
that's it!  You should have full access to the network folder.

Wednesday, November 9, 2016

Basic filesharing server on OpenBSD (updated for 6.0)

For the record.  I assume that the other OpenBSD pages on this site have already been implemented.

Install samba:
pkg_add samba
Create a folder to use as a shared location.  According to the official docs, that's what /srv is for.  Since I use this a lot, I'm not going to bother with any further file structure.
mkdir -p /srv/
chmod 777 /srv/
Modify the samba configuration file for a basic all-permissive shared folder.  My threat model assumes that if someone is connected to the network, they're friendly.  Since there's several Win7 computers on the network, I had to get around the authentication requests.

Cut & paste stuff doesn't really work on the command line, so here's what needs to be added at the bottom of the /etc/samba/smb.conf. src.
nano /etc/samba/smb.conf
[SRV]
    path = /srv/
    public = yes
    only guest = yes
    writable = yes
    printable = no
    guest ok = yes
    read only = no
    map to guest = bad user
After finishing the smb.conf edits, use the rc.conf.local file to start the samba share with the machine.  You can use the echo command to make the adjustments.  Note: rc.conf.local doesn't actually exist in the default OpenBSD...but it is acknowledged.  src.
echo '
smbd_flags="-D"
nmbd_flags="-D"
' >> /etc/rc.conf.local
rcctl enable samba
rcctl restart samba
That should do it.

Open a USB drive on OpenBSD

For the record.

Find out the device name of the usb with (e.g., sd1):
sysctl hw.disknames
Then find out the name of the partition you want to mount with (e.g., i):
disklabel sd0
Then create a mount point (a folder that is linked to the partition you're mounting):
mkdir /mnt/foo
Then mount the partition at that location (e.g., sd1i):
mount /dev/sd1i /mnt/foo
To remove your flash drive, run:
umount /mnt/foo

Setting up OpenBSD (updated for 6.0)

A few notes on how I set up my OpenBSD installation.  This will be an ongoing compilation.

Installation

Had to do this with a USB connected CD drive.  Followed the instructions for a flash drive, but the installation itself didn't want to play ball.  I forget the exact scenario; it was confusing.

Wireless

I'm on an Acer Aspire One from a long time ago - I believe it's a D250 model.  It uses the athn0 wifi driver.  Set it up by putting this into your /etc/hostname.ath0 file (copy the whole thing into the command prompt and run it):
echo "
nwid 'foo'
wpakey 'bar'
dhcp 
" > /etc/hostname.ath0
Replace the text as required with your own information...specifically, the stuff that says foo and bar.  :)  After that's added, run:
sh /etc/netstart
...because it won't start automatically.  Don't know why.  I used this link to figure out how to get it running.

Ethernet

If you have ethernet access, internet is somewhat simpler.  Find out what the ethernet device name is:
ifconfig
Mine is fxp0.  Using DHCP makes things easy.  All this command does is put dhcp in the device's config file.
echo dhcp > /etc/hostname.fxp0
Reboot, and you should be online.  Any problems, visit http://www.openbsd.org/faq/faq6.html#Setup
and http://www.openbsd.org/faq/faq6.html#DHCP.

Package Installation

See http://www.openbsd.org/faq/faq15.html#Intro for an excellent explanation of how all this works.

Setting up the Package Mirror

Being able to install packages is always nice.  On OpenBSD, you have to specify the mirror you want to search from and download from manually.  You can set this variable after startup every time, or put it in your .profile.  I used the MIT mirror; it's not going anywhere anytime soon. [edit: ok, it did go.  They didn't keep the 5.9 mirror once 6.0 came out; here's the link to the 6.0 packages.]
vi ./.profile
Now add (I stuck it in the middle of the file):
export PKG_PATH=http://mirrors.mit.edu/pub/OpenBSD/$(uname -r)/packages/$(uname -m)/
Except that in my case this didn't work.  OpenBSD read that as
mirrors.mit.edu/pub/OpenBSD/OpenBSD/packages/i386/
which doesn't make sense.  Instead, I had to do
export PKG_PATH=http://mirrors.mit.edu/pub/OpenBSD/6.0/packages/$(uname -m)/
which destroys flexibility when I upgrade to 6.0 (whenever that comes out). Changed for compatibility with 6.0.

Installing a Package

Now I can do
pkg_add python-2.7.11
to install python 2.7 - but to get that full package name, I have to do CTRL-F in the mirror webpage and figure out what's available.  I'm pretty sure there's a way to search that on the command line, but I haven't figured it out yet.  If only the package name, and not the exact version number, is known, then just use that.  The following successfully installs nano.
pkg_add nano

Turning the Computer Off

Restarting

Restarting is simple: 
reboot

Shutting Down

You'd think this would be simple, eh?  Linux works with a straightforward
shutdown now
but that eventually brings you right back to the shell on my computer's OpenBSD installation.  I have to use 
halt
Though, and I haven't tried this yet, something like
shutdown -h now
is also supposed to work.  This thread has more details.

Sunday, July 31, 2016

Mutt on OpenBSD

Mutt is a command-line based mail reader.  I've heard that even top execs at Google have used it as their primary mail reading tool.  These are my notes for setting it up on OpenBSD 5.9 for use with gmail.  I've heard it can be used in conjunction with davmail(??) to deal with Microsoft Exchange.
sources here:
https://dev.mutt.org/trac/wiki/UseCases/Gmail 
https://www.linux.com/blog/setup-mutt-gmail-centos-and-ubuntu 
in order to use the trash function with Gmail, you have to apply this patch
http://cedricduval.free.fr/mutt/patches/#trash 
how to do it:
http://cedricduval.free.fr/mutt/patches/#patch
install mutt and nano (for ease of command-line text editing).
sudo apt-get install mutt nano
create the mutt config file and open it.
touch ~/.mutt/muttrc
nano ~/.mutt/muttrc
The contents of the config file can vary, based on what you actually want.  Mutt doesn't by default understand spaces in mailbox/folder names, so you have to change that setting in the muttrc file.

Here is a link to my own muttrc file on Github.  

Final post here

I'm switching over to github pages .  The continuation of this blog (with archives included) is at umhau.github.io .  By the way, the ...