OpenBSD: Difference between revisions
Initial content |
No edit summary |
||
| Line 1: | Line 1: | ||
OpenBSD is a UNIX-like operating system. | OpenBSD is a UNIX-like operating system. | ||
==Package management== | |||
https://cdn.openbsd.org/pub/OpenBSD | |||
#export PKG_PATH=scp://user@company-build-server/usr/ports/packages/%a/all:https://trusted-public-server/%m:installpath | |||
The common programs that you'll use to manage packages are: | |||
{| class="wikitable" | |||
!Command | |||
!Description | |||
|- | |||
|<code>pkg_add</code> | |||
|installing and upgrading packages | |||
|- | |||
|<code>pkg_check</code> | |||
|checking the consistency of installed packages | |||
|- | |||
|<code>pkg_delete</code> | |||
|removing installed packages | |||
|- | |||
|<code>pkg_info</code> | |||
|display and search for information about packages | |||
|} | |||
Common package tasks: | |||
{| class="wikitable" | |||
!Task | |||
!Command | |||
!Example | |||
|- | |||
|Search for a package | |||
|<code>pkg_info -Q <search></code> | |||
|<code>pkg_info -Q unzip</code> | |||
|- | |||
|Find out what package provides a specific file. Eg. like <code>yum whatprovides</code> | |||
|<code>pkglocate <file/path></code> | |||
|<code>pkglocate vim</code> | |||
|- | |||
|Install a new package | |||
|<code>pkg_add <package></code> | |||
|<code>pkg_add vim</code> | |||
|- | |||
|Update a package and its dependencies | |||
|<code>pkg_add -u <package></code> | |||
|<code>pkg_add -u vim</code> | |||
|} | |||
== Tasks == | |||
===System update=== | |||
To update a OpenBSD system, run: | |||
{{Highlight | |||
| code = # syspatch | |||
# pkg_add -Uu | |||
# sysmerge -d | |||
| lang = terminal | |||
}} | |||
=== Finding all available disks === | |||
There is no lsblk. Rather, you can find all disks using <code>sysctl | grep disk</code>. | |||
{{Highlight | |||
| code = # sysctl -a {{!}} grep -i disk | |||
hw.disknames=wd0:94a4943e88c9a60f,wd1:,cd0:,fd0: | |||
hw.diskcount=4 | |||
machdep.bios.diskinfo.128=bootdev = 0xa0000200, cylinders = 1023, heads = 255, sectors = 63 | |||
machdep.bios.diskinfo.129=bootdev = 0xa0010200, cylinders = 1023, heads = 255, sectors = 63 | |||
| lang = terminal | |||
}} | |||
Disks are named either <code>wd*</code> (IDE, SATA, flash devices) or <code>sd*</code> (SCSI devices, USB drives via the ahci interface, or disks via a RAID controller). | |||
=== Partitioning and formatting disks === | |||
Disk partitioning can be done using OpenBSD's version of <code>fdisk</code>. fdisk supports both MBR and GPT disks. For MBR based disks, fdisk will allow you to create a primary partition in each of the available 4 slots (as shown below). Each primary MBR partition that's set to the OpenBSD MBR partition type (0xA6) will have its own 16 entry partition table which can be edited with <code>disklabel</code>. These 'disk labels' outline the start and end of the underlying primary partition which can then be formatted with a filesystem. | |||
For more info, refer to [https://www.openbsd.org/faq/faq14.html? OpenBSD's FAQ]. | |||
A blank MBR disk looks like the following: | |||
{{Highlight | |||
| code = # fdisk wd1 | |||
Disk: wd1 geometry: 1305/255/63 [20971520 Sectors] | |||
Offset: 0 Signature: 0x0 | |||
Starting Ending LBA Info: | |||
#: id C H S - C H S [ start: size ] | |||
------------------------------------------------------------------------------- | |||
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
| lang = terminal | |||
}} | |||
To create a new primary partition, edit one of the entries and specify a start and end size. You can enter '1G' to specify 1GB. Set the type to <code>0xA6</code> so that you can use <code>disklabel</code> to partition out the space out further. | |||
{{Highlight | |||
| code = ## Create a new primary partition | |||
# fdisk -e wd1 | |||
wd1*: 1> edit 3 | |||
Starting Ending LBA Info: | |||
<nowiki> #</nowiki>: id C H S - C H S [ start: size ] | |||
------------------------------------------------------------------------------- | |||
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
Partition id ('0' to disable) [01 - FF]: [00] (? for help) A6 | |||
Do you wish to edit in CHS mode? [n] | |||
Partition offset [0 - 20971519]: [0] | |||
Partition size [1 - 20971520]: [1] 1G | |||
wd1*: 1> print | |||
Disk: wd1 geometry: 1305/255/63 [20971520 Sectors] | |||
Offset: 0 Signature: 0x0 | |||
Starting Ending LBA Info: | |||
<nowiki> #</nowiki>: id C H S - C H S [ start: size ] | |||
------------------------------------------------------------------------------- | |||
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused | |||
3: A6 0 0 1 - 130 138 8 [ 0: 2097152 ] OpenBSD | |||
| lang = terminal | |||
}} | |||
With a partition created, you can then partition out the space with <code>disklabel</code>. | |||
{{Highlight | |||
| code = ## Create a new secondary partition | |||
# disklabel -e wd1 | |||
## In the editor, add a new entry after 'c:' | |||
16 partitions: | |||
<nowiki>#</nowiki> size offset fstype [fsize bsize cpg] | |||
c: 20971520 0 unused | |||
d: 102400 0 4.2BSD 2048 16384 12960 | |||
| lang = terminal | |||
}} | |||
Then, create a new filesystem on <code>wd1d</code> | |||
{{Highlight | |||
| code = # newfs wd1d | |||
/dev/rwd1d: 50.0MB in 102400 sectors of 512 bytes | |||
4 cylinder groups of 12.50MB, 800 blocks, 1600 inodes each | |||
super-block backups (for fsck -b #) at: | |||
160, 25760, 51360, 76960, | |||
| lang = terminal | |||
}} | |||
=== Disabling library ASLR === | |||
<code>rcctl disable library_aslr</code> | |||
Revision as of 00:28, 27 April 2022
OpenBSD is a UNIX-like operating system.
Package management
https://cdn.openbsd.org/pub/OpenBSD
- export PKG_PATH=scp://user@company-build-server/usr/ports/packages/%a/all:https://trusted-public-server/%m:installpath
The common programs that you'll use to manage packages are:
| Command | Description |
|---|---|
pkg_add
|
installing and upgrading packages |
pkg_check
|
checking the consistency of installed packages |
pkg_delete
|
removing installed packages |
pkg_info
|
display and search for information about packages |
Common package tasks:
| Task | Command | Example |
|---|---|---|
| Search for a package | pkg_info -Q <search>
|
pkg_info -Q unzip
|
Find out what package provides a specific file. Eg. like yum whatprovides
|
pkglocate <file/path>
|
pkglocate vim
|
| Install a new package | pkg_add <package>
|
pkg_add vim
|
| Update a package and its dependencies | pkg_add -u <package>
|
pkg_add -u vim
|
Tasks
System update
To update a OpenBSD system, run:
# syspatch
# pkg_add -Uu
# sysmerge -d
Finding all available disks
There is no lsblk. Rather, you can find all disks using sysctl | grep disk.
# sysctl -a | grep -i disk
hw.disknames=wd0:94a4943e88c9a60f,wd1:,cd0:,fd0:
hw.diskcount=4
machdep.bios.diskinfo.128=bootdev = 0xa0000200, cylinders = 1023, heads = 255, sectors = 63
machdep.bios.diskinfo.129=bootdev = 0xa0010200, cylinders = 1023, heads = 255, sectors = 63
Disks are named either wd* (IDE, SATA, flash devices) or sd* (SCSI devices, USB drives via the ahci interface, or disks via a RAID controller).
Partitioning and formatting disks
Disk partitioning can be done using OpenBSD's version of fdisk. fdisk supports both MBR and GPT disks. For MBR based disks, fdisk will allow you to create a primary partition in each of the available 4 slots (as shown below). Each primary MBR partition that's set to the OpenBSD MBR partition type (0xA6) will have its own 16 entry partition table which can be edited with disklabel. These 'disk labels' outline the start and end of the underlying primary partition which can then be formatted with a filesystem.
For more info, refer to OpenBSD's FAQ.
A blank MBR disk looks like the following:
# fdisk wd1
Disk: wd1 geometry: 1305/255/63 [20971520 Sectors]
Offset: 0 Signature: 0x0
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
To create a new primary partition, edit one of the entries and specify a start and end size. You can enter '1G' to specify 1GB. Set the type to 0xA6 so that you can use disklabel to partition out the space out further.
## Create a new primary partition
# fdisk -e wd1
wd1*: 1> edit 3
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
Partition id ('0' to disable) [01 - FF]: [00] (? for help) A6
Do you wish to edit in CHS mode? [n]
Partition offset [0 - 20971519]: [0]
Partition size [1 - 20971520]: [1] 1G
wd1*: 1> print
Disk: wd1 geometry: 1305/255/63 [20971520 Sectors]
Offset: 0 Signature: 0x0
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: A6 0 0 1 - 130 138 8 [ 0: 2097152 ] OpenBSD
With a partition created, you can then partition out the space with disklabel.
## Create a new secondary partition
# disklabel -e wd1
## In the editor, add a new entry after 'c:'
16 partitions:
# size offset fstype [fsize bsize cpg]
c: 20971520 0 unused
d: 102400 0 4.2BSD 2048 16384 12960
Then, create a new filesystem on wd1d
# newfs wd1d
/dev/rwd1d: 50.0MB in 102400 sectors of 512 bytes
4 cylinder groups of 12.50MB, 800 blocks, 1600 inodes each
super-block backups (for fsck -b #) at:
160, 25760, 51360, 76960,
Disabling library ASLR
rcctl disable library_aslr