KNOPPIX TRICKS - Linux Magazine
  • No tags were found...

KNOPPIX TRICKS - Linux Magazine

Practical KnoppixCOVER STORYExpert techniques for getting more from KnoppixKNOPPIX TRICKSKnoppix creator Klaus Knopper shares some tips for using Knoppix inthe real world. BY KLAUS KNOPPERKnoppix is a full Linux system ona removable disk. You can plugyour Knoppix disk into almostany Intel-compatible computer and bootKnoppix – regardless of what system ison the hard drive. But unlike manybootable Linux distros, Knoppix is notintended simply as a demo system orrecovery disk. Knoppix is a real Linuxdistribution capable of many of theeveryday chores you would commonlyexpect of a hard-disk Linux.Of course, most people think of a livedistro as a tool for troubleshooting anddata recovery, and Knoppix is certainlyused for these tasks, but Knoppix is alsocapable of some equally essential butless exotic assignments.Slip your Knoppix disk into the CD orDVD drive, and start your computer. Thesystem boots much the same as anyother Linux system. (See the box titled“Booting Knoppix.”) Once you havestarted the system, Knoppix looks prettymuch like a “normal” and preconfiguredDebian installation, apart fromsome automatic scripts thatcreate Desktopicons for newly plugged-in USB devicesand the automounter taking care of CD-ROMs. But is it the same?The fact that the operating system isrunning from a read-only medium makessome tasks more difficult – but not asdifficult as you might think. In this article,I’ll describe how to use Knoppix forpractical tasks such as:• installing a new program• burning CDs• writing to NTFS partitionsThese techniques give Knoppixa power and versatility youmay not expect from a livedistro, and once youmaster some ofthese tasks, youmay find yourselfdiscoveringnew ways to make Knoppix part of youreveryday life with Linux.Installing New ProgramsWith Knoppix 3.8, a new feature wasintroduced that made remastering Knoppixeasier and added capabilities youwould probably not expect in a systemdesigned to run from a read-onlymedium: unionfs.W W W. L I N U X- M A G A Z I N E . C O M21

COVER STORYPractical KnoppixA workaround for the update-menuscase could be just removing that commandusing the unionfs “delete a filefrom an originally read-only CD” featureby just doing asudo rm -f U/usr/bin/update-menuswhich will have the (in this case desirable)side effect of no longer automaticallyupdating the KDE menus.Also, minor bugs (like missing executepermissions for cdrecord in Knoppix4.0.1) can be fixed on-the-fly withoutburning a new DVD by just modifyingthe unified live system withsudo chmod 755 U/usr/bin/cdrecord*Figure 1: If you don't like working from the command line, you can burn a CD with k3b.Basically, what unionfs does is to“simply” merge directories. Example:You can merge a read-only directory(like a mounted CD-ROM) at /KNOPPIXand a read-write but empty, writableramdisk directory at /ramdisk, to createa read-write and pre-populated/UNIONFS directory that’s fully writable.In previous versions of Knoppix, therewas a strict separation between readonlydata and writable data, and symlinkswere used to put files where theywere expected in the individual directories.This system worked well, though itwas complicated to maintain since, forevery program added to Knoppix, youcdrecord PermissionsRemember the problem with wrongcdrecord permissions in Knoppix 4.0.1that I mentioned above? To avoidunpleasant surprises, you should double-checkthat all /usr/bin/cdrecord*instances are executable by the Knoppixuser (well, just run “cdrecord” in theshell), and fix the programs permissionsin case they are wrong, usingsudo chmod a+x U/usr/bin/cdrecord* U/usr/bin/growisofsNow we should be able to burn with allprograms that use cdrecord (for CDs) orgrowisofs (for DVDs), such as k3b,which is integrated in the KDE menus.had to figure out which files were supposedto be written to and copy them tothe ramdisk with a symlink on the readonlyarea.Since unionfs now takes care of copyingchanged data to the ramdisk directoryand also (seemingly) allow you todelete files on a read-only CD or DVD,you can just add your own stuff to thelive system as if it were installed on aregular hard disk.So, in theory, to install a new Debianpackage from the Debian mirrors listedin /etc/apt/sources.list, we would onlyneed to run (as root)apt-get updateapt-get install pingusIn fact, this should work on many Knoppixversions without major problems.However, unionfs is at an early stage ofdevelopment, and while the basic fileoperations like create, copy, rename,delete on a joined file system work fine,there are some known bugs and issueswhen overwriting or locking files, whichis unfortunately done A LOT by programslike update-menus that run automaticallyafter a program is installed. So,should you see a unionfs-related Kernel“Oops” in the output of the dmesg commandafter installing new software orupdating configuration files, this is probablycaused by a bug in unionfs.It almost makes you forget that you areworking without a writable harddiskwhen running from a CD.For large and lengthy program downloadsand installations, the “persistentKnoppix image” feature comes in handy.The persistent image feature does theCopying a Data CD or DVDfor BurningJust copying a data CD or DVD into anISO file for later burning is easy:cp /dev/cdrom U/mnt/hda2/copy-of-cd.isoTo obtain a copy of a non copy-protectedaudio CD, you would do the following.Of course, you alone mustdecide if this is consistent with applicablecopyright laws of the nation whereyou reside:cd /mnt/hda2cdrdao read-cd --device U/dev/hdc --driver Ugeneric-mmc-raw --eject Umy-cd.tocYou can burn the CD later with:cdrdao write --device U/dev/hdc --driver Ugeneric-mmc-raw --eject Umy-cd.tocOf course, fans of the graphical environmentcould just as well use k3b for thispurpose (which will call cdrecord/ growisofsanyway). You just have to find theright buttons and switches.22 ISSUE 60 NOVEMBER 2005 W W W. L I N U X- M A G A Z I N E . C O M

Practical KnoppixCOVER STORYsame thing the overlaid ramdisk does,just using an ext2 image on the harddisk instead of a ramdisk, and thuscreating a persistent snapshot of thechanges done to the CD or DVD system.You can create this persistent image,containing all changes to the system, bycalling mkimage-knoppix from the Knoppixmenu under Create persistent Knoppiximage. For the case of an NTFS partition,since we cannot directly write toNTFS with the Linux kernel driver, asmall Windows program called mkimage.exeis provided inside the KNOPPIXdirectory on the uncompressed part ofthe CD or DVD.Once the persistent image has beencreated,it has a constant size (like a virtualharddisk.) You should not make theimage too small. The ideal size for theimage depends on how much you intendto install or save to the writable part ofthe image. If you configure a printer,install one or two small programs, andexecute OpenOffice once, you willalready have used up 100MB or more.Once you have created a persistentimage on hard disk (or USB memorystick), the image is overlaid with theread-only DVD or CD on the next reboot,Figure 2: Knoppix 4 lets the user create a persistent disk image.if you accept the boot option for usingthe image. Everything you change orsave is automatically kept inside thereset-proof image.One very important thing you need toremember about this procedure is thatthe image should be cleanly unmounted.In other words, a regular shutdown isrequired to make sure that the data fromLinux’s ramcache really is written. Incase of emergency, a sync commandwould possibly work in this situation aswell, if you need a really quick rebootusing the computer’s power or reset but-When you boot Knoppix, the following events take place:1. Your computer BIOS loads the isolinux boot loader from CD/ DVD,which displays some background graphics and allows you to gethelp (with F2-F3) or enter kernel options.2. isolinux loads the Linux kernel and a file called minirt.gz, whichcontains a tiny ramdisk with all drivers needed to make hard disksand (most SCSI, USB and Firewire) CD-ROMs/ DVDs accessible inorder to access the main Knoppix compressed file system.3. The kernel starts all builtin drivers (i.e., IDE, SATA), decompressesthe initial ramdisk, and starts the /linuxrc script, which loads evenmore drivers for SCSI, USB and firewire.4. linuxrc mounts the CD/ DVD and loads the cloop transparentdecompression block device module with /cdrom/KNOPPIX/KNOPPIX as the input file (possibly also more cloop files containingadd-ons).5. linuxrc merges the read-only file system layer with a read-writedynamic ramdisk, so now we can change every file in the live session.6. linuxrc ends, init starts and runs some scripts to investigate andmake all linux-supported hardware components usable to the system(/etc/init.d/knoppix-autoconfig).7. The libkudzu-based hwsetup utility loads all drivers correspondingto any hardware found and generates a hardware info file thatis used by mkxf86config to create the setup file for the X server.8. KDE starts.Booting KnoppixADVERTISEMENTW W W. L I N U X- M A G A Z I N E . C O MISSUE 60 NOVEMBER 200523

COVER STORYPractical Knoppixton. But this alternative solution shouldbe an exception.Burning CDs or DVDs usingKnoppixBurning a CD can be difficult if you haveonly One CD- or DVD-writer that isalready used by Knoppix. However, youcan try to free the device by copying thecontents of the Knoppix-CD or DVD tothe hard disk, and just loading the kerneland initrd from the DVD drive, whilerunning the rest from the copy on thehard drive. As of this writing, NTFS partitionsare not supported for this way ofbooting. However, using a FAT32 or ext2partition, you can do this by typing (forthe second partition on the first harddisk on your IDE controller):knoppix tohd=/dev/hda2 dmaat the boot prompt. This command tellsKnoppix to copy all the required files tothe hard disk partition and run fromthere. In the next session, use:knoppix fromhd=/dev/hda2 dmato just reuse the previously copied Knoppixinstead of copying everything again.The dma option speeds up hard diskaccess by about a factor of five for mostboards. If you have a board that does notsupport DMA, however, you should notuse this option, since it can corrupt data.Now, we all know that hardware is evil,incompatible, and badly designed –nothing works as it should. RAM eithermisbehaves or is overclocked, interruptsrun amok, and the I/O address schemefrom the computer stone age is still aliveand kicking in the 21st century. What canwe do if the Linux kernel encounters brokenhardware or badly configured firmware?For example, what if the systemcomes across a BIOS version that is simplynon-functional unless you add a proprietary“system board” driver thatexists only for proprietary operatingsystems?Luckily, the Linux kernel already containsmany automatic workarounds for BIOSsoftware and broken hardware (rememberthe first Pentium CPUs that returnedwrong results for certain arithmetic operations?),so in most cases, Linux will justprint a warning message about activatinga workaround and continue. This isnot possible in all cases – sometimeseverything seems to be detected, but, forexample, the network card is not working,or USB devices are not recognized,or even worse, if PCMCIA devices freezethe entire system when initialized.The following boot command line workswith most broken BIOSes:knoppix nosmp acpi=off Unoapic pnpbios=off pci=biosThe command line options have the followingeffects:• nosmp – switch off multiprocessorand hyperthreading support for theboard (some boards don’t actuallyhave a second processor, but they arekind of schizophrenic and throwerrors, thinking they have).Troubleshooting the Knoppix Boot Process• acpi=off – switch off the automaticconfiguration and power managementfunction of newer boards. Some of theboards simply have a broken BIOSimplementation of ACPI or need specialconfigurations in order to workcorrectly. Some other boards, on theother hand, require acpi=forcebecause they have a broken “fallback”if ACPI isn’t activated.• noapic – If some hardware componentsare correctly detected but justdon’t respond to anything, try this. Itswitches off the “let it look like wehave more interrupts than we actuallyhave to avoid hardware conflicts inproprietary operating systems” chipon some boards. Actually, this featureis not actually as bad or nonsensical asI have just described, but it’s simplybroken on many boards. If you mostlyhave PCI cards that can use interruptsharing, you won’t need APIC. Don’tconfuse APIC with ACPI. It’s not thesame. Both can be broken, independentlyof one another. If you are indoubt, switch both off. Like withacpi=off before, there are boards that,for an unknown reason, won’t workwith noapic.• pnpbios=off – switch off automatic ISA“Plug and Play.” Well, sometimes thishelps if your board thinks it is a goodidea to reserve a lot of interrupts fornon-existing devices or to claim interruptsthat should stay with onboard(PCI-bus) components.• pci=bios – let the BIOS use the userdefinedsettings (like interrupts) foreach device; don’t try to read the interruptconfiguration directly from thespecific device. This works better forolder computers; it just uses what theBIOS knows best about your hardwareconfiguration.There are more options for the bootcommand line: some are direct switchesfor the Linux kernel, and some are justused within the Knoppix hardware detectionscripts. For example, if a graphicscard incorrectly identifies itself as a SCSIcontroller (yes, I have seen this…), thuscausing a system freeze when the“matching” SCSI driver is loaded byKnoppix, and you are confident thatthere is really no SCSI controller in yourcomputer that you would need, try bootingwithknoppix noscsiAlso, you may have to change the screenresolution if your display (as it is the casefor most notebooks) does not supportDDC autodetection of the “favorite” resolutionmodes. The following commandshould work for a 75Hz 1280x1024 TFTdisplay:knoppix screen=1280x1024 Uvsync=75 hsync=90Note that the “text” resolution is alwaysset to 1024x768 by Knoppix, unless youadd the vga=normal option or just thevga= options from thetable shown in /usr/src/linux/Documentation/fb/vesafb.txt.If you are going to use a video projectorfor a presentation, and (did I mentionthat hardware was evil?) the video porton your laptop isn’t working, try theframebuffer-only mode of Knoppix:fb1024x768Note that this boot command line istyped WITHOUT the prefix knoppix thatyou have seen in the example before,mostly because it REPLACES optionsfrom the default line. For some notebooks,you still have to manually activatethe video port with some function keycombination, but if you are in framebuffermode, once you get textmode to displayon the video projector, X/ KDE willwork as well.If you are in the mood to investigatemore of the options that were put intothe Knoppix autoconfiguration whenthey were needed for a special case, seethe KNOPPIX/knoppix-cheatcodes.txt fileon your Knoppix CD.24 ISSUE 60 NOVEMBER 2005 W W W. L I N U X- M A G A Z I N E . C O M

Practical KnoppixCOVER STORY(The possibility of data corruption is thereason this option is not the default inKnoppix, even though very few boardshave this problem.)You can also boot a completely disklessKnoppix over the network. Justlaunch the knoppix terminalserver onone computer on your LAN, and bootanother system via PXE or a networkboot disk that you can fetch from www.rom-o-matic. net for your specific networkcard. For Knoppix 4.0.1, you willneed to fix the knoppix-terminalserverscripts, though, with a hotfix patchavailable on the DVD mirrors.Now that the DVD or CD writer is freefor burning CDs or DVDs, you can startto burn stuff right away. (See the boxtitled “cderecord Permissions.”)You can just burn any directory thatappears in Konqueror by hitting the rightmouse button over the directory iconand selecting burn data CD with k3b.Professional users who prefer the commandline may want to issue the followingcommand in order to create abootable Knoppix DVD from a modifiedcopy on hard disk:growisofs -dvd-compat -Z U/dev/hdc -no-emul-boot U-boot-load-size 4 U-boot-info-table -b Uboot/isolinux/isolinux.bin -c Uboot/isolinux/ -l -r U-J /mnt/hda2/copy-of-Uknoppix-dvd-contentlength. (This option is used by Knoppixfor the persistent Knoppix image, asdescribed earlier in this article.)But recently, the Open Sourcelinux-ntfs library (not the kernel-driver,which is derived from it) has advancedto allow limited write operations on anNTFS partition. Using the current CVSsnapshot of libntfs, you can now:• delete files and directories• create up to 9 new files or subdirectorieswithin a directoryThese options are sufficient for manythings that were not possible before.Since it would be complicated torecompile every program to use libntfsfor write operations (remember, thekernel module is about half a yearbehind libntfs), we can use the FUSEkernel module and an utility called ntfsmountto actually mount an NTFSpartition.Following is a small HOWTO from thecurrent Knoppix DVD, which explainshow to use FUSE and libntfs for mountingan NTFS partition read/ write, so youcan delete or add files with the limitationsmentioned above. Check outKNOPPIX/linux-ntfs/FOR-DEVELOPERS.txt on your Knoppix CD or DVD for this.Please keep in mind that this is still anexperimental feature, so make sure youhave a backup of all your important databefore attempting this:1. Load the “Filesystem in Userspace”module: sudo modprobe fuse2. Make the NTFS partition accessiblefor unprivileged users (in the case ofour example, partition 1 on the slavehard disk attached to IDE controller 2/dev/hdd1): sudo chmod 666 /dev/hdd13. Create a mountpoint in your userhome directory: mkdir $HOME/ntfs4. Mount the partition read/ write into$HOME/ntfs ntfsmount $HOME/ntfs -odev=/dev/hdd1,force,umask=000You should now be able to access thecontents of the NTFS partition at$HOME/ntfs, but don’t forget the nextstep.5. As a normal “umount” is likely to notsucceed with FUSE, use the followingcommand when you are finishedexperimenting: fusermount -u $HOME/ntfsAfter Step 4, you should also be ableto access and browse the NTFS partitionfrom KDE with konqueror $HOME/ntfs/ Be very careful not to mount thesame partition twice, once with thekernel module and again with ntfsmount;otherwise your kernel may getconfused.ConclusionIn this article, I described how to installa program, free the CD-ROM drive, andwrite to NTFS partitions in Knoppix. Ihope these techniques bring you a worldof new possibilities for using Knoppix inpractical situations. ■The preceding command assumes youhave a writable partition /mnt/ hda2 containinga copy of the Knoppix DVD (thefiles, not the ISO) in the “copy-of-knoppix-dvd-content”directory.Writing to NTFS PartitionsAs you may have read, support for NTFSpartitions is more-or-less limited to readoperations, due to patents, licensingissues, and last but not least, the lack ofusable vendor specifications. The existingopen source NTFS read support inthe kernel, created by a lot of workintensivereverse engineering, workspretty well and is good for rescue tasks,such as copying data from a non-bootingsystem to a safe place.The only write operation the kernelntfs driver supports at this point is overwritingfiles without changing theirFigure 3: Use the ntfsmount utility to mount an NTFS partition in Knoppix.W W W. L I N U X- M A G A Z I N E . C O MISSUE 60 NOVEMBER 200525

More magazines by this user
Similar magazines