tutes-dump/site-tutorials/VPS_NetBSD.html

179 lines
5.3 KiB
HTML
Raw Normal View History

2020-07-11 06:11:19 -04:00
<style type="text/css">
pre {
margin-left: 2em;
}
</style>
<!-- NetBSD logo, right-aligned. Non-commercial use is permitted. -->
<div style="float:right;margin-right:1em;">
<img src="http://sdf.org/tutorials/images/NetBSD.png"/>
</div>
<h1>NetBSD on SDF VPS</h1>
<h2>Contents</h2>
<ul>
<li>
<a href="#first_steps">First Steps</a>
<ul>
<li><a href="#user_accounts">User Accounts</a></li>
<li><a href="#system_clock">System Clock</a></li>
<li><a href="#networking">Networking</a></li>
</ul>
</li>
<li><a href="#pkgsrc">pkgsrc</a></li>
<li><a href="#tips">Miscellaneous Tips</a></li>
<li><a href="#references">References</a></li>
</ul>
<h2 id="first_steps">First Steps</h2>
<h3 id="user_accounts">User Accounts</h3>
<p>After you have installed and started your NetBSD VPS, go to the
console and log-in as user root with the default password, "root".</p>
<p>One of the first things you
will want to do is change the default root password by typing
<code>passwd</code> at the prompt. Don't forget this password as there is
currently no way to recover it.</p>
<p>It is also a good habit to create a regular user account for
working, using <code>su</code> to obtain root privileges as needed.
To create a regular user account which is part of the administrative
<code>wheel</code> group:</p>
<pre>useradd -m -G wheel &lt;username&gt;</pre>
<p>Then immediately set its password with:</p>
<pre>passwd &lt;username&gt;</pre>
<p>This user will be in the <code>wheel</code> group and will be able
to perform administrative tasks by runing <code>su</code> to obtain
superuser privileges using the root password.</p>
<h3 id="system_clock">System Clock</h3>
<p>It is customary on UNIX systems for the system clock to be set
to UTC. To set the local time zone, find your zone file in
<code>/usr/share/zoneinfo/</code> and link to it at
<code>/etc/localtime</code> as follows:</p>
<pre>ln -fs /usr/share/zoneinfo/Europe/Helsinki /etc/localtime</pre>
<h3 id="networking">Networking</h3>
<p>Look at the first line of your control panel at vps.sdf.org and note YOUR_HOSTNAME
(e.g. netbsd99), EXTERNAL_IP (e.g. 205.166.94.nnn), and INTERNAL_IP
(e.g. 10.1.0.nnn):</p>
<pre>
VPS Maintenance Shell for netbsd99 (205.166.94.nnn / 10.1.0.nnn)
-------- ------------- ----------
^ ^ ^
| | |
| EXTERNAL_IP INTERNAL_IP
|
YOUR_HOSTNAME
</pre>
<p>Open /etc/rc.conf in an editor and, replacing the text YOUR_HOSTNAME,
EXTERNAL_IP, and
INTERNAL_IP with your own actual host name and IP numbers, add:</p>
<pre>
hostname=YOUR_HOSTNAME.sdf.org
defaultroute=205.166.94.1
auto_ifconfig=yes
ifconfig_xennet0="inet EXTERNAL_IP netmask 0xffffff00"
ifconfig_xennet1="inet INTERNAL_IP netmask 0xffffff00"
</pre>
<p>Then put this in /etc/resolv.conf:</p>
<pre>nameserver 205.166.94.20</pre>
<p>Add this to /etc/hosts:</p>
<pre>EXTERNAL_IP YOUR_HOSTNAME.sdf.org YOUR_HOSTNAME</pre>
<p>Run/Type:</p>
<pre>/etc/rc.d/network restart</pre>
<h2 id="pkgsrc">pkgsrc</h2>
<p>On NetBSD you can mount a pre-built (and still in progress) pkgsrc DESTDIR.
Following the procedures below will effectively install the 2000+ included
packages on your virtual NetBSD system.</p>
<p>Note that at the moment the pre-built pkgsrc assumes that its
path is /pkgshare. Some programs won't work under a different
prefix since they won't be able to find their shared libraries.</p>
<pre>
mkdir -p /pkgshare
rmdir /usr/pkg
ln -s /pkgshare /usr/pkg
rm -rf /var/db/pkg
ln -s /pkgshare/db/pkg /var/db/pkg
mount -t nfs 10.1.0.1:/pkgshare /pkgshare
export PATH=$PATH:/usr/pkg/bin:/usr/pkg/sbin
</pre>
<p>It is read only.</p>
<p>To set this up on boot, execute the steps above and then:</p>
<pre>
echo "nfs_client=YES" >> /etc/rc.conf
echo "rpcbind=YES" >> /etc/rc.conf
echo "10.1.0.1 vps" >> /etc/hosts
echo "vps:/pkgshare /pkgshare nfs ro" >> /etc/fstab
echo "export PATH=$PATH:/usr/pkg/bin:/usr/pkg/sbin" >> /etc/profile
</pre>
<p>Note that you cannot use both this pre-built pkgsrc and pre-built packages
from netbsd.org. It may be possible to set the system up so you can, however
this is best left to the experienced NetBSD administrator.</p>
<h2 id="tips">Miscellaneous Tips</h2>
<h3>Free up disk space by removing unwanted sets</h3>
<p>The default image comes with all distribution sets installed. You can free
up some disk space by removing the ones you don't need.</p>
<p>First, check which distribution sets are installed:</p>
<pre>ls /etc/mtree</pre>
<p>Decide which sets you want to remove and examine their contents. For example,
to remove games and all X11 sets:</p>
<pre>
for set in games xbase xcomp xetc xfont xserver ; do \
tar tzf /usr/INSTALL/$set.tgz | sed -e 's/^\.//' &gt;&gt; /tmp/purgelist ; \
done
</pre>
<p>After examining <code>/tmp/purgelist</code> and removing any files you want to
keep, do:</p>
<pre>cat /tmp/purgelist | xargs rm</pre>
<h2 id="references">References</h2>
<ul>
<li><a href="http://www.netbsd.org/docs/guide/en/">The NetBSD Guide</a></li>
<li><a href="http://wiki-static.aydogan.net/The_NetBSD_System_Manager%27s_Manual">The
NetBSD System Manager's Manual</a></li>
</ul>
<hr />
<div>
$Id: VPS_NetBSD.html,v 1.23 2018/02/22 15:12:01 slugmax Exp $
</div>