Disks and Filesystems NetBSD names disks by driver and number: sd0 is the first SCSI or SATA disk, wd0 the first IDE disk, ld0 a logical disk, cd0 a CD or DVD drive. A partition is a letter after the disk: sd0a is the first partition of the first disk. The raw device has an r in front (rsd0a); the block device is the one you mount. Seeing what is there $ dmesg | grep -E 'sd|wd|cd' $ disklabel sd0 $ df -h $ du -sh /home/* disklabel8 prints the partition table of a disk; df1 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. Adding a disk A new disk has no label until one is written. The interactive editor is the safe way to look first: # disklabel -i sd1 disklabel> p disklabel> a partition> a offset> [Enter] size> [Enter] fstype> 4.2BSD disklabel> w disklabel> q The partition table is written by w; nothing happens before it. A GPT disk can be edited with gpt8 instead. After the label, make a file system and mount it: # newfs /dev/rsd1e # mkdir -p /data # mount /dev/sd1e /data The raw device is the one for newfs. A file system that should come back after a reboot belongs in /etc/fstab: /dev/sd1e /data ffs rw 1 2 newfs8 destroys what was on the partition. Check the device name with disklabel before you type it. Backing up a file system dump8 and restore8 are the NetBSD pair for a whole file system. They preserve owners, modes and hard links, which cp does not: # dump -0 -f /backup/root.dump / # restore -i -f /backup/root.dump For a directory, tar1 is enough, and a compressed archive is easier to keep: $ tar -czf /backup/home.tar.gz /home $ tar -xzf /backup/home.tar.gz -C / A backup that has never been restored is a hope. Restore one file from the archive before you trust it. Encrypted disks An installation with encryption uses cgd4. The key is derived from a passphrase and stored in /etc/cgd/disk. 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 /cgdboot. To encrypt another disk by hand, create the configuration, then the cgd device, then a file system on it: # 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 The exact partition letters and the choice of algorithm are the administrator's; cgdconfig8 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. RAID, LVM and concatenation 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: raidctl8 — 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. lvm8 — logical volumes: physical volumes, a volume group, logical volumes that can grow. It is the flexible choice for a data disk. ccdconfig8 — concatenation and striping without RAIDframe. Simple, and with no redundancy. 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. Checking a file system fsck8 runs at boot on an unclean file system. A file system that needs it by hand must be unmounted first: # umount /data # fsck -f /dev/rsd1e # mount /data fsck -n only reports; it changes nothing. The output names every repaired inode, and a file that was open during a crash can end up in lost+found at the top of the file system.