1
0

Compare commits

...

32 Commits

Author SHA1 Message Date
41f208c28d Update Linux.md 2025-12-05 08:16:50 +01:00
4518f96edd Update Linux.md 2025-05-07 13:53:12 +02:00
81b1e38af3 Update Linux.md 2025-05-07 13:52:22 +02:00
072ac6969c Update Linux.md 2025-05-07 09:51:09 +02:00
a0a9a3ea6d Add ionos_freebsd_install.md 2025-02-21 09:10:14 +01:00
1ab41f0714 Update mfsbsd.md 2025-04-21 17:18:21 +02:00
093a41fcba Update mfsbsd.md 2025-04-21 17:17:17 +02:00
ed6df10373 Add mfsbsd 2025-04-21 17:16:50 +02:00
3b3eeef268 Update README.md 2025-01-04 09:10:23 +01:00
43695d4215 Update Linux.md 2025-01-03 07:06:14 +01:00
f944adc918 Update Linux.md 2025-01-03 07:04:58 +01:00
c70dc8d662 Add Linux.md 2025-01-03 07:04:19 +01:00
96d69523bf Update awk_sed.md 2024-03-15 15:50:00 +01:00
1cbcc3b6a6 Add awk_sed.md 2024-03-15 15:48:21 +01:00
887dbb9566 Adding GPG Cheatsheet 2024-02-19 08:16:53 +01:00
d64752972e Update README.md 2024-01-16 12:40:38 +01:00
96809be28e Update DPX.md 2024-01-16 12:39:35 +01:00
c97f308e46 Update DPX.md 2024-01-16 12:37:57 +01:00
93db66f910 Add DPX.md 2024-01-16 12:37:31 +01:00
50f03c919f Update FreeBSD.md 2023-12-01 18:55:25 +01:00
a83893f001 Update FreeBSD.md 2023-11-29 08:45:55 +01:00
d587927599 Update FreeBSD.md 2023-11-29 07:56:14 +01:00
fe7dc8d98f Update README.md 2023-11-28 16:57:56 +01:00
f009736854 Update OES.md 2023-11-28 15:55:51 +01:00
f9ae8eddd8 Add OES.md 2023-11-28 15:53:48 +01:00
f2c8a47d8f Update FreeBSD.md 2023-11-26 17:49:39 +01:00
64819f017b Update FreeBSD.md 2023-11-24 17:17:00 +01:00
1f90d9d649 Update FreeBSD.md 2023-11-24 17:15:55 +01:00
369f5e1ff2 Update FreeBSD.md 2023-11-24 17:04:08 +01:00
b18cae04fd Some changes 2023-11-15 12:54:37 +01:00
f6916b6b61 Added Windows Cheat Sheet 2023-11-15 12:45:18 +01:00
e70bf12cf6 Added Windows Cheat Sheet 2023-11-15 12:41:20 +01:00
10 changed files with 423 additions and 14 deletions

26
DPX.md Normal file
View File

@ -0,0 +1,26 @@
## DPX / vStor Tips
### Expand vStor Pool
When the disk for the vStor pool is expanded on VMWARE or storage backend, the ZFS pool still needs to be informed of that change.
First get the device name in your pool
```sh
zpool status <pool name>
[root@vstor-4-9-2_rep admin]# zpool status vpool1
pool: vpool1
state: ONLINE
config:
NAME STATE READ WRITE CKSUM
vpool1 ONLINE 0 0 0
scsi-36000c2958c1c3aa7c2b11d461c47ee37 ONLINE 0 0 0
errors: No known data errors
```
Expand the pool to use all available space
```sh
zpool online -e vpool1 scsi-36000c2958c1c3aa7c2b11d461c47ee37
```
where scsi-36000c2958c1c3aa7c2b11d461c47ee37 is the name of the device which expands the pool

61
FreeBSD.md Normal file
View File

@ -0,0 +1,61 @@
# FreeBSD Cheat Sheet
A collection of commands I use frequently and still don't remember.
## pkg
### Display the message after first installing the application
```sh
pkg show -D <pkg_name>
```
## iocage
### Setup a new jail with vnet
```sh
iocage create -n <jailname> ip4_addr="10.192.0.28/24" defaultrouter="10.192.0.1" allow_raw_sockets=1 vnet=on boot=on interfaces="vnet0:em0bridge" -r 13.2-RELEASE
```
## zfs
### Show holds on a specific snapshot
If snapshots return as dataset is busy upon deletion, they are either dependent or use a tag that prevents them from being deleted. The command below will display any holds on a snapshot.
```sh
zfs holds -r <snapshot_name>
```
To release the snapshot from a tag
```sh
zfs release -r <tag_name> <snapshot_name>
```
### Migrate dataset to new pool
```sh
zfs snapshot -r old_pool/<dataset_name>@relocate
zfs send -Rv old_pool/<dataset_name>@relocate | zfs receive -d new_pool/<new_dataset_name>
```
## tcsh
### Execute command from history
```sh
history | grep <command>
!<id command>
```
### For loop to copy files and rename in destination
```sh
foreach f (*.jpg)
cp "$f" /destination/newname-"$f"
end
```
Use quotes if filenames have spaces

51
GPG.md Normal file
View File

@ -0,0 +1,51 @@
# GPG Cheatsheet
A collection of GPG commands I use and still don't remember.
### List keys
```sh
gpg -k
```
### Edit a key
```sh
gpg --edit-key <key_id>
```
### Import a public key
```sh
gpg --import <keyfile>.txt
```
### Export a public key
```sh
gpg --export -a <user_or_email> > <outputfile>
```
### Export a private key
```sh
gpg --export-secret-key -a <user_or_email> > <outputfile>
```
### Encrypt a message
```sh
gpg --encrypt --armor -r <user_or_email> <inputfile>
```
### Decrypt a message
```sh
gpg --decrypt --output <outputfile> <inputfile>
```
### Update keys on server
```sh
gpg --keyserver pgp.mit.edu --send-keys <key_id>
```

32
Linux.md Normal file
View File

@ -0,0 +1,32 @@
# Linux Tips
## Network
### Wifi setup
```
wpa_passphrase <Network Name> <password> > /etc/wpa_supplicant.conf
wpa_supplicant -B -i<wlan> -c /etc/wpa_supplicant.conf
```
### EFI Boot Manager
To fix boot manager use -o to select first entry
```
efibootmgr -o 0001
```
### Download SSL certificate from website
```
openssl s_client -connect www.google.com:443 2>/dev/null </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p'
```
### Import certificate into Java Keystore
```
keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias"
```
### Scan for new disks without reboot
```
echo "- - -" | tee /sys/class/scsi_host/host*/scan
```
### Socat fork connection
```
socat tcp6-listen:5558,fork tcp4:192.168.18.21:80
```

11
OES.md Normal file
View File

@ -0,0 +1,11 @@
# OES Cheat Sheet
A collection of commands and hints for administering OES
## Hints
### Location of eDirectory and NSS configuration files
```sh
/etc/opt/novell/
```

View File

@ -1,22 +1,15 @@
# FreeBSD Cheat Sheet # Command Line Cheat Sheet
A collection of commands I use frequently and still don't remember. A collection of commands I use frequently and still don't remember.
## pkg [FreeBSD Cheat Sheet](FreeBSD.md)
### Display the message after first installing the application [Linux Cheat Sheet](Linux.md)
```sh [Windows Cheat Sheet](Windows.md)
pkg show -D <pkg_name>
```
## iocage [OES Cheat Sheet](OES.md)
### Setup a new jail with vnet [DPX / vStor Cheat Sheet](DPX.md)
```sh [GPG Cheat Sheet](GPG.md)
iocage create -n <jailname> ip4_addr="10.192.0.28/24" defaultrouter="10.192.0.1" allow_raw_sockets=1 vnet=on boot=on interfaces="vnet0:em0bridge" -r 13.2-RELEASE
```
## Test
Some test below

11
Windows.md Normal file
View File

@ -0,0 +1,11 @@
# Windows Cheat Sheet
A collection of commands I use frequently and still don't remember.
## CMD
### 'watch' command on Windows
```sh
for /l %g in () do @(<command> & timeout /t 5)
```

15
awk_sed.md Normal file
View File

@ -0,0 +1,15 @@
# AWK and SED Tips and tricks
## AWK
### Calculate total or average
```sh
awk '{sum+=$1; n++} END {print sum / n}'
```
or using builtin row counter NR
```sh
awk '{sum+=$1} END {{if NR > 0} print sum / NR}'
```

51
ionos_freebsd_install.md Normal file
View File

@ -0,0 +1,51 @@
# Install FreeBSD
1. Buy VPS, with any OS
2. Insert DVD: Grml
3. Reboot
4. `wget https://mfsbsd.vx.sk/files/images/14/amd64/mfsbsd-14.1-RELEASE-amd64.img`
5. `fdisk -l` => find the `/dev/<disk>` to use
6. `dd if=mfsbsd-14.1-RELEASE-amd64.img of=/dev/<disk>`
7. Eject DVD & reboot
8. ssh using mfsbsd default creds root/mfsroot
9. `gpart recover vtbd0` to fix the partition table
10. `bsdinstall`
11. Reboot
# Reduce boot time
1. `fetch http://ftp.freebsd.org/pub/FreeBSD/releases/amd64/14.1-RELEASE/src.txz`
2. `tar -C / -xvf src.txz`
3. `freebsd-update fetch && freebsd-update install`
4. `cd /usr/src/`
5. ```make buildkernel -j `sysctl -n hw.ncpu` KERNCONF=MINIMAL && make installkernel KERNCONF=MINIMAL```
6. Update `/boot/loader.conf`
```conf
...
kern.boottrace.enabled=1
autoboot_delay=1
ufs_load="YES"
...
```
# Enabling IPv6 and fixing “Bogus Host Name” warning
> IONOS uses DHCPv6+rtsol to assign IP address and routing configuration for the IPv6.
1. Add ipv6 in the Ionos panel
2. `pkg install dual-dhclient-daemon`
3. Update `/etc/rc.conf`:
```conf
...
ifconfig_vtnet0="DHCP"
dhclient_program="/usr/local/sbin/dual-dhclient"
ipv6_activate_all_interfaces="YES"
ipv6_defaultrouter="fe80::1%vtnet0"
...
```
4. Update `/etc/dhclient.conf`:
```conf
...
interface "vtnet0" {
ignore host-name;
}
...
```
5. `service dhclient restart vtnet0`

158
mfsbsd.md Normal file
View File

@ -0,0 +1,158 @@
Preface
As many might have already discovered, there are myriads of hosting providers out there that only offer various Linux distributions for (pre-)installation on their servers, but often won't even offer any support for installing any BSD variant.
However, installing FreeBSD from a Linux rescue system - or basically _any_ (rescue) system that allows you to copy a diskimage to a hard drive on your server - really isn't that hard.
There are quite some how-tos and blog postings out there on how to achieve this and even the FreeBSD handbook has a page on this Topic. However, at least all of those I sifted through, were quite a bit outdated, almost none even covered ZFS or only in obscure and complicated ways (been there, done that...) and some were just wrong - at least for more recent FreeBSD versions.
Overall - most of the instructions were overly complicated and it seemed that some authors were trying their best to avoid any shortcut or automatism e.g. by leveraging the FreeBSD installer to do the heavy lifting.
I recently evaluated a working procedure for an upcoming deployment of FreeBSD 11.1-RELEASE on a new root-server without IPMI and remote access only via a Linux rescue system. This how to is directly derived from my notes/documentation of the process.
As every Perl coder knows: TIMTOWTDI - the procedure I will describe was - for me - the most painless and easiest way condensed from various older Instructions, manual pages, personal experiences and quite a lot of 'try & error'.
What I have come up with will very likely not be the most perfect way to do it - so feel free to reply with improvements or (most importantly) corrections on any error I might have made.
Warnings
As stated before, there are many outdated how-tos out in the wild from way back when e.g. 9.0-RELEASE was the latest release. The following procedure has been worked out and tested with 11.1-RELEASE. Don't expect any of the following to work in a few years time with something like a 13.0-RELEASE or even 12.0-RELEASE and even expect minor variations for other dot-Releases!
I'll try to keep these instructions updated for some time, but you have been warned.
Overview
The whole Procedure basically consists of only 3 Steps:
- build a mfsBSD image
- use the Linux Rescue System to write mfsBSD to a disk on the server
- boot mfsBSD and use bsdinstall(8) to do all the dirty work
Especially on the first and last step, however, I discovered some pitfalls that have to be circumvented.
Step 1 - built the mfsBSD image
mfsBSD is basically only a set of scripts to build a stripped-down FreeBSD image that will from memory.
On the project website at http://mfsbsd.vx.sk/ one could download pre-built images, but they are pre-configured for DHCP, which rules them out for most hosting environments.
Additionally we'd really like to use a ssh-key for login instead of exposing an sshd with enabled root-login and a (very weak) password to the whole world.
I've seen boxes being hit with automated bruteforce login attempts to ssh just seconds after they were first deployed - this is a real threat, so don't take this lightly!
To build our own mfsBSD-image we need to clone the mfsBSD github repository:
Code:
$ git clone https://github.com/mmatuska/mfsbsd.git
Now we have a look at the mfsbsd/conf directory. All files with their names ending in .sample contain information on how/what can be configured, but mainly they are just what you would expect on a running FreeBSD system. The .sample-files will be ignored at build time, so copy any file you need and want to edit, stripping the .sample from its name.
At least add your/a working public ssh-key to authorized_keys and add the configuration for one of the available Network cards on your server to either interfaces.conf or rc.conf.
The interfaces.conf file is special, in that it allows you to configure a network adapter without knowing what driver it uses - you only need to know the MAC-address.
interfaces.conf.sample contains all the information you need. A working configuration might look as follows:
Code:
mac_interface="ext1"
ifconfig_ext1_mac="d2:b9:2e:5a:a0:dc"
ifconfig_ext1="inet 10.50.51.169/24"
Make sure to also include rc.conf with sshd_enable="YES" and the defaultrouter set! A working resolv.conf should also be included.
Now you should have the following files in your conf/ directory, with the interfaces.conf being optional:
Code:
$ ls ~/mfsbsd/conf | grep -v sample
authorized_keys
interfaces.conf
loader.conf
rc.conf
To build the image, mfsBSD needs the release-files and sources for the version we want to build our image from. This is most likely the same release we want to install on the target system.
Download the files into a known location (e.g. a separate folder within the mfsbsd directory) and unpack the src.txz file.
Code:
$ mkdir ~/mfsbsd/dist-files
$ cd ~/mfsbsd/dist-files
$ curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/base.txz
$ curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/kernel.txz
$ curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/MANIFEST
$ curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/src.txz
$ tar xzf src
mfsBSD also needs a statically linked version for pkg. This can be placed either into the mfsbsd/tools directory or we can just use the one provided on the system we are building mfsBSD on. I will use the second approach in the example.
Beware of possible ABI incompatibilities when building on a different branch than the resulting mfsBSD image will be! I was running all mfsBSD builds during my tests on a 12.0-CURRENT system and the resulting build for 11.1-RELEASE worked, but you have been warned!
For building mfsBSD we need to elevate to root and run make within the mfsbsd directory, including the paths to BASE, SRC_DIR and PKG_STATIC and increasing the MFSROOT_MAXSIZE.
Code:
make BASE=/usr/home/user/sko/mfsbsd/dist-files SRC_DIR=/usr/home/user/sko/mfsbsd/dist-files/usr/src PKG_STATIC=/usr/local/sbin/pkg-static MFSROOT_MAXSIZE=100m
Extracting base and kernel ... done
Removing selected files from distribution ... done
Installing configuration scripts and files ... done
Generating SSH host keys ... done
Configuring boot environment ... done
Installing pkgng ... done
Compressing usr ... done
Creating and compressing mfsroot ... done
The mfsBSD image has been created in mfsbsd/mfsbsd-11.1-RELEASE-amd64.img and is ready to be deployed. We can now drop root privileges and move on.
Step 2 - transfer the mfsBSD image to your server and write it to disk
Well, there isn't really much to say about this step - we really only need to touch the Linux system for a minimal amount of time, using only 2 tools everyone is already familiar with: scp and dd.
Just transfer the image over to the Linux rescue system via scp and write it to a bootable (most likely the first) disk.
Usually Linux will name SATA/SAS/SCSI disks "sdN" with N=a being the first disk, N=c the 3rd and N=z the 26nd disk. Virtual disks are named "vdN" in case you are installing on a VPS.
So to dd the image to the first disk:
dd if=mfsbsd-11.1-RELEASE-amd64.img of=/dev/sda bs=1M
Step 3 - boot the mfsBSD image and install FreeBSD
After writing the mfsbsd-image to disk, just reboot the box:
shutdown -r now
Then wait for it to come back online, this time already running FreeBSD. You can now log as root with the ssh-key matching the public key in the authorized_keys file used to build mfsbsd.
Code:
$ ssh root@10.50.51.169
FreeBSD 11.1-RELEASE (GENERIC) #0 r321309: Fri Jul 21 02:08:28 UTC 2017
Welcome to mfsBSD, the memory based FreeBSD distribution.
This is a stripped-down version of FreeBSD without:
- manual pages, info pages, examples
- include files, static library files, development tools
- bind binaries (host, dig, named, etc.)
Feel free to email me with any bug reports or feature suggestions.
Martin Matuska <mm@FreeBSD.org>
http://mfsbsd.vx.sk/
root@mfsbsd:~ #
Before we can actually run bsdinstall(8) we need to create the directory where bsdinstall wants to download additional release files to, as this isn't present on our mfsbsd system.
Somehow bsdinstall on mfsbsd also fails to store the files at this location - so we download all of them before running bsdinstall. To do this we also need to install curl (or wget).
Code:
mkdir /usr/freebsd-dist
pkg install curl
curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/kernel.txz
curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/base.txz
curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/MANIFEST
curl -O https://download.freebsd.org/ftp/releases/amd64/11.1-RELEASE/src.txc
bsdinstall
Now you can walk through the installation process as usual. As mfsbsd is completely running from memory filesystem (hence the "mfs" in its name), you can use your local disks just as you would on any installation via IPMI or on a local console.
The process of installing FreeBSD is covered in detail by the FreeBSD Handbook. Therefore, and because I strongly believe anyone putting a server out in the wild should be already familiar with installing, setting up and securing a system, I will not cover any of these topics here.
Before rebooting the newly installed system make sure to add at least one user and enable sshd, so you will be able to access the newly installed system. Double-checking rc.conf and resolv.conf might also be a good idea, just to make sure the new system is able to get on the network and resolve names.
Final Words
This is really all that's necessary nowadays to remotely install FreeBSD from any rescue system. No manual setup of ZFS-pools and -datasets, extracting the base system, placing the bootloader on disk or building world in a chroot. These skills are quite handy when things go wrong, but things done manually are prone to human error.
The FreeBSD installer is really up to the task of most if not all scenarios (at least where you won't have proper IPMI...) and makes installation so much more easy, fast and somewhat safer. So why not honor the hard work of the authors of bsdinstall and just use it for what it was meant to do and does well :).
As said in the Preface: This procedure will most likely not be perfect - feel free to reply with any improvements or corrections.