Blame
Date:
Wed Dec 7 05:00:19 2022
UTC
Message:
Daily backup
010
2021-12-17
targets=Openbsd.Backup,Openbsd.Announce,Openbsd.Dump,Openbsd.Restore,Openbsd.Growpartition,Openbsd.Vmmuser,Openbsd.Buyvm,Openbsd.Ed
011
2021-12-17
text=(:title Adding a New Disk:)%0a%0a'''WARNING''': '''BE CAREFUL!''' Some commands in this tutorial can cause permanent data loss. We recommend you [[openbsd/backup|backup]] your files before attempting to run these commands. You should also double check every command to make sure you have made no typos or mistakes. A single typo could destroy your data forever!%0a%0a'''NOTE''': This guide is '''no''' substitute for reading the [[https://www.openbsd.org/faq/|OpenBSD FAQ]]. In particular, you should read the section on [[https://www.openbsd.org/faq/faq14.html|Disk Setup]].%0a%0a'''NOTE''': Before performing the upgrades, you will want to [[openbsd/announce|announce]] the changes to your users and teammates.%0a%0aOn OpenBSD, there are two disk drivers: [[https://man.openbsd.org/wd|wd]] and [[https://man.openbsd.org/sd|sd]]. wd is an IDE-like disk, and sd is a SCSI-like disk (including USB disks). To list all your available disks:%0a%0a[@%0a$ dmesg | grep -E '(sd[0-9]|wd[0-9])'%0asd0 at scsibus2 targ 0 lun 0: %3cBUYVM, SLAB, 2.5+> serial.BUYVM_SLAB_VOLUME-4047%0asd0: 524288MB, 512 bytes/sector, 1073741824 sectors, thin%0asd1 at scsibus3 targ 0 lun 0: %3cVirtIO, Block Device, >%0asd1: 40960MB, 512 bytes/sector, 83886080 sectors%0a@]%0a%0aIn this example, our server has two SCSI-like disks (a BuyVM slab and a VirtIO block device). In this case, the VirtIO block device is the hard disk the operating system is installed on, and the slab is extra storage we purchased. The disks are numbered by the order in which they are detected at boot time. The first SCSI-like disk will be sd0, the second sd1, and so forth.%0a%0aThe first disk @@sd0@@ can store around 500GB of data, the second disk @@sd1@@ can store around 40GB.%0a%0aWe will now add the new space from @@sd0@@ by creating a new partition for the disk, formatting it, and then mounting it to the filesystem.%0a%0a'''WARNING''': Double check your commands and make certain you are editing the correct disk. You must substitute the disk in the example for the one you actually want to format. Typing the wrong disk by accident could destroy all your data forever.%0a%0a!! Creating a New Partition%0a%0aThe first task is to use fdisk to create fdisk partitions (Master Boot Record partitions). Now, the easy way is to run this one command:%0a%0a[@%0a$ doas fdisk -iy sd0%0a@]%0a%0aThis automatically creates an fdisk partition that spans the entire disk. That said, you can (and should!) learn how to edit this interactively, to fine tune your options.%0a%0a[@%0a$ doas fdisk -e sd0%0aEnter 'help' for information%0a@]%0a%0aType @@help@@ to get help, @@manual@@ to read the [[https://man.openbsd.org/fdisk|fdisk]] man page, and @@print@@ to view the partitions:%0a%0a[@%0asd0: 1> help%0a help Command help list%0a manual Show entire OpenBSD man page for fdisk%0a reinit Re-initialize loaded MBR (to defaults)%0a setpid Set the identifier of a given table entry%0a disk Edit current drive stats%0a edit Edit given table entry%0a flag Flag given table entry as bootable%0a update Update machine code in loaded MBR%0a select Select extended partition table entry MBR%0a swap Swap two partition entries%0a print Print loaded MBR partition table%0a write Write loaded MBR to disk%0a exit Exit edit of current MBR, without saving changes%0a quit Quit edit of current MBR, saving current changes%0a abort Abort program without saving current changes%0asd0: 1> print%0aDisk: sd0 geometry: 66837/255/63 [1073741824 Sectors]%0aOffset: 0 Signature: 0x0%0a Starting Ending LBA Info:%0a #: id C H S - C H S [ start: size ]%0a-------------------------------------------------------------------------------%0a 0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a 3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a@]%0a%0aThis disk sd0 is completely blank, so it is probably safe to edit the fdisk partitions and format the disk.%0a%0a'''WARNING''': If the disk already has existing partitions, double check to make sure you are not wiping out data!%0a%0aFirst, let's reinit. This should automatically create an fdisk partition on the last partition, partition 3, for OpenBSD and use all available space. It will also initialize this as the boot block.%0a%0a[@%0asd0: 1> reinit%0aDisk: sd0 geometry: 66837/255/63 [1073741824 Sectors]%0aOffset: 0 Signature: 0xAA55%0a Starting Ending LBA Info:%0a #: id C H S - C H S [ start: size ]%0a-------------------------------------------------------------------------------%0a 0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a*3: A6 0 1 2 - 66836 254 63 [ 64: 1073736341 ] OpenBSD %0aUse 'write' to update disk.%0a@]%0a%0aNotice that the Signature changes from 0x0 to 0xAA55, and partition #3 is now set to id A6 (the OpenBSD partition type).%0a%0aThis can also be done manually by using the edit command on partition 3:%0a%0a[@%0asd0: 1> edit 3%0a Starting Ending LBA Info:%0a #: id C H S - C H S [ start: size ]%0a-------------------------------------------------------------------------------%0a 3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0aPartition id ('0' to disable) [01 - FF]: [0] (? for help) A6%0aDo you wish to edit in CHS mode? [n] y%0aBIOS Starting cylinder [0 - 66836]: [0] %0aBIOS Starting head [0 - 254]: [1] %0aBIOS Starting sector [1 - 63]: [2] %0aBIOS Ending cylinder [0 - 66836]: [0] 66836%0aBIOS Ending head [0 - 254]: [0] 254%0aBIOS Ending sector [1 - 63]: [1] 63%0a@]%0a%0aWe need to edit in [[https://en.wikipedia.org/wiki/Cylinder-head-sector|Cylinder-Head-Sector]] ('''CHS''') mode. To use the full space of the disk, you will want to choose the lowest numbers in the range for the starting cylinder, head, and sector; and the highest possible numbers for the ending cylinder, head, and sector.%0a%0aWe now write to disk:%0a%0a[@%0asd0*: 1> write%0aWriting MBR at offset 0.%0a@]%0a%0aWe'll @@print G@@ to see everything in gigabytes:%0a%0a[@%0asd0: 1> print G%0aDisk: sd0 geometry: 66837/255/63 [1073741824 Sectors]%0aOffset: 0 Signature: 0xAA55%0a Starting Ending LBA Info:%0a #: id C H S - C H S [ start: size ]%0a-------------------------------------------------------------------------------%0a 0: 00 0 0 0 - 0 0 0 [ 0: 0G] unused %0a 1: 00 0 0 0 - 0 0 0 [ 0: 0G] unused %0a 2: 00 0 0 0 - 0 0 0 [ 0: 0G] unused %0a*3: A6 0 1 2 - 66836 254 63 [ 64: 512G] OpenBSD %0a@]%0a%0aIf everything looks good, %0a%0a[@%0asd0: 1> quit%0a@]%0a%0a!! Disklabel%0a%0aNext, we need to use [[https://man.openbsd.org/disklabel|disklabel]] to manage OpenBSD filesystem partitions (these disklabel partitions exist inside of an fdisk partition).%0a%0aWe should leave the first logical track unused, so the first partition should start at block 64.%0a%0aEach fdisk partition can be sliced into OpenBSD disklabel partitions with letters as labels. The @@a@@ partition is your root partition, @@b@@ is your swap, and @@c@@ is the entire disk.%0a%0aIf you already have the operating system installed on another disk (like we do here), you just need 1 single partition: the @@a@@ partition with the same size as the disk.%0a%0a[@%0a$ doas disklabel -E sd0%0aLabel editor (enter '?' for help at any prompt)%0asd0> ?%0aAvailable commands:%0a ? | h - show help n [part] - set mount point%0a A - auto partition all space p [unit] - print partitions%0a a [part] - add partition q - quit & save changes%0a b - set OpenBSD boundaries R [part] - resize auto allocated partition%0a c [part] - change partition size r - display free space%0a D - reset label to default s [path] - save label to file%0a d [part] - delete partition U - undo all changes%0a e - edit drive parameters u - undo last change%0a g [d|u] - [d]isk or [u]ser geometry w - write label to disk%0a i - modify disklabel UID X - toggle expert mode%0a l [unit] - print disk label header x - exit & lose changes%0a M - disklabel(8) man page z - delete all partitions%0a m [part] - modify partition%0a%0aSuffixes can be used to indicate units other than sectors:%0a 'b' (bytes), 'k' (kilobytes), 'm' (megabytes), 'g' (gigabytes) 't' (terabytes)%0a 'c' (cylinders), '%25' (%25 of total disk), '&' (%25 of free space).%0aValues in non-sector units are truncated to the nearest cylinder boundary.%0a@]%0a%0aTo print the partitions in gigabytes:%0a%0a[@%0asd0> p G%0aOpenBSD area: 64-1073736405; size: 512.0G; free: 512.0G%0a# size offset fstype [fsize bsize cpg]%0a c: 512.0G 0 unused %0a@]%0a%0aWe want to add the @@a@@ partition. We'll use defaults for offset, size, and FS type:%0a%0a[@%0asd0> a a%0aoffset: [64] %0asize: [1073736341] %0aFS type: [4.2BSD] %0asd0*> p G%0aOpenBSD area: 64-1073736405; size: 512.0G; free: 0.0G%0a# size offset fstype [fsize bsize cpg]%0a a: 512.0G 64 4.2BSD 4096 32768 1 %0a c: 512.0G 0 unused %0a@]%0a%0aThen write the changes to disk and quit:%0a%0a[@%0asd0*> w%0asd0> q%0aNo label changes.%0a@]%0a%0aNext, you'll want to format the disk:%0a%0a[@%0a$ doas newfs sd0a%0a/dev/rsd0a: 524285.3MB in 1073736320 sectors of 512 bytes %0a644 cylinder groups of 814.44MB, 26062 blocks, 52224 inodes each %0asuper-block backups (for fsck -b #) at: %0a...%0a@]%0a%0aWe now have sd0a formatted, but we need to mount it. Let's look at where our system's partitions are currently mounted:%0a%0a[@%0a$ mount %0a/dev/sd1a on / type ffs (local)%0a/dev/sd1k on /home type ffs (local, nodev, nosuid)%0a/dev/sd1d on /tmp type ffs (local, nodev, nosuid)%0a/dev/sd1f on /usr type ffs (local, nodev)%0a/dev/sd1g on /usr/X11R6 type ffs (local, nodev)%0a/dev/sd1h on /usr/local type ffs (local, nodev, wxallowed)%0a/dev/sd1j on /usr/obj type ffs (local, nodev, nosuid)%0a/dev/sd1i on /usr/src type ffs (local, nodev, nosuid)%0a/dev/sd1e on /var type ffs (local, nodev, nosuid)%0a@]%0a%0aWe can also see the size of these partitions:%0a%0a[@%0a$ df -h %0aFilesystem Size Used Avail Capacity Mounted on%0a/dev/sd1a 615M 232M 352M 40%25 /%0a/dev/sd1k 3.7G 2.1G 1.4G 59%25 /home%0a/dev/sd1d 863M 28.0K 820M 0%25 /tmp%0a/dev/sd1f 2.3G 1.6G 600M 74%25 /usr%0a/dev/sd1g 648M 238M 378M 39%25 /usr/X11R6%0a/dev/sd1h 2.3G 2.2G 50.2M 98%25 /usr/local%0a/dev/sd1j 5.2G 2.0K 4.9G 0%25 /usr/obj%0a/dev/sd1i 1.4G 2.0K 1.3G 0%25 /usr/src%0a/dev/sd1e 1.3G 318M 913M 26%25 /var%0a@]%0a%0aFor this example, /home is too small for our server, so we're going to copy all the data from sd1k to sd0, then mount sd0a as the new /home.%0a%0a[@%0a$ doas su%0a# mount /dev/sd0a /mnt%0a# cd /mnt%0a@]%0a%0aThen we [[openbsd/dump|dump]] and [[openbsd/restore|restore]] to clone the partition:%0a%0a[@%0a# dump -0 -a -f - /home | restore -rf -%0a@]%0a%0aYou will want to replace /home with whatever partition you want to back up on the new disk.%0a%0aAlternatively, you can copy the files manually by running:%0a%0a[@%0a# cp -R /home/* /home/.* /mnt/%0a@]%0a%0aInspect the files in the partition to make sure they copied successfully:%0a%0a[@%0a# ls -a /mnt/%0a@]%0a%0aThen unmount the partition:%0a%0a[@%0a# umount /mnt/%0a# ^D%0a@]%0a%0a(Type ctrl+d or ^D to exit)%0a%0aThe next steps will take the system offline, so before performing any more steps, you will want to [[openbsd/announce|announce]] to your users and teammates that they should save all files and prepare for downtime.%0a%0aNow we need to automatically mount this partition at bootup. Let's take a look at the current [[https://man.openbsd.org/fstab|/etc/fstab]]:%0a%0a[@%0a37deb3c1c30cbfbf.b none swap sw%0a37deb3c1c30cbfbf.a / ffs rw 1 1%0a37deb3c1c30cbfbf.k /home ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.d /tmp ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.f /usr ffs rw,nodev 1 2%0a37deb3c1c30cbfbf.g /usr/X11R6 ffs rw,nodev 1 2%0a37deb3c1c30cbfbf.h /usr/local ffs rw,wxallowed,nodev 1 2%0a37deb3c1c30cbfbf.j /usr/obj ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.i /usr/src ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.e /var ffs rw,nodev,nosuid 1 2%0a@]%0a%0aThe string @@37deb3c1c30cbfbf@@ is called the disklabel unique identifier ('''DUID'''). Each disk partition has its own unique DUID. Let's find the DUID of our new disk partition:%0a%0a[@%0a$ sysctl hw.disknames %0ahw.disknames=cd0:,sd0:f433d9e11879420f,sd1:37deb3c1c30cbfbf,fd0:%0a@]%0a%0aThe DUID for sd0 is f433d9e11879420f. So, we need to replace /home's partition 37deb3c1c30cbfbf.k with f433d9e11879420f.a (since we are trying to mount sd0a):%0a%0a[@%0a37deb3c1c30cbfbf.b none swap sw%0a37deb3c1c30cbfbf.a / ffs rw 1 1%0af433d9e11879420f.a /home ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.d /tmp ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.f /usr ffs rw,nodev 1 2%0a37deb3c1c30cbfbf.g /usr/X11R6 ffs rw,nodev 1 2%0a37deb3c1c30cbfbf.h /usr/local ffs rw,wxallowed,nodev 1 2%0a37deb3c1c30cbfbf.j /usr/obj ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.i /usr/src ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.e /var ffs rw,nodev,nosuid 1 2%0a@]%0a%0aThen, reboot:%0a%0a[@%0a$ doas shutdown -r now%0a@]%0a%0aIf everything was done correctly, the system should automatically mount sd0a as /home upon bootup. The old partition, /dev/sd1k, can still be mounted if you need it:%0a%0a[@%0a$ doas mount /dev/sd1k /mnt/%0a@]%0a%0aDouble check to make sure the files on /home exactly match those on /mnt from sd1k. If they do not, you will need to clone the disk again using [[openbsd/dump|dump]]/[[openbsd/restore|restore]] or cp.%0a%0aOnce you are certain the files have been copied properly, you can use unmount the partition:%0a%0a[@%0a$ doas umount /mnt%0a@]%0a%0aThen you can clear out the free space to [[openbsd/growpartition|grow an existing partition]] or you can create a new partition with it and mount it elsewhere.%0a%0a!! Troubleshooting:%0a%0a!!! Uh oh, my system won't reboot!%0a%0aThis can happen if you foul up [[https://man.openbsd.org/fstab|/etc/fstab]]. For example, suppose I had made this error in /etc/fstab:%0a%0a[@%0a37deb3c1c30cbfbf.b none swap sw%0a37deb3c1c30cbfbf.a / ffs rw 1 1%0af433d9e11879420f.b /home ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.d /tmp ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.f /usr ffs rw,nodev 1 2%0a37deb3c1c30cbfbf.g /usr/X11R6 ffs rw,nodev 1 2%0a37deb3c1c30cbfbf.h /usr/local ffs rw,wxallowed,nodev 1 2%0a37deb3c1c30cbfbf.j /usr/obj ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.i /usr/src ffs rw,nodev,nosuid 1 2%0a37deb3c1c30cbfbf.e /var ffs rw,nodev,nosuid 1 2%0a@]%0a%0aFor the third line, instead of putting .a, I put .b by accident. When I reboot the system by running @@doas shutdown -r now@@, I can no longer ssh into the system. When I log in via serial console (cu for [[openbsd/vmmuser|vmm]] or VNC for [[openbsd/Buyvm|BuyVM]])%0a%0a[@%0aroot on sd0a (a0e97b069eed0743.a) swap on sd0b dump on sd0b%0aAutomatic boot in progress: starting file system checks.%0a/dev/sd0a (a0e97b069eed0743.a): file system is clean; not checking%0aCan't open d40a0cfcd4551ac7.b: No such file or directory%0aCAN'T CHECK FILE SYSTEM.%0ad40a0cfcd4551ac7.b: UNEXPECTED INCONSISTENCY; RUN fsck_ffs MANUALLY.%0a/dev/sd0k (a0e97b069eed0743.k): file system is clean; not checking%0a/dev/sd0d (a0e97b069eed0743.d): file system is clean; not checking%0a/dev/sd0f (a0e97b069eed0743.f): file system is clean; not checking%0a/dev/sd0g (a0e97b069eed0743.g): file system is clean; not checking%0a/dev/sd0h (a0e97b069eed0743.h): file system is clean; not checking%0a/dev/sd0j (a0e97b069eed0743.j): file system is clean; not checking%0a/dev/sd0i (a0e97b069eed0743.i): file system is clean; not checking%0a/dev/sd0e (a0e97b069eed0743.e): file system is clean; not checking%0aTHE FOLLOWING FILE SYSTEM HAD AN UNEXPECTED INCONSISTENCY:%0a ffs: d40a0cfcd4551ac7.b (/home)%0aAutomatic file system check failed; help!%0aEnter pathname of shell or RETURN for sh: %0a@]%0a%0aIn order to boot up, you'll need to fix fstab. So, press the enter key to enter into the shell. Then, to view your /etc/fstab, type:%0a%0a[@%0a# cat /etc/fstab%0a@]%0a%0aCheck how your partitions are mounted:%0a%0a[@%0a# mount%0aroot_device on / type ffs (local, read-only)%0a@]%0a%0aYou'll notice that only / is mounted (so you can't use programs from /usr or view files in /home). This means you'll lack basic utilities like less and text editors like vi and mg. You'll also be unable to edit and save /etc/fstab, since / is mounted read-only. So first, let's fix that.%0a%0a[@%0a# mount -rw /%0a# mount -rw /dev/sd0f /usr%0a@]%0a%0aOur fstab says a0e97b069eed0743.f is used for /usr so we mount /dev/sd0f to /usr. %0aAlso, [@ TERM=vt220 @] will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a%0a[@%0a# export TERM=vt220%0a# vi /etc/fstab%0a@]%0a%0aReplace f433d9e11879420f.b with f433d9e11879420f.a, save and quit, then reboot the system:%0a%0a[@%0a# shutdown -r now%0a@]
015
2021-12-17
diff:1624980202:1624606581:=411,412c411,412%0a%3c Also, [@ TERM=vt220 @] will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a%3c %0a---%0a> Also, [@ TERM=xterm @] will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a> %0a414c414%0a%3c # export TERM=vt220%0a---%0a> # export TERM=xterm%0a
018
2021-12-17
diff:1624606581:1609820273:minor=410,411c410%0a%3c Our fstab says a0e97b069eed0743.f is used for /usr so we mount /dev/sd0f to /usr. %0a%3c Also, [@ TERM=xterm @] will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a---%0a> Our fstab says a0e97b069eed0743.f is used for /usr so we mount /dev/sd0f to /usr. This will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a
021
2021-12-17
diff:1609820273:1609820059:=410,421c410%0a%3c Our fstab says a0e97b069eed0743.f is used for /usr so we mount /dev/sd0f to /usr. This will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a%3c %0a%3c [@%0a%3c # export TERM=xterm%0a%3c # vi /etc/fstab%0a%3c @]%0a%3c %0a%3c Replace f433d9e11879420f.b with f433d9e11879420f.a, save and quit, then reboot the system:%0a%3c %0a%3c [@%0a%3c # shutdown -r now%0a%3c @]%0a\ No newline at end of file%0a---%0a> Our fstab says a0e97b069eed0743.f is used for /usr so we mount /dev/sd0f to /usr. This will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a\ No newline at end of file%0a
024
2021-12-17
diff:1609820059:1609819903:=403,404c403,404%0a%3c You'll notice that only / is mounted (so you can't use programs from /usr or view files in /home). This means you'll lack basic utilities like less and text editors like vi and mg. You'll also be unable to edit and save /etc/fstab, since / is mounted read-only. So first, let's fix that.%0a%3c %0a---%0a> You'll notice that only / is mounted (so you can't use programs from /usr or view files in /home). This means you'll lack basic utilities like less and text editors like vi and mg. You'll also be unable to edit and save /etc/fstab, since / is mounted read-only. So first, let's fix that:%0a> %0a407d406%0a%3c # mount -rw /dev/sd0f /usr%0a410c409,410%0a%3c Our fstab says a0e97b069eed0743.f is used for /usr so we mount /dev/sd0f to /usr. This will allow us to use text editors like vi to edit (you could, of course, use [[openbsd/ed|ed]]).%0a\ No newline at end of file%0a---%0a> %0a> Unfortunately, you're being forced to boot in single user mode, which lacks normal utilities like vi and emacs.%0a\ No newline at end of file%0a
027
2021-12-17
diff:1609819903:1609819299:=390,408c390%0a%3c In order to boot up, you'll need to fix fstab. So, press the enter key to enter into the shell. Then, to view your /etc/fstab, type:%0a%3c %0a%3c [@%0a%3c # cat /etc/fstab%0a%3c @]%0a%3c %0a%3c Check how your partitions are mounted:%0a%3c %0a%3c [@%0a%3c # mount%0a%3c root_device on / type ffs (local, read-only)%0a%3c @]%0a%3c %0a%3c You'll notice that only / is mounted (so you can't use programs from /usr or view files in /home). This means you'll lack basic utilities like less and text editors like vi and mg. You'll also be unable to edit and save /etc/fstab, since / is mounted read-only. So first, let's fix that:%0a%3c %0a%3c [@%0a%3c # mount -rw /%0a%3c @]%0a%3c %0a---%0a> In order to boot up, you'll need to fix fstab.%0a
030
2021-12-17
diff:1609819299:1609816235:=352,353c352,353%0a%3c This can happen if you foul up [[https://man.openbsd.org/fstab|/etc/fstab]]. For example, suppose I had made this error in /etc/fstab:%0a%3c %0a---%0a> This can happen if you foul up [[https://man.openbsd.org/fstab|/etc/fstab]]. For example, suppose I had put this in /etc/fstab:%0a> %0a367,392c367%0a%3c For the third line, instead of putting .a, I put .b by accident. When I reboot the system by running @@doas shutdown -r now@@, I can no longer ssh into the system. When I log in via serial console (cu for [[openbsd/vmmuser|vmm]] or VNC for [[openbsd/Buyvm|BuyVM]])%0a%3c %0a%3c [@%0a%3c root on sd0a (a0e97b069eed0743.a) swap on sd0b dump on sd0b%0a%3c Automatic boot in progress: starting file system checks.%0a%3c /dev/sd0a (a0e97b069eed0743.a): file system is clean; not checking%0a%3c Can't open d40a0cfcd4551ac7.b: No such file or directory%0a%3c CAN'T CHECK FILE SYSTEM.%0a%3c d40a0cfcd4551ac7.b: UNEXPECTED INCONSISTENCY; RUN fsck_ffs MANUALLY.%0a%3c /dev/sd0k (a0e97b069eed0743.k): file system is clean; not checking%0a%3c /dev/sd0d (a0e97b069eed0743.d): file system is clean; not checking%0a%3c /dev/sd0f (a0e97b069eed0743.f): file system is clean; not checking%0a%3c /dev/sd0g (a0e97b069eed0743.g): file system is clean; not checking%0a%3c /dev/sd0h (a0e97b069eed0743.h): file system is clean; not checking%0a%3c /dev/sd0j (a0e97b069eed0743.j): file system is clean; not checking%0a%3c /dev/sd0i (a0e97b069eed0743.i): file system is clean; not checking%0a%3c /dev/sd0e (a0e97b069eed0743.e): file system is clean; not checking%0a%3c THE FOLLOWING FILE SYSTEM HAD AN UNEXPECTED INCONSISTENCY:%0a%3c ffs: d40a0cfcd4551ac7.b (/home)%0a%3c Automatic file system check failed; help!%0a%3c Enter pathname of shell or RETURN for sh: %0a%3c @]%0a%3c %0a%3c In order to boot up, you'll need to fix fstab.%0a%3c %0a%3c Unfortunately, you're being forced to boot in single user mode, which lacks normal utilities like vi and emacs.%0a\ No newline at end of file%0a---%0a> For the third line, instead of putting .a, I put .b by accident.%0a\ No newline at end of file%0a
033
2021-12-17
diff:1609816235:1609815144:=346,367c346%0a%3c Then you can clear out the free space to [[openbsd/growpartition|grow an existing partition]] or you can create a new partition with it and mount it elsewhere.%0a%3c %0a%3c !! Troubleshooting:%0a%3c %0a%3c !!! Uh oh, my system won't reboot!%0a%3c %0a%3c This can happen if you foul up [[https://man.openbsd.org/fstab|/etc/fstab]]. For example, suppose I had put this in /etc/fstab:%0a%3c %0a%3c [@%0a%3c 37deb3c1c30cbfbf.b none swap sw%0a%3c 37deb3c1c30cbfbf.a / ffs rw 1 1%0a%3c f433d9e11879420f.b /home ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.d /tmp ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.f /usr ffs rw,nodev 1 2%0a%3c 37deb3c1c30cbfbf.g /usr/X11R6 ffs rw,nodev 1 2%0a%3c 37deb3c1c30cbfbf.h /usr/local ffs rw,wxallowed,nodev 1 2%0a%3c 37deb3c1c30cbfbf.j /usr/obj ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.i /usr/src ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.e /var ffs rw,nodev,nosuid 1 2%0a%3c @]%0a%3c %0a%3c For the third line, instead of putting .a, I put .b by accident.%0a\ No newline at end of file%0a---%0a> Then you can clear out the free space to [[openbsd/growpartition|grow an existing partition]] or you can create a new partition with it and mount it elsewhere.%0a\ No newline at end of file%0a
036
2021-12-17
diff:1609815144:1609814801:=332,346c332%0a%3c If everything was done correctly, the system should automatically mount sd0a as /home upon bootup. The old partition, /dev/sd1k, can still be mounted if you need it:%0a%3c %0a%3c [@%0a%3c $ doas mount /dev/sd1k /mnt/%0a%3c @]%0a%3c %0a%3c Double check to make sure the files on /home exactly match those on /mnt from sd1k. If they do not, you will need to clone the disk again using [[openbsd/dump|dump]]/[[openbsd/restore|restore]] or cp.%0a%3c %0a%3c Once you are certain the files have been copied properly, you can use unmount the partition:%0a%3c %0a%3c [@%0a%3c $ doas umount /mnt%0a%3c @]%0a%3c %0a%3c Then you can clear out the free space to [[openbsd/growpartition|grow an existing partition]] or you can create a new partition with it and mount it elsewhere.%0a\ No newline at end of file%0a---%0a> If everything was done correctly, the system should automatically mount sd0a as /home upon bootup.%0a\ No newline at end of file%0a
039
2021-12-17
diff:1609814801:1609814743:=287a288,294%0a> %0a> You'll want to list the files to verify that everything has been copied correctly:%0a> %0a> [@%0a> $ doas ls /mnt/home/%0a> ...%0a> @]%0a
045
2021-12-17
diff:1609814690:1609814559:=258,259c258,259%0a%3c Then we [[openbsd/dump|dump]] and [[openbsd/restore|restore]] to clone the partition:%0a%3c %0a---%0a> Then we dump and restore to clone the partition:%0a> %0a285a286,293%0a> %0a> %0a> %0a> [@%0a> $ doas mount /dev/sd0a /mnt%0a> $ doas cp -R /home/ /mnt/%0a> $ doas umount /mnt/%0a> @]%0a
048
2021-12-17
diff:1609814559:1609814252:=255a256,258%0a> # dump -0 -a -f - / | restore -rf -%0a> # umount /mnt/%0a> # ^D%0a258,287c261,264%0a%3c Then we dump and restore to clone the partition:%0a%3c %0a%3c [@%0a%3c # dump -0 -a -f - /home | restore -rf -%0a%3c @]%0a%3c %0a%3c You will want to replace /home with whatever partition you want to back up on the new disk.%0a%3c %0a%3c Alternatively, you can copy the files manually by running:%0a%3c %0a%3c [@%0a%3c # cp -R /home/* /home/.* /mnt/%0a%3c @]%0a%3c %0a%3c Inspect the files in the partition to make sure they copied successfully:%0a%3c %0a%3c [@%0a%3c # ls -a /mnt/%0a%3c @]%0a%3c %0a%3c Then unmount the partition:%0a%3c %0a%3c [@%0a%3c # umount /mnt/%0a%3c # ^D%0a%3c @]%0a%3c %0a%3c (Type ctrl+d or ^D to exit)%0a%3c %0a%3c %0a---%0a> (Type ctrl+d or ^D to exit)%0a> %0a> Alternatively, you can copy the files simply by running:%0a> %0a
054
2021-12-17
diff:1609814226:1609770565:=251,262d250%0a%3c %0a%3c [@%0a%3c $ doas su%0a%3c # mount /dev/sd0a /mnt%0a%3c # dump -0 -a -f - / | restore -rf -%0a%3c # umount /mnt/%0a%3c # ^D%0a%3c @]%0a%3c %0a%3c (Type ctrl+d or ^D to exit)%0a%3c %0a%3c Alternatively, you can copy the files simply by running:%0a
057
2021-12-17
diff:1609770565:1609682122:=250c250%0a%3c For this example, /home is too small for our server, so we're going to copy all the data from sd1k to sd0, then mount sd0a as the new /home.%0a---%0a> /home is too small for our server, so we're going to copy all the data from sd1k to sd0, then mount sd0a as the new /home.%0a
063
2021-12-17
diff:1609681990:1609680663:=19c19%0a%3c In this example, our server has two SCSI-like disks (a BuyVM slab and a VirtIO block device). In this case, the VirtIO block device is the hard disk the operating system is installed on, and the slab is extra storage we purchased. The disks are numbered by the order in which they are detected at boot time. The first SCSI-like disk will be sd0, the second sd1, and so forth.%0a---%0a> In this example, our server has two SCSI-like disks (a BuyVM slab and a VirtIO block device). In this case, the VirtIO block device is the hard disk the operating system is installed on, and the slab is extra storage we purchased. The disks are numbered by the ordered in which they are detected at boot time. The first SCSI-like disk will be sd0, the second sd1, and so forth.%0a
066
2021-12-17
diff:1609680663:1609679838:=259,311c259%0a%3c The next steps will take the system offline, so before performing any more steps, you will want to [[openbsd/announce|announce]] to your users and teammates that they should save all files and prepare for downtime.%0a%3c %0a%3c You'll want to list the files to verify that everything has been copied correctly:%0a%3c %0a%3c [@%0a%3c $ doas ls /mnt/home/%0a%3c ...%0a%3c @]%0a%3c %0a%3c Now we need to automatically mount this partition at bootup. Let's take a look at the current [[https://man.openbsd.org/fstab|/etc/fstab]]:%0a%3c %0a%3c [@%0a%3c 37deb3c1c30cbfbf.b none swap sw%0a%3c 37deb3c1c30cbfbf.a / ffs rw 1 1%0a%3c 37deb3c1c30cbfbf.k /home ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.d /tmp ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.f /usr ffs rw,nodev 1 2%0a%3c 37deb3c1c30cbfbf.g /usr/X11R6 ffs rw,nodev 1 2%0a%3c 37deb3c1c30cbfbf.h /usr/local ffs rw,wxallowed,nodev 1 2%0a%3c 37deb3c1c30cbfbf.j /usr/obj ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.i /usr/src ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.e /var ffs rw,nodev,nosuid 1 2%0a%3c @]%0a%3c %0a%3c The string @@37deb3c1c30cbfbf@@ is called the disklabel unique identifier ('''DUID'''). Each disk partition has its own unique DUID. Let's find the DUID of our new disk partition:%0a%3c %0a%3c [@%0a%3c $ sysctl hw.disknames %0a%3c hw.disknames=cd0:,sd0:f433d9e11879420f,sd1:37deb3c1c30cbfbf,fd0:%0a%3c @]%0a%3c %0a%3c The DUID for sd0 is f433d9e11879420f. So, we need to replace /home's partition 37deb3c1c30cbfbf.k with f433d9e11879420f.a (since we are trying to mount sd0a):%0a%3c %0a%3c [@%0a%3c 37deb3c1c30cbfbf.b none swap sw%0a%3c 37deb3c1c30cbfbf.a / ffs rw 1 1%0a%3c f433d9e11879420f.a /home ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.d /tmp ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.f /usr ffs rw,nodev 1 2%0a%3c 37deb3c1c30cbfbf.g /usr/X11R6 ffs rw,nodev 1 2%0a%3c 37deb3c1c30cbfbf.h /usr/local ffs rw,wxallowed,nodev 1 2%0a%3c 37deb3c1c30cbfbf.j /usr/obj ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.i /usr/src ffs rw,nodev,nosuid 1 2%0a%3c 37deb3c1c30cbfbf.e /var ffs rw,nodev,nosuid 1 2%0a%3c @]%0a%3c %0a%3c Then, reboot:%0a%3c %0a%3c [@%0a%3c $ doas shutdown -r now%0a%3c @]%0a%3c %0a%3c If everything was done correctly, the system should automatically mount sd0a as /home upon bootup.%0a\ No newline at end of file%0a---%0a> The next steps will take the system offline, so before performing the upgrades, you will want to [[openbsd/announce|announce]] the changes to your users and teammates.%0a\ No newline at end of file%0a
069
2021-12-17
diff:1609679838:1609678850:=7,8d6%0a%3c '''NOTE''': Before performing the upgrades, you will want to [[openbsd/announce|announce]] the changes to your users and teammates.%0a%3c %0a259c257%0a%3c The next steps will take the system offline, so before performing the upgrades, you will want to [[openbsd/announce|announce]] the changes to your users and teammates.%0a\ No newline at end of file%0a---%0a> [[openbsd/announce|announce]]%0a
072
2021-12-17
diff:1609678850:1609678804:=254,257c254%0a%3c $ doas umount /mnt/%0a%3c @]%0a%3c %0a%3c [[openbsd/announce|announce]]%0a---%0a> @]%0a\ No newline at end of file%0a
075
2021-12-17
diff:1609678804:1609677726:=210,254c210,211%0a%3c [@%0a%3c $ doas newfs sd0a%0a%3c /dev/rsd0a: 524285.3MB in 1073736320 sectors of 512 bytes %0a%3c 644 cylinder groups of 814.44MB, 26062 blocks, 52224 inodes each %0a%3c super-block backups (for fsck -b #) at: %0a%3c ...%0a%3c @]%0a%3c %0a%3c We now have sd0a formatted, but we need to mount it. Let's look at where our system's partitions are currently mounted:%0a%3c %0a%3c [@%0a%3c $ mount %0a%3c /dev/sd1a on / type ffs (local)%0a%3c /dev/sd1k on /home type ffs (local, nodev, nosuid)%0a%3c /dev/sd1d on /tmp type ffs (local, nodev, nosuid)%0a%3c /dev/sd1f on /usr type ffs (local, nodev)%0a%3c /dev/sd1g on /usr/X11R6 type ffs (local, nodev)%0a%3c /dev/sd1h on /usr/local type ffs (local, nodev, wxallowed)%0a%3c /dev/sd1j on /usr/obj type ffs (local, nodev, nosuid)%0a%3c /dev/sd1i on /usr/src type ffs (local, nodev, nosuid)%0a%3c /dev/sd1e on /var type ffs (local, nodev, nosuid)%0a%3c @]%0a%3c %0a%3c We can also see the size of these partitions:%0a%3c %0a%3c [@%0a%3c $ df -h %0a%3c Filesystem Size Used Avail Capacity Mounted on%0a%3c /dev/sd1a 615M 232M 352M 40%25 /%0a%3c /dev/sd1k 3.7G 2.1G 1.4G 59%25 /home%0a%3c /dev/sd1d 863M 28.0K 820M 0%25 /tmp%0a%3c /dev/sd1f 2.3G 1.6G 600M 74%25 /usr%0a%3c /dev/sd1g 648M 238M 378M 39%25 /usr/X11R6%0a%3c /dev/sd1h 2.3G 2.2G 50.2M 98%25 /usr/local%0a%3c /dev/sd1j 5.2G 2.0K 4.9G 0%25 /usr/obj%0a%3c /dev/sd1i 1.4G 2.0K 1.3G 0%25 /usr/src%0a%3c /dev/sd1e 1.3G 318M 913M 26%25 /var%0a%3c @]%0a%3c %0a%3c /home is too small for our server, so we're going to copy all the data from sd1k to sd0, then mount sd0a as the new /home.%0a%3c %0a%3c [@%0a%3c $ doas mount /dev/sd0a /mnt%0a%3c $ doas cp -R /home/ /mnt/%0a%3c @]%0a\ No newline at end of file%0a---%0a> # newfs /dev/rsd0g%0a> # mount /dev/sd0g /mnt%0a
078
2021-12-17
diff:1609677726:1609677551:=186,209c186,188%0a%3c We want to add the @@a@@ partition. We'll use defaults for offset, size, and FS type:%0a%3c %0a%3c [@%0a%3c sd0> a a%0a%3c offset: [64] %0a%3c size: [1073736341] %0a%3c FS type: [4.2BSD] %0a%3c sd0*> p G%0a%3c OpenBSD area: 64-1073736405; size: 512.0G; free: 0.0G%0a%3c # size offset fstype [fsize bsize cpg]%0a%3c a: 512.0G 64 4.2BSD 4096 32768 1 %0a%3c c: 512.0G 0 unused %0a%3c @]%0a%3c %0a%3c Then write the changes to disk and quit:%0a%3c %0a%3c [@%0a%3c sd0*> w%0a%3c sd0> q%0a%3c No label changes.%0a%3c @]%0a%3c %0a%3c Next, you'll want to format the disk:%0a%3c %0a---%0a> We want to add a partition%0a> %0a> # disklabel%0a
081
2021-12-17
diff:1609677551:1609677157:=151,186d150%0a%3c %0a%3c [@%0a%3c $ doas disklabel -E sd0%0a%3c Label editor (enter '?' for help at any prompt)%0a%3c sd0> ?%0a%3c Available commands:%0a%3c ? | h - show help n [part] - set mount point%0a%3c A - auto partition all space p [unit] - print partitions%0a%3c a [part] - add partition q - quit & save changes%0a%3c b - set OpenBSD boundaries R [part] - resize auto allocated partition%0a%3c c [part] - change partition size r - display free space%0a%3c D - reset label to default s [path] - save label to file%0a%3c d [part] - delete partition U - undo all changes%0a%3c e - edit drive parameters u - undo last change%0a%3c g [d|u] - [d]isk or [u]ser geometry w - write label to disk%0a%3c i - modify disklabel UID X - toggle expert mode%0a%3c l [unit] - print disk label header x - exit & lose changes%0a%3c M - disklabel(8) man page z - delete all partitions%0a%3c m [part] - modify partition%0a%3c %0a%3c Suffixes can be used to indicate units other than sectors:%0a%3c 'b' (bytes), 'k' (kilobytes), 'm' (megabytes), 'g' (gigabytes) 't' (terabytes)%0a%3c 'c' (cylinders), '%25' (%25 of total disk), '&' (%25 of free space).%0a%3c Values in non-sector units are truncated to the nearest cylinder boundary.%0a%3c @]%0a%3c %0a%3c To print the partitions in gigabytes:%0a%3c %0a%3c [@%0a%3c sd0> p G%0a%3c OpenBSD area: 64-1073736405; size: 512.0G; free: 512.0G%0a%3c # size offset fstype [fsize bsize cpg]%0a%3c c: 512.0G 0 unused %0a%3c @]%0a%3c %0a%3c We want to add a partition%0a
084
2021-12-17
diff:1609677157:1609656989:=148,150c148%0a%3c Each fdisk partition can be sliced into OpenBSD disklabel partitions with letters as labels. The @@a@@ partition is your root partition, @@b@@ is your swap, and @@c@@ is the entire disk.%0a%3c %0a%3c If you already have the operating system installed on another disk (like we do here), you just need 1 single partition: the @@a@@ partition with the same size as the disk.%0a---%0a> %0a
087
2021-12-17
diff:1609656989:1609656753:=143,148d142%0a%3c %0a%3c Next, we need to use [[https://man.openbsd.org/disklabel|disklabel]] to manage OpenBSD filesystem partitions (these disklabel partitions exist inside of an fdisk partition).%0a%3c %0a%3c We should leave the first logical track unused, so the first partition should start at block 64.%0a%3c %0a%3c %0a
090
2021-12-17
diff:1609656753:1609656511:=27,33c27,28%0a%3c The first task is to use fdisk to create fdisk partitions (Master Boot Record partitions). Now, the easy way is to run this one command:%0a%3c %0a%3c [@%0a%3c $ doas fdisk -iy sd0%0a%3c @]%0a%3c %0a%3c This automatically creates an fdisk partition that spans the entire disk. That said, you can (and should!) learn how to edit this interactively, to fine tune your options.%0a---%0a> The first task is to use fdisk to create fdisk partitions (Master Boot Record partitions).%0a> %0a
093
2021-12-17
diff:1609656511:1609655206:=66,71c66,68%0a%3c This disk sd0 is completely blank, so it is probably safe to edit the fdisk partitions and format the disk.%0a%3c %0a%3c '''WARNING''': If the disk already has existing partitions, double check to make sure you are not wiping out data!%0a%3c %0a%3c First, let's reinit. This should automatically create an fdisk partition on the last partition, partition 3, for OpenBSD and use all available space. It will also initialize this as the boot block.%0a%3c %0a---%0a> This disk sd0 is completely blank.%0a> %0a> %0a73,137c70%0a%3c sd0: 1> reinit%0a%3c Disk: sd0 geometry: 66837/255/63 [1073741824 Sectors]%0a%3c Offset: 0 Signature: 0xAA55%0a%3c Starting Ending LBA Info:%0a%3c #: id C H S - C H S [ start: size ]%0a%3c -------------------------------------------------------------------------------%0a%3c 0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c *3: A6 0 1 2 - 66836 254 63 [ 64: 1073736341 ] OpenBSD %0a%3c Use 'write' to update disk.%0a%3c @]%0a%3c %0a%3c Notice that the Signature changes from 0x0 to 0xAA55, and partition #3 is now set to id A6 (the OpenBSD partition type).%0a%3c %0a%3c This can also be done manually by using the edit command on partition 3:%0a%3c %0a%3c [@%0a%3c sd0: 1> edit 3%0a%3c Starting Ending LBA Info:%0a%3c #: id C H S - C H S [ start: size ]%0a%3c -------------------------------------------------------------------------------%0a%3c 3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c Partition id ('0' to disable) [01 - FF]: [0] (? for help) A6%0a%3c Do you wish to edit in CHS mode? [n] y%0a%3c BIOS Starting cylinder [0 - 66836]: [0] %0a%3c BIOS Starting head [0 - 254]: [1] %0a%3c BIOS Starting sector [1 - 63]: [2] %0a%3c BIOS Ending cylinder [0 - 66836]: [0] 66836%0a%3c BIOS Ending head [0 - 254]: [0] 254%0a%3c BIOS Ending sector [1 - 63]: [1] 63%0a%3c @]%0a%3c %0a%3c We need to edit in [[https://en.wikipedia.org/wiki/Cylinder-head-sector|Cylinder-Head-Sector]] ('''CHS''') mode. To use the full space of the disk, you will want to choose the lowest numbers in the range for the starting cylinder, head, and sector; and the highest possible numbers for the ending cylinder, head, and sector.%0a%3c %0a%3c We now write to disk:%0a%3c %0a%3c [@%0a%3c sd0*: 1> write%0a%3c Writing MBR at offset 0.%0a%3c @]%0a%3c %0a%3c We'll @@print G@@ to see everything in gigabytes:%0a%3c %0a%3c [@%0a%3c sd0: 1> print G%0a%3c Disk: sd0 geometry: 66837/255/63 [1073741824 Sectors]%0a%3c Offset: 0 Signature: 0xAA55%0a%3c Starting Ending LBA Info:%0a%3c #: id C H S - C H S [ start: size ]%0a%3c -------------------------------------------------------------------------------%0a%3c 0: 00 0 0 0 - 0 0 0 [ 0: 0G] unused %0a%3c 1: 00 0 0 0 - 0 0 0 [ 0: 0G] unused %0a%3c 2: 00 0 0 0 - 0 0 0 [ 0: 0G] unused %0a%3c *3: A6 0 1 2 - 66836 254 63 [ 64: 512G] OpenBSD %0a%3c @]%0a%3c %0a%3c If everything looks good, %0a%3c %0a%3c [@%0a%3c sd0: 1> quit%0a%3c @]%0a%3c %0a%3c !! Disklabel%0a%3c %0a---%0a> # fdisk%0a
096
2021-12-17
diff:1609655206:1609655144:=63a64%0a> %0a66c67%0a%3c This disk sd0 is completely blank.%0a---%0a> First, let's print%0a
099
2021-12-17
diff:1609655144:1609654883:=11c11%0a%3c sd0 at scsibus2 targ 0 lun 0: %3cBUYVM, SLAB, 2.5+> serial.BUYVM_SLAB_VOLUME-4047%0a---%0a> sd0 at scsibus2 targ 0 lun 0: %3cBUYVM, SLAB, 2.5+> serial.BUYVM_SLAB_VOLUME-1305%0a19,22c19,20%0a%3c The first disk @@sd0@@ can store around 500GB of data, the second disk @@sd1@@ can store around 40GB.%0a%3c %0a%3c We will now add the new space from @@sd0@@ by creating a new partition for the disk, formatting it, and then mounting it to the filesystem.%0a%3c %0a---%0a> We will now add this new space by creating a new partition for the disk, formatting it, and then mounting it to the filesystem.%0a> %0a32c30%0a%3c sd0: 1> %0a---%0a> sd2: 1> %0a38c36%0a%3c sd0: 1> help%0a---%0a> sd2: 1> %0a54,56c52,54%0a%3c sd0: 1> print%0a%3c Disk: sd0 geometry: 66837/255/63 [1073741824 Sectors]%0a%3c Offset: 0 Signature: 0x0%0a---%0a> sd2: 1> print%0a> Disk: sd2 geometry: 949/255/63 [15261696 Sectors]%0a> Offset: 0 Signature: 0xAA55%0a60c58%0a%3c 0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a---%0a> 0: EF 0 1 2 - 0 16 16 [ 64: 960 ] EFI Sys %0a63,64c61%0a%3c 3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c %0a---%0a> *3: A6 0 16 17 - 84 165 17 [ 1024: 1358848 ] OpenBSD %0a
102
2021-12-17
diff:1609654883:1609653927:=28,30c28%0a%3c $ doas fdisk -e sd0%0a%3c Enter 'help' for information%0a%3c sd2: 1> %0a---%0a> $ doas fdisk sd0%0a33,64d30%0a%3c Type @@help@@ to get help, @@manual@@ to read the [[https://man.openbsd.org/fdisk|fdisk]] man page, and @@print@@ to view the partitions:%0a%3c %0a%3c [@%0a%3c sd2: 1> %0a%3c help Command help list%0a%3c manual Show entire OpenBSD man page for fdisk%0a%3c reinit Re-initialize loaded MBR (to defaults)%0a%3c setpid Set the identifier of a given table entry%0a%3c disk Edit current drive stats%0a%3c edit Edit given table entry%0a%3c flag Flag given table entry as bootable%0a%3c update Update machine code in loaded MBR%0a%3c select Select extended partition table entry MBR%0a%3c swap Swap two partition entries%0a%3c print Print loaded MBR partition table%0a%3c write Write loaded MBR to disk%0a%3c exit Exit edit of current MBR, without saving changes%0a%3c quit Quit edit of current MBR, saving current changes%0a%3c abort Abort program without saving current changes%0a%3c sd2: 1> print%0a%3c Disk: sd2 geometry: 949/255/63 [15261696 Sectors]%0a%3c Offset: 0 Signature: 0xAA55%0a%3c Starting Ending LBA Info:%0a%3c #: id C H S - C H S [ start: size ]%0a%3c -------------------------------------------------------------------------------%0a%3c 0: EF 0 1 2 - 0 16 16 [ 64: 960 ] EFI Sys %0a%3c 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused %0a%3c *3: A6 0 16 17 - 84 165 17 [ 1024: 1358848 ] OpenBSD %0a%3c @]%0a%3c %0a%3c First, let's print%0a
108
2021-12-17
diff:1609653679:1609653561:=4,5d3%0a%3c %0a%3c '''NOTE''': This guide is '''no''' substitute for reading the [[https://www.openbsd.org/faq/|OpenBSD FAQ]]. In particular, you should read the section on [[https://www.openbsd.org/faq/faq14.html|Disk Setup]].%0a
111
2021-12-17
diff:1609653561:1609653222:=3,4d2%0a%3c '''WARNING''': '''BE CAREFUL!''' Some commands in this tutorial can cause permanent data loss. We recommend you [[openbsd/backup|backup]] your files before attempting to run these commands. You should also double check every command to make sure you have made no typos or mistakes. A single typo could destroy your data forever!%0a%3c %0a19,20d16%0a%3c '''WARNING''': Double check your commands and make certain you are editing the correct disk. You must substitute the disk in the example for the one you actually want to format. Typing the wrong disk by accident could destroy all your data forever.%0a%3c %0a23,29c19,20%0a%3c The first task is to use fdisk to create fdisk partitions (Master Boot Record partitions).%0a%3c %0a%3c [@%0a%3c $ doas fdisk sd0%0a%3c @]%0a%3c %0a%3c %0a---%0a> If you need to add a new disk%0a> %0a
114
2021-12-17
diff:1609653222:1609653146:=13,15c13%0a%3c In this example, our server has two SCSI-like disks (a BuyVM slab and a VirtIO block device). In this case, the VirtIO block device is the hard disk the operating system is installed on, and the slab is extra storage we purchased. The disks are numbered by the ordered in which they are detected at boot time. The first SCSI-like disk will be sd0, the second sd1, and so forth.%0a%3c %0a%3c We will now add this new space by creating a new partition for the disk, formatting it, and then mounting it to the filesystem.%0a---%0a> In this example, our server has two SCSI-like disks (a BuyVM slab and a VirtIO block device). In this case, the VirtIO block device is the hard disk the operating system is installed on, and the slab is extra storage we purchased. We will now add this new space by creating a new partition for the disk, formatting it, and then mounting it to the filesystem.%0a
117
2021-12-17
diff:1609653146:1609652893:=7,10c7,8%0a%3c sd0 at scsibus2 targ 0 lun 0: %3cBUYVM, SLAB, 2.5+> serial.BUYVM_SLAB_VOLUME-1305%0a%3c sd0: 524288MB, 512 bytes/sector, 1073741824 sectors, thin%0a%3c sd1 at scsibus3 targ 0 lun 0: %3cVirtIO, Block Device, >%0a%3c sd1: 40960MB, 512 bytes/sector, 83886080 sectors%0a---%0a> sd0 at scsibus3 targ 0 lun 0: %3cVirtIO, Block Device, >%0a> sd0: 10240MB, 512 bytes/sector, 20971520 sectors%0a13,15c11%0a%3c In this example, our server has two SCSI-like disks (a BuyVM slab and a VirtIO block device). In this case, the VirtIO block device is the hard disk the operating system is installed on, and the slab is extra storage we purchased. We will now add this new space by creating a new partition for the disk, formatting it, and then mounting it to the filesystem.%0a%3c %0a%3c !! Creating a New Partition%0a---%0a> In this example, our server uses a SCSI-like disk (VirtIO block device). The disk itself is about 10G in size.%0a
120
2021-12-17
diff:1609652893:1609652335:=3,4c3,4%0a%3c On OpenBSD, there are two disk drivers: [[https://man.openbsd.org/wd|wd]] and [[https://man.openbsd.org/sd|sd]]. wd is an IDE-like disk, and sd is a SCSI-like disk (including USB disks). To list all your available disks:%0a%3c %0a---%0a> On OpenBSD, there are two disk drivers: wd and sd. To list all your available disks:%0a> %0a6,8c6%0a%3c $ dmesg | grep -E '(sd[0-9]|wd[0-9])'%0a%3c sd0 at scsibus3 targ 0 lun 0: %3cVirtIO, Block Device, >%0a%3c sd0: 10240MB, 512 bytes/sector, 20971520 sectors%0a---%0a> $ dmesg | grep -E '(sd|wd)'%0a11,19d8%0a%3c In this example, our server uses a SCSI-like disk (VirtIO block device). The disk itself is about 10G in size.%0a%3c %0a%3c If you need to add a new disk%0a%3c %0a%3c [@%0a%3c # fdisk%0a%3c # disklabel%0a%3c # newfs /dev/rsd0g%0a%3c # mount /dev/sd0g /mnt%0a
123
2021-12-17
diff:1609652335:1609652102:=1,8c1,5%0a%3c (:title Adding a New Disk:)%0a%3c %0a%3c On OpenBSD, there are two disk drivers: wd and sd. To list all your available disks:%0a%3c %0a%3c [@%0a%3c $ dmesg | grep -E '(sd|wd)'%0a%3c @]%0a%3c %0a---%0a> %0a> # fdisk%0a> # disklabel%0a> # newfs /dev/rsd0g%0a> # mount /dev/sd0g /mnt%0a
126
2021-12-17
diff:1609652102:1609652102:=1,5d0%0a%3c %0a%3c # fdisk%0a%3c # disklabel%0a%3c # newfs /dev/rsd0g%0a%3c # mount /dev/sd0g /mnt%0a