Ok, I'm sick and tired of looking up these questions in my engineering
notebook over and over so I have put them on the web. Now I don't need
to search for them anymore and maybe they'll be useful to you too. If
these notes are outdated or if you have notes you'll like to contribute
feel free to contact me.
Lastly I rebooted my box and started surfing. Thats it!
How do I clone an OS disk on Solaris?
Mon Sep 22 20:26:30 1997
Now, mount the destination partition
# mount /dev/dsk/c0t1d0s0 /mnt
Get creative with ufsdump/restore
# ufsdump 0f - /dev/rdsk/c0t3d0s0 | (cd /mnt;ufsrestore rf -)
Make the new root disk bootable
# installboot /usr/platform/`uname -m`/lib/fs/ufs/bootblk /dev/rdsk/c0t1d0s0
Repeat for different partitions
# mount/dev/dsk/c0t1d0s6 /mnt/usr
# ufsdump 0f /dev/rdsk/c0t3d0s6 | (cd /mnt/usr;ufsrestore rf -)
You can see this would lend itself to scripting. It's also fairly easy to
clone one disk onto several targets. It's not fast, it's not normally pretty,
but when you don't want to send disgusting amounts of data over a network,
it's useful. If you want to go from a drive with few partitions (say, / and
swap) to a same-size or smaller disk with many partitions, this process will
sometimes overfill the / partition. Extensive taring can get around that.
Most people move to bigger disks anyway.
Enjoy!
Sam Rafter
How do I configure sendmail to add my domain to my return add
ress Solaris 2.5.1?
Fri Sep 19 13:48:47 1997
Lots of questions are answered in the
Sendmail FAQ. One way to solve this problem is to
copy /etc/mail/subsidiary.cf to /etc/mail/sendmail.cf and then make the
following changes to /etc/mail/sendmail.cf.
NOTE: the whitespace in the rule set MUST be tabs.
S11
R$*<@$+>$* $@$1<@$2>$3 already ok
R$=D $@$1<@$w> tack on my hostname
R$+ $@$1<@kalle.com> tack on my domain
How do I set up majordomo on Solaris 2.5.1?
Thu Sep 4 15:21:48 1997
The
majordomo FAQ is a good place to start.
You'll need a C compiler and perl on the system your installing majordomo on.
Then get
sources for majordomo
and put them in /tmp.
Majordomo comes with rather extensive INSTALL and NEWLIST files.
You should read these files completely.
Then run the following commands as root:
# useradd -c "majordomo" -d /usr/local/majordomo -g 12 \
-m -u 100 -s /usr/bin/csh majordomo
# passwd majordomo
Run the following commands to extract the majordomo source a the majordomo
user.
% cd /tmp
% gunzip -c majordomo-1.94.4.tar.gz | tar -xvf -
% cd majordomo-1.94.4
Modify the following macros in /tmp/majordomo-1.94.4/Makefile:
PERL = /opt/LWperl/bin/perl
CC = /opt/SUNWspro/SC4.0/bin/cc
W_HOME = /usr/local/majordomo
W_USER = 100
W_GROUP = 12
Run the following commands as the majordomo user to install the majordomo
software.
% cd /tmp/majordomo-1.94.4
% /usr/ccs/bin/make wrapper
% /usr/ccs/bin/make install
% su root -c "/usr/ccs/bin/make install-wrapper"
% cd /usr/local/majordomo
% cp sample.cf majordomo.cf
Modify the following variables in /usr/local/majordomo/majordomo.cf:
$whereami = "kalle.com";
$homedir = "/usr/local/majordomo";
Add the following lines to /etc/aliases:
# majordomo mail aliases
majordomo: "|/usr/local/majordomo/wrapper majordomo"
owner-majordomo: kalle@kalle.com
majordomo-owner: kalle@kalle.com
test-list: :include:/usr/local/majordomo/lists/test
owner-test: kalle@kalle.com
test-owner: kalle@kalle.com
test-request: "|/usr/local/majordomo/wrapper majordomo -l test"
test-approval: kalle@kalle.com
Run the following configuration test script as a regular,
unprivileged user (not the majordomo user or root).
% cd /usr/local/majordomo
% ./wrapper config-test
Run the following commands as majordomo to create a test list.
The info file should have some useful information for the first time
user of the list.
% touch /usr/local/majordomo/lists/test
% touch /usr/local/majordomo/lists/test.info
% chmod 664 /usr/local/majordomo/lists/*
Test the configuration:
% echo 'lists' | mail majordomo
How do I set up the automounter on Solaris 2.5?
Mon Aug 11 14:22:12 1997
You'll need to add the file /etc/auto_direct and update /etc/auto_master
and /etc/auto_home.
Sam Rafter
comments that you'd prob'ly want to mount the directorys soft, or mount it
with a low number of retries. If you mount it hard, and the system
can't be reached, the machine won't finish loading the OS.
Here's an example of the configuration files I've used in the past:
/home1 rw,soft abbott:/export/home1
/etc/auto_home
+auto_home
kalle abbott:/export/home/&
/etc/auto_master
+auto_master
/net -hosts -nosuid
/home auto_home
/xfn -xfn
/- auto_direct
Once the system files are set up restart the automounter with
the following commands:
# /etc/rc2.d/S74autofs stop
# /etc/rc2.d/S74autofs start
What does big-endian and little-endian mean?
Thu Aug 7 16:23:32 1997
The terms
big-endian
and little
-endian
come from Swift's `Gulliver's Travels'
where big-endian refered to opening an egg at the big end and
little-endian refered to opening an egg at the little end.
The "endianness" of a computer's CPU is determined by how
multi-byte data structures are stored.
The paper by Danny Cohen
that popularized these terms
in connection
with the LSB-first/MSB-first controversy was entitled "On oly Wars and a Plea for
Peace".
Here's a table to help you determine the endianness of your system.
CPU | Endianness
|
Sparc | big |
Intel | little |
Motorola | big |
IBM | big |
MIPS | little/big |
Here's a simple runtime check for endianness of your machine.
is_little_endian()
{
int i=0;
((char *)(&i))[0] = 1;
return i == 1;
}
Here's the source to a generic endian swapper.
#define ENDIAN_SWAP(a) endian_swap(&(a), sizeof(a))
void
endian_swap(void *v, int size)
{
int i;
unsigned char *p = (unsigned char *) v, q;
for(i=0; i<size/2; i++) {
q = p[i];
p[i] = p[(size-1)-i];
p[(size-1)-i] = q;
}
}
What is a simple program to controls screen movements?
Aug 1 11:15:14 1997
The curses library routines give the user a terminal-independent method
of updating character screens with reasonable optimization. Here's a trivial
example of a C program that uses the curses library.
% cc -o test test.c -lcurses -ltermcap
% cat test.c
/*******************************************************************
*** test: Uses the curses library to move a curser on the screen.
*** Kalle Hoffman
*** (831) 458-0685
*** Aug 1 11:15:14 1997
*** www.kalle.com
*** kalle@kalle.com
*******************************************************************/
#include <curses.h>
main() {
int col=0, line=0, c=0;
initscr(); cbreak(); noecho(); /* init curses and screen */
do {
mvprintw(line, col, " "); /* clear old curser */
switch (c) {
case 'k': line--; break; /* up */
case 'j': line++; break; /* down */
case 'h': col--; break; /* left */
case 'l': col++; break; /* right */
}
mvprintw(line, col, "%02d,%02d", line, col);
refresh();
} while ((c=getch()) != 'q');
move(LINES-1, 0); /* leave curser in lower left corner */
refresh();
endwin();
return 0;
}
How do I copy a directory while preserving links, owner id,
group id and timestamps?
Mon Jul 7 12:04:42 1997
The GNU copy command (cp) supports the -a (archive) option
which preserves as much as possible of the structure and attributes of the
original files in the copy. This includes: copying symbolic links as
symbolic links rather than copying the files that they point to,
preserving hard link relationships between source files in the copies,
preserving the original files' owner, group, permissions, and timestamps,
and copying directories recursively (copying all nondirectories as if they
were regular files).
% cp -a SRC_DIR DEST_DIR
The Solaris 2.5 copy command (cp) supports the -p option which preserves
the owner id and group id, permissions modes, modification, access
time, and ACLs if applicable. WARNING: This command won't copy links as links it
copies the information the link points to.
% cp -rp SRC_DIR DEST_DIR
Another way to preserve file information and soft links when copying is by
using tar.
% mkdir DEST_DIR
% cd SRC_DIR
% tar -cf - . | ( cd DEST_DIR; tar -xvf - )
I have written a shell script
(tarcp.sh) that acts
like cp but uses tar to copy directories. You can get a copy at: ftp://ftp.kalle.com/pub/tarcp.sh
How do I pass a variable number of arguments in c?
Wed Jul 2 18:43:23 1997
#include <stdio.h>
#include <stdarg.h>
void
my_printf(char *format, ...)
{
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
}
How do I add swap space (increase /tmp) on Solaris 2.5.1?
Wed Jul 2 18:13:04 1997
First you'll need to allocate disk space (200 megabytes) on a local disk
(/export/home) and create a swap file (/export/home/SWAP).
# mkfile 200m /export/home/SWAP
Then tell the memory manager about the new swap space.
# swap -a /export/home/SWAP
Last so the new swap space will be used the next time the system
is rebooted update /etc/vfstab.
Make sure the new swap entry comes after the disk it's allocated on.
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#======== ======= ====== ==== ==== ======= =======
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c1d0s1 - - swap - no -
/dev/dsk/c1d0s0 /dev/rdsk/c1d0s0 / ufs 1 no -
/dev/dsk/c1d0s6 /dev/rdsk/c1d0s6 /usr ufs 1 no -
/dev/dsk/c1d0s7 /dev/rdsk/c1d0s7 /export/home ufs 2 yes -
swap - /tmp tmpfs - yes -
/export/home/SWAP - - swap - no -
Where are the most useful search engines on the net?
Thu Jun 5 10:35:25 1997
Where can I get precompiled utilities like gcc, tcsh, and elm for Solaris 2.5 sparc and x86?
Thu Apr 22 15:22:38 1999
How do I get a Solaris 2.5.1 box to
revert to a "blank" system?
Thu Jun 5 10:16:17 1997
The way you can make a machine not have a name or know about other
systems or networks is with sys-unconfig.
Sam Rafter
adds that a problem with sys-unconfig is that it removes the root
password and if the machine was built from a server
(as opposed to CDROM), it doesn't unconfig properly.
# sys-unconfig
How do I configure a Solaris 2.5.1 box to talk to a network?
Thu Jun 5 10:36:41 1997
First see blanking your system. Then you'll need to put the
IP address of your systems default router or Gateway in
/etc/defaultrouter. Put the domain name and DSN
name servers IP address in /etc/resolv.conf. And you'll need
to add dns to the hosts line of /etc/nsswitch.conf.
Here's an example of files on a solaris 2.5.1 x86 box on a
network of NT machines.
192.122.209.42
/etc/resolv.conf
domain kalle.com
nameserver 192.122.209.43
nameserver 192.122.209.44
/etc/nsswitch.conf
passwd: files
group: files
hosts: dns files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files
netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files
How do I set up a trash directory so I can unremove files on UNIX using csh?
Thu Jun 5 10:56:58 1997
Set up these aliases in your .cshrc and do the mkdir once.
% mkdir ~/.trash
% alias urm "mv ~/.trash/\!* ."
% alias rm "mv -f \!* ~/.trash"
% alias check "ls ~/.trash; du -s ~/.trash"
% alias empty "/bin/rm -fr ~/.trash/{,.}*"
What can't I ftp to a Solaris 2.5.1 box when my login shell is tcsh?
Thu Jun 5 11:11:56 1997
The solaris ftp daemon (in.ftpd) authenticates users according
to the following rules:
- If the user name is "anonymous" or "ftp", an
entry for the user name ftp must be present in
the password and shadow files. The user is then
allowed to log in by specifying any password
How do I get a new disk formatted, mounted, and exported on a Solaris 2.5.1 box?
Thu Jun 5 11:19:04 1997
Turn your machine off and install the disk.
In order to get Solaris to reconfigure your new hardware configuration
you'll need to boot Solaris with the reconfigure option at the boot prompt.
Some people like to do this operation in single user mode, you can do this by
using the -s option.
# b -r
When the machine boots login as root and
run the format command to partition the new device.
# /etc/format
format> fdisk
format> label
format> partition
format> quit
Now run newfs on the raw device. Here's an example of a disk on scsi controller 0,
target 1, slice 0.
# /usr/sbin/newfs /dev/dsk/c0t1d0s0
Now edit the /etc/vfstab file so that the device will mount at boot time.
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#======== ======= ====== ==== ==== ======= =======
fd - /dev/fd fd - no -
/proc - /proc proc - no -
/dev/dsk/c1d0s1 - - swap - no -
/dev/dsk/c1d0s0 /dev/rdsk/c1d0s0 / ufs 1 no -
/dev/dsk/c1d0s6 /dev/rdsk/c1d0s6 /usr ufs 1 no -
/dev/dsk/c1d0s7 /dev/rdsk/c1d0s7 /export/home ufs 2 yes -
swap - /tmp tmpfs - yes -
/dev/dsk/c0t1d0s0 /dev/rdsk/c0t1d0s0 /export/home1 ufs 2 yes -
If you want the device exported put the following in the dfstab file.
share -F nfs /export/home1
Now reboot the machine and the device will be mounted when you login.
# sync; sync; sync;
# reboot
How do I share file systems without rebooting on Solaris 2.5?
Tue Feb 27 16:44:26 1996
It turns out that if /etc/dfs/dfstab is empty, nfsd and mountd are not
started at boot time, so any share commands will not take effect. If
you want to access files from a system that is not currently exporting
any filesystems, you will have to explicitly start the nfs and mount
daemons. Then the share command will make /export/home available for
mounting by other machines.
# /usr/lib/nfs/nfsd -a 16
# /usr/lib/nfs/mountd
# share -F nfs /export/home
Copyright © 1995-2022 Kalle Hoffman - All Rights Reserved.