On Wed, Jan 18, 2006 at 11:55:15PM -0800, Jacob Meuser wrote: > On Thu, Jan 19, 2006 at 08:17:15AM +0100, Karl-Ludwig Reinhard wrote: > > hello list, > > > > I'm looking for a openbsd live cd for sys admins, but the only thing > > I've found was the anonym.os. Is there any other live cd based on > > openbsd? > > >
My personal "man livecd" If anybody thinks something is wrong with it please tell me, I'm eager to learn :) Hint this is optimized for vim, tw=80 and syntax highlighting set to "CONF". # live_cd OpenBSD 2006.01.19 Since there isn't (unfortunately) an official OpenBSD Live CD we will create one: We need a current system and create a release with source code -> release # Alternatively you could use OpenBSD stable/release if you have the source code # available Create a directory, this will become root '/' on the CD. # NOTE: If there is not enought free space on '/usr/' you have to choose a # different directory (of course you can do so anyway) and change the paths in # all following commands accordingly "mkdir -p /usr/livecd/backups/dev" # COMPLICATED way SKIP this! (Life is to short for this kind of stuff!) #------------------------------------------------------------------------------- #Nun muss das gesamte root System, welches in der Release Tarballs enthalten ist #in das livecd Verzeichnis entpackt werden: #"cp baseXX.tgz /usr/livecd/ && cd /usr/livecd/ && tar pxzf baseXX.tgz" # Dies ist f|r alle gew|nschten Teile des Systems zu wiederholen! ## WICHTIG! #Weitere Dateien anpassen: #"etc/motd" "etc/mygate" "etc/myname" "etc/sysctl.conf" "etc/rc.conf" #"etc/defaultdomain" # #Tastatur Layout: #"etc/kbdtype" # #F|r Netzwerkkarten vorsorgen: #"etc/hostname.*" "etc/resolv.conf" # #Hosts: #"etc/hosts" # #Timezone: #"rm etc/localtime && ln -s usr/share/zoneinfo/Europe/Berlin etc/localtime" #Benutzer anlegen: ## Am einfachsten: #Auf "Host System" den Benutzer, Gruppe anlegen und diese Eintrage per #Cut/Paste in "/etc/group" und "/etc/master.passwd" einf|gen. #-> afterboot # ssh , etc. #-> sicherheit #Packete hinzuf|gen ? #------------------------------------------------------------------------------- # Simple way to get this done Grab an empty hard drive and make a fresh nice and SLIM install of OpenBSD. As said above you need the source code to the version you install! # HINT: Against all good practices ONLY create an 'a' partition since it will # make creating the CD much more easier than having multiple partions. This includes all packages/ports you want to be on the CD. You should configure the system EXACTLY like you want it to be on CD. # WARNING: # The settings should be fairly generic, especially /etc/X11/xorg.conf should # use the vesa driver and a resolution of "1024x768"! Now mount this partition with another OpenBSD system in order to create a (compressed) tar archive. # NOTE: Do not forget the 'p' flag! "cd /mnt/ && tar pczf ~/livecd_root.tar.gz *" We transfer this archive to our build machine and extract into our livecd directory we created earlier: "tar pxzf livecd_root.tar.gz -C /usr/livecd/" We have to copy "/var", "/etc", "/dev", "/root" and "/home" from "/usr/livecd" to "/usr/livecd/backup": # WARNING: Delete the "shell history", "vim info" and other documents we might # NOT want to have on our CD: "cd /usr/livecd && rm -i {root,home/*}/{.history,.viminfo} " "cp -pR /usr/livecd/{var,etc,root,home} /usr/livecd/backups/" "cp -pR /usr/livecd/dev/MAKEDEV /usr/livecd/backups/dev/" # WARNING: Check for permission issues in livecd directory Since a CD is not huge we will compress the "backup" directories into compressed tar archives: # NOTE: This is ONE long command line, you could split it into several steps "cd /usr/livecd/backups && \ tar pzcf var.tar.gz var && \ tar pzcf etc.tar.gz etc && \ tar pzcf dev.tar.gz dev && \ tar pzcf home.tar.gz home && \ tar pzcf root.tar.gz root/.[a-z]* && \ rm -rf /usr/livecd/backups/{var,etc,dev,home,root}" We have to create virtual partitions in memory (MFS) since we want them to be faster and more importantly writeable. On boot the content extract of the archives under "/livecd/backups" is extract into them. We have to modify the "etc/rc" script in order for this to work: --------------------------- /usr/livecd/etc/rc --------------------------------- # Insert this AFTER # rm -f /fastboot # XXX (root now writeable) # Create/mount mfs partitions echo 'mounting mfs' mount_mfs -s 51200 -o async,nosuid,nodev,noatime swap /var mount_mfs -s 6144 -i 4096 -o async,nosuid,nodev,noatime swap /etc mount_mfs -s 2048 -i 128 -o async,noatime swap /dev mount_mfs -s 6144 -o async,nosuid,nodev,noatime swap /tmp mount_mfs -s 8192 -o async,nosuid,nodev,noatime swap /home mount_mfs -s 8192 -o async,nosuid,nodev,noatime swap /root # Seems that a short break is necessary here sleep 2 # Copy over all stuff in mfs partitions echo -n 'copying files: var ' tar pzxf /backups/var.tar.gz -C / echo -n 'etc ' tar pzxf /backups/etc.tar.gz -C / echo -n 'dev ' tar pzxf /backups/dev.tar.gz -C / echo -n 'home ' tar pzxf /backups/home.tar.gz -C / echo -n 'root' echo '.' tar pzxf /backups/root.tar.gz -C / echo 'creating device nodes' cd /dev && sh MAKEDEV all # Set correct permissions for tmp dirs test -d /var/tmp && chmod 1777 /var/tmp test -d /tmp && chmod 1777 /tmp # Insert this AFTER # if [ -f /sbin/kbd -a -f /etc/kbdtype ]; then # We need a root Password echo 'Need to set a root password' passwd # We need a password for our default user as well echo "Need to set a password for default user 'ahblive'" passwd ahblive # Insert this at the very END # Start X environment? echo 'Do you want to have a [G]raphical environment or [C]onsole only?' read ans if [ "$ans" == "G" -o "$ans" == "g" -o "$ans" == "Graphical" ] ; then xdm fi -------------------------------------------------------------------------------- Create devices we need to boot # NOTE: not all of them would be necessary, but they don't hurt either since # we mount a mfs partition on the real /dev and create devices on boot "cd /usr/livecd/dev && ./MAKEDEV all" # WARNING: As said several times use the source MATCHING YOUR BINARIES! # Bad things will happen if your kernel is not in sync with userland! Now we need to compile a modified GENERIC kernel that is able to boot from CD, we also have to compile it with RAMDISK "cd /usr/src/sys/arch/$arch/conf" # NOTE: Only tested for i386, amd64 "mv RAMDISK_CD RAMDISK_CD.old && cp GENERIC RAMDISK_CD" ------------------- /usr/src/sys/$arch/conf/RAMDISK_CD ------------------------- ... # config bsd swap generic < - we have to comment this one out option RAMDISK_HOOKS option MINIROOTSIZE=3800 config bsd root on cd0a ... -------------------------------------------------------------------------------- Compile the modified kernel: "config RAMDISK_CD && cd ../compile/RAMDISK_CD/ && make clean && make depend && make" -> kernel_compilieren Copy the compiled kernel in the root directory of livecd: "cp bsd /usr/livecd && chown root:wheel /usr/livecd/bsd && \ chmod 644 /usr/livecd/kernel" Apply this patch to the {i386,amd64} "Makefile.inc": # NOTE: You MIGHT have to adjust it since the line numbers may have changed over # time. As you see you HAVE to adjust it for amd64 as well! --------------------------- patch-livecd.inc ----------------------------------- --- Makefile.inc.orig Thu Nov 25 23:02:08 2004 +++ Makefile.inc Thu Jan 19 13:57:49 2006 @@ -33,8 +33,7 @@ newfs -m 0 -o space -i 524288 -c 80 ${VND_RDEV} mount ${VND_DEV} ${MOUNT_POINT} cp ${BOOT} ${.OBJDIR}/boot - strip ${.OBJDIR}/boot - strip -R .comment ${.OBJDIR}/boot + strip -s -R .comment -K cngetc ${.OBJDIR}/boot dd if=${.OBJDIR}/boot of=${MOUNT_POINT}/boot bs=512 dd if=bsd.gz of=${MOUNT_POINT}/bsd bs=512 /usr/mdec/installboot -v ${MOUNT_POINT}/boot \ @@ -54,8 +53,7 @@ bsd.gz: bsd.rd cp bsd.rd bsd.strip - strip bsd.strip - strip -R .comment bsd.strip + strip -s -R .comment -K cngetc bsd.strip gzip -c9 bsd.strip > bsd.gz bsd.rd: ${IMAGE} bsd rdsetroot -------------------------------------------------------------------------------- Apply by doing: "cd /usr && patch -p0 < patch-livecd.inc" We need "crunch" to be installed: "cd /usr/src/distrib/crunch && make obj depend all install" Create the boot image used for the CD: # WARNING: /dev/svnd0c MUSN'T be in use for this step! "cd /usr/src/distrib/i386/ramdisk_cd && rm -rf obj/* && make" # We have to delete "obj" directory --------^ # otherwise it will not be updated (BAD!) Copy the successfully created boot image to livecd directory: # NOTE: XX is the version like 38 "cp /usr/src/distrib/i386/ramdisk_cd/obj/cdromXX.fs /usr/livecd/" We have to modify these files in order to be able to boot: ----------------------- /usr/livecd/etc/fstab ---------------------------------- /dev/cd0a / cd9660 ro,noatime 0 0 /dev/cd0a / cd9660 ro,noatime 0 0 swap /dev mfs rw,noatime,-s=12000 0 0 swap /tmp mfs rw,noatime,-s=262144 0 0 swap /var mfs rw,noatime,-s=262144 0 0 swap /root mfs rw,noatime,-s=262144 0 0 swap /home mfs rw,noatime,-s=262144 0 0 swap /etc mfs rw,noatime,-s=131072 0 0 -------------------------------------------------------------------------------- # This is optional, but think about if bevore going on -------------------- /usr/livecd/etc/ttys -------------------------------------- # You might want to have the serial console activated console "/usr/libexec/getty Pc" vt220 off secure # otherwise keep default settings tty00 "/usr/libexec/getty std.9600" vt100 on secure local -------------------------------------------------------------------------------- Finally we can create the CD .iso image: "cd /usr/livecd" # NOTE: Again XX stands for the version like 38 "mkisofs -vrTJV 'OBSDLive' -b cdromXX.fs -c boot.catalog -R -o /tmp/livecd.iso /usr/livecd" Burn the image as usuall: -> cdrecord Regards, ahb