Zobrazujú sa príspevky s označením Vim. Zobraziť všetky príspevky
Zobrazujú sa príspevky s označením Vim. Zobraziť všetky príspevky

nedeľa 25. marca 2012

Installation/upgrade/settings/hints summary

As I needed to reinstall whole system, I wrote down some notes as summary from beginning up to last post plus some new hints.

1. Minimal install
I started with version 9.0-Release. Than you don't have problems to upgrade to latest major version. Etc. from 8.2 to 9.0.
The post about installation is in this article.

2. Post install settings
a)Post install settings include steps from articles part1, part2, part3.
If you have already your settings in your current system and you would like to transfer them, just backup configuration files and put them into new system in the same place. Don't forget to install all ports/packages as before.

b)Edit your "make.conf" for instance like this. Do it before anything else, because from this point you will compile ports so let them be compiled with customized way.

c)HINT:Edit loader.conf. First important option we need to adjust is boot delay. By default the delay is 10s. Just put this line into "/boot/loader.conf":
autoboot_delay="1"

d)Install cvsup and create ports tree/source code. Don't forget to refuse what you don't need. I added to refuse file also:
src/games

Later we will cut off unnecessary features for compilation. We won't compile games so we don't need to download them.

e)HINT:As you recall about mutli-threaded source compilation, we can do this for ports compilation as well with very simple way.
cd /usr/ports/Mk/
vi bsd.port.mk
FORCE_MAKE_JOBS=yes
MAKE_JOBS_NUMBER=5

Why 5?As I've noticed, every time you upgrade ports tree, the "bsd.port.mk" is overwritten. So be aware of this. Of course there is workaround,I have to find it.

f)Install helpful ports like mc, vim...and adjust their configuration.

3. Compilation prepare of your own kernel/world
The aim is to skip everything unnecessary in compilation.

a)Make your own kernel config. Edit GENERIC in currently downloaded source! GENERICs may be different in content among major versions.

b)HINT:Adjust "world" compilation by refusing some stuff. This is my example:
cd /etc
touch src.conf
vi src.conf and what I have there:
WITHOUT_ATM=
WITHOUT_BLUETOOTH=
WITHOUT_CALENDAR=
WITHOUT_CVS=
WITHOUT_CTM=
WITHOUT_DICT=
WITHOUT_FLOPPY=
WITHOUT_GAMES=
WITHOUT_HTML=
WITHOUT_IDEA=
WITHOUT_INFO=
WITHOUT_IPFILTER=
WITHOUT_IPFW=
WITHOUT_LEGACY_CONSOLE=
WITHOUT_NCP=
WITHOUT_PORTSNAP=
WITHOUT_PPP=
WITHOUT_ROUTED=

c)HINT:Install "screen". Screen creates virtual terminals which you can detach and reconnect without loss of content or process output...
For example you can run the compilation in virtual terminal, detach terminal so switch back to normal shell, do your work and time to time switch to virtual terminal to check the process status. You can do the same with ssh connection, open terminal, run command, log off and another day log in back to remote machine, reconnect to virtual terminal and continue with work.
cd /usr/ports/sysutils/screen
make install clean

Usage example:
I want to create virtual terminal with name "MCBSD": screen -S MCBSD
I do something in new terminal and I want to switch back to normal shell:
Ctrl+a+d - this is for detach
I want to list the running terminals: screen -ls
I want to reconnect back to MCBSD terminal: screen -r MCBSD
I'm in the MCBSD terminal and want to terminate this terminal because I don't need it anymore: Ctrl+d

d)Edit "make.conf" to not to compile modules.

4. Compilation of your own kernel/world
-do a backup of config files
cd /usr/src
make buildworld
make buildkernel KERNCONF=[your_kernel]
make installkernel KERNCONF=[your_kernel]
-reboot to single user mode. On boot screen option something like "boot prompt". Type: "boot -s"
mount -a
cd /usr/src
mergemaster -p - leave everything in tmp folder
make installworld
mergemaster - leave everything in tmp folder
-Check differences between tmp and current files.
-manually copy files from tmp folder to final destination if needed.
make delete-old
make delete-old-libs - be careful, google first about it or don't do it
reboot
-if everything works fine, done
-You can reinstall all your ports, this is what I do.

 5. Reinstall ports/packages
It's not necessary if everything goes well. But I do it.
HINT:Install "portmaster". You will need it anyway (or another port-mgmt).
cd /usr/ports/ports-mgmt/portmaster
make install clean
man portmaster

To reinstall all ports with creating packages after compilation which saves time further. Will write about.
portmaster -a -f -g
Packages are stored in "usr/ports/packages".

Now you have fresh system waiting to be backed-up.
This is perfect stage when you can do a backup of whole system.
Every time you will need to install or reinstall computer/server or create new server or even a jail, you will do a restore and in few minutes(bit longer) you have a fresh system ready to go.


nedeľa 12. februára 2012

Vim install and configuration

You may have noticed we are editing/viewing files more and more. For these purposes I use "vim" editor. 
After minimal install, you can try to type "vi" in CLI. You will see kind of light,skimmed version of real "vim". We can make our work much more efficient with real "vim".

cd /usr/ports/editors/vim-lite - I use light version
make install clean
rehash

Now you can try to run vim with "vim" command. Notice you still have "vi" and "vim" command. I used to use old "vi" command, so we need to associate "vi" command with "vim" editor. One way how to do that is via alias. Put this in ".tcshrc":
alias vi /usr/local/bin/vim
setenv EDITOR vim - not necessary but why not

Log out and log in back and "vi" command should run "vim" editor.

That's nice, we have "vim" but to utilize vim's features for which we've installed "vim", we need to create config file with some parameters.
cd - go to home dir.
vi .vimrc - if ".vimrc" doesn't exist, vim will create new file
Put these lines into it:
set nocompatible - to stop vim acting weird
set number - show numbered lines
syntax on - distinguish syntax (very useful)
set backspace=start,eol,indent - make backspace work normally
set ignorecase - no case sensitve search
set incsearch - search on fly
set hlsearch - highlighted search
hi linenr ctermfg=darkgrey - color of line numbers
hi search ctermfg=red ctermbg=yellow - color of searched items

Now, after saving ".vimrc" and restarting "vim", all above should work. Essential controls in "vim":
a - insert mode (you can start typing)
i - replace mode (you can start typing)
/[string] - search in text
:w - save file, but not quit
:wq - save file with quit
:q! - force quit

It takes a while to get used to use "vim" but it's worth.