Files
makronix/docs/guide/chapters/disks.xml
T
lotherk b654bf74a2 docs: add The Makronix Guide and its four installed forms
One DocBook source in docs/guide produces the manual pages, one HTML
file, the PDF and an MCDE information library.  The guide follows the
structure of The NetBSD Guide, describes Makronix 0.99.10
(Camouflage), and has its own chapters for MCDE, the Information
Manager and the display.

The forms are installed by the release:

  /usr/share/doc/makronix/makronix-guide.html
  /usr/share/doc/makronix/makronix-guide.pdf
  /usr/share/doc/makronix/infolib/makronix.dti/   (base-sys-share)
  /usr/share/man/man7/makronix-guide*.7           (man-reference-man)
  /etc/dt/config/Xsession.d/0000makronix          (etc-sys-etc)
  /etc/dt/infolib/en_US.UTF-8/makronix.dti        (symlink)

The information library is built with MCDE's dtdocbook2infolib from a
small Lua writer for the CDE DocBook SGML dialect; tools/test-tools.sh
runs docs/guide/check.sh on the installed copies and proves that a
missing manual page falls red.
2026-11-15 21:21:49 +00:00

158 lines
6.5 KiB
XML

<!-- License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. -->
<chapter id="disks">
<title>Disks and Filesystems</title>
<para>NetBSD names disks by driver and number: <filename>sd0</filename>
is the first SCSI or SATA disk, <filename>wd0</filename> the first IDE
disk, <filename>ld0</filename> a logical disk, <filename>cd0</filename> a
CD or DVD drive. A partition is a letter after the disk:
<filename>sd0a</filename> is the first partition of the first disk. The
raw device has an <literal>r</literal> in front
(<filename>rsd0a</filename>); the block device is the one you mount.</para>
<sect1 id="disks-see">
<title>Seeing what is there</title>
<screen>$ dmesg | grep -E 'sd|wd|cd'
$ disklabel sd0
$ df -h
$ du -sh /home/*</screen>
<para><citerefentry><refentrytitle>disklabel</refentrytitle><manvolnum>8</manvolnum></citerefentry>
prints the partition table of a disk;
<citerefentry><refentrytitle>df</refentrytitle><manvolnum>1</manvolnum></citerefentry>
shows what is mounted and how full it is. A machine installed with the
simple way has a GPT label and a root partition that uses the whole
disk; the full way can have an MBR label and a NetBSD disklabel inside
it, as NetBSD documents.</para>
</sect1>
<sect1 id="disks-add">
<title>Adding a disk</title>
<para>A new disk has no label until one is written. The interactive
editor is the safe way to look first:</para>
<screen># disklabel -i sd1
disklabel&gt; p
disklabel&gt; a
partition&gt; a
offset&gt; [Enter]
size&gt; [Enter]
fstype&gt; 4.2BSD
disklabel&gt; w
disklabel&gt; q</screen>
<para>The partition table is written by <literal>w</literal>; nothing
happens before it. A GPT disk can be edited with
<citerefentry><refentrytitle>gpt</refentrytitle><manvolnum>8</manvolnum></citerefentry>
instead. After the label, make a file system and mount it:</para>
<screen># newfs /dev/rsd1e
# mkdir -p /data
# mount /dev/sd1e /data</screen>
<para>The raw device is the one for <command>newfs</command>. A file
system that should come back after a reboot belongs in
<filename>/etc/fstab</filename>:</para>
<screen>/dev/sd1e /data ffs rw 1 2</screen>
<para><citerefentry><refentrytitle>newfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>
destroys what was on the partition. Check the device name with
<command>disklabel</command> before you type it.</para>
</sect1>
<sect1 id="disks-backup">
<title>Backing up a file system</title>
<para><citerefentry><refentrytitle>dump</refentrytitle><manvolnum>8</manvolnum></citerefentry>
and <citerefentry><refentrytitle>restore</refentrytitle><manvolnum>8</manvolnum></citerefentry>
are the NetBSD pair for a whole file system. They preserve owners,
modes and hard links, which <command>cp</command> does not:</para>
<screen># dump -0 -f /backup/root.dump /
# restore -i -f /backup/root.dump</screen>
<para>For a directory, <citerefentry><refentrytitle>tar</refentrytitle><manvolnum>1</manvolnum></citerefentry>
is enough, and a compressed archive is easier to keep:</para>
<screen>$ tar -czf /backup/home.tar.gz /home
$ tar -xzf /backup/home.tar.gz -C /</screen>
<para>A backup that has never been restored is a hope. Restore one file
from the archive before you trust it.</para>
</sect1>
<sect1 id="disks-encryption">
<title>Encrypted disks</title>
<para>An installation with encryption uses
<citerefentry><refentrytitle>cgd</refentrytitle><manvolnum>4</manvolnum></citerefentry>.
The key is derived from a passphrase and stored in
<filename>/etc/cgd/</filename><replaceable>disk</replaceable>. The
installer writes it; the boot loader asks for the passphrase before the
root file system is mounted. The unencrypted partition that the loader
reads is <filename>/cgdboot</filename>.</para>
<para>To encrypt another disk by hand, create the configuration, then
the cgd device, then a file system on it:</para>
<screen># cgdconfig -g -k argon2id -o /etc/cgd/sd1e adiantum 256
# cgdconfig cgd0 /dev/sd1e
/dev/sd1e's passphrase:
# newfs /dev/rcgd0a
# mount /dev/cgd0a /mnt</screen>
<para>The exact partition letters and the choice of algorithm are the
administrator's; <citerefentry><refentrytitle>cgdconfig</refentrytitle><manvolnum>8</manvolnum></citerefentry>
documents the parameters and the verification methods. A lost
passphrase cannot be recovered; keep a copy of the configuration in a
safe place, not the passphrase.</para>
</sect1>
<sect1 id="disks-raid-lvm">
<title>RAID, LVM and concatenation</title>
<para>NetBSD has three ways to combine disks. Each has its own manual
page and its own recovery rules, and each is a decision to make before
the data is on it:</para>
<itemizedlist>
<listitem><para><citerefentry><refentrytitle>raidctl</refentrytitle><manvolnum>8</manvolnum></citerefentry>
&#x2014; RAIDframe, hardware-independent RAID levels 0, 1, 5 and more.
The configuration is a file; the set must be assembled before the root
file system is mounted if it holds the root.</para></listitem>
<listitem><para><citerefentry><refentrytitle>lvm</refentrytitle><manvolnum>8</manvolnum></citerefentry>
&#x2014; logical volumes: physical volumes, a volume group, logical
volumes that can grow. It is the flexible choice for a data
disk.</para></listitem>
<listitem><para><citerefentry><refentrytitle>ccdconfig</refentrytitle><manvolnum>8</manvolnum></citerefentry>
&#x2014; concatenation and striping without RAIDframe. Simple, and
with no redundancy.</para></listitem>
</itemizedlist>
<para>Whichever you choose, the rule is the same: write the
configuration down, test that it comes back after a reboot, and only
then put the data on it. A RAID set that has never been assembled from
a cold boot is not yet a backup.</para>
</sect1>
<sect1 id="disks-check">
<title>Checking a file system</title>
<para><citerefentry><refentrytitle>fsck</refentrytitle><manvolnum>8</manvolnum></citerefentry>
runs at boot on an unclean file system. A file system that needs it by
hand must be unmounted first:</para>
<screen># umount /data
# fsck -f /dev/rsd1e
# mount /data</screen>
<para><command>fsck -n</command> only reports; it changes nothing. The
output names every repaired inode, and a file that was open during a
crash can end up in <filename>lost+found</filename> at the top of the
file system.</para>
</sect1>
</chapter>