Wednesday, June 28, 2006

 

Modifying the kernel's make install initrd image

# Login as root
# mkdir myinitrd
# cd myinitrd
# gzip -dc < /boot/initrd-your-version-here.img | cpio -i
# edit init do what you want at the top of the script. Usually custom scripts added after mounting /proc but before mounting any drives
# find . | cpio -o -c |gzip -9 > /boot/initrd-your-version-here.img

Tuesday, June 27, 2006

 

Single Writer Multiple Readers using Anonymous Pipes

Use the tee command. Here is an example where I use pipes and the linux cut/paste command to implement a windows like "scanning wireless networks available" in linux.



scan_nets(){
echo "Going to scan nets"
rm -rf *.trace
iwlist $wintf scanning | tee >(grep "ESSID" |cut -d ':' -f 2 > essid.trace ) >(grep "Encryption"|cut -d ':' -f 2 > enc.trace ) | (grep "Quality"|cut -d '=' -f 2 > quality.trace)

paste -d " :" essid.trace enc.trace <(cut -d " " -f 1,3 quality.trace) > table
availnets=`cat table`

selected_net=$($DIALOG --stdout --title "Scanned Networks Available. " --radiolist "Press Cancel to enter your own ESSID

ESSID Encypted? Signal Strength" 18 45 12 $availnets)
retval1=$?
case $retval1 in
0)
echo "Input string is $selected_net";;
1)
echo "Cancel pressed.";;
#No problem will prompt for essid later
255)
$DIALOG --no-close --no-buttons --title "Disable Network" --infobox "User Interrupt going to disable the network" 8 32 10
;;
esac
}


Saturday, June 10, 2006

 

Creating symbolic links for bootup scripts

If you want to startup a certain service e.g. vmware in runlevel 4 during system bootup.

cd /etc/rc4.d
ln -s ../init.d/vmware S90vmware

The S (as apposed to K) signifies that you want this script to run and the 90 determines the order of being called in this folder.

Friday, June 09, 2006

 

Coping folders between Machines

Make sure you ssh/scp deamon is running.
/etc/init.d/ssh start

Regenerate host keys for ssh if necessary
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

package your folder
tar -cvf folder.tar folder | gzip > folder.tgz

copy it
scp folder.tgz root@192.168.1.5:/home/anwar/myfiles

extract it
gunzip folder.tgz
tar -xvf folder.tar

Alternatively you can also use
smbmount //ipaddress/path/to/folder /mountfolder -o username=anwar

 

Linux Managing multiple Network interfaces

If you have multiple network interfaces on your machine e.g. a wireless (check using iwconfig) and wired. i.e. eth0 and eth1. Linux will end up using the first one it finds. In order to use the interface of your choice, you can disable one or the other.

ifconfig eth1 down and force the other to take over using the pump command.

# pump -i eth0 --status
Check the status / get details of dhcp on eth0

# pump -i eth0 --release
Release dhcp IP on eth0

# pump -i eth0
Request a dhcp ip for eth0

Wednesday, June 07, 2006

 

Setting up Knoppix file system on a hard drive

A Knoppix installation on you hard drive will use unionfs by default. You can check to see which folders are part of the unionfs tree by using the mount command and you can add more folders via
mount -t unionfs -o dirs=/ramdisk=rw:/KNOPPIX=rw unionfs /

Normally you can only write in the /KNOPPIX folder and therefore you will need to remount it to be writable via
mount -o remount, rw /KNOPPIX/

Another thing you might want to do is chroot /KNOPPIX/ so that you don't confuse / with /KNOPPIX

Before chrooting you can mount the /proc and /dev to the new folders.
mount -o bind /proc /KNOPPIX/proc

Tuesday, June 06, 2006

 

Setting up and Formatting encrypted Partitions

losetup -e AES128 -T /dev/loop7 /dev/sda7

format
mke2fs -j /dev/loop7

Monday, June 05, 2006

 

changing & formatting partitions

I prefer using cfdisk over fdisk because it is menu driven. Usually creating a partition table will involve a hda1 primary boot partition followed by a extended partition hda5 (linux), hda 6 (swap) and so on.

format boot via
mkfs.vfat -F 16 -n NAME -v /dev/hda1

format linux via
mke2fs -j -L KNOPPIX /dev/hda5

turn off filesystem checking via
tune2fs -c 0 /dev/hda5

set up swap via
mkswap /dev/hda6

changing a label of partition after you put your data on it
tune2fs -L NEWLABEL /dev/hda5

Friday, June 02, 2006

 

Disk Space Remaining

df -h

and

du -hsc

 

Mounting a compressed image

Needed when mounting a compressed KNOPPIX file found in the linux boot partition. For instance you need to recover some USB modules to place directly in miniroot.

insmod cloop.o file=/path/to/compressed/image

mount -o ro -t whatever /dev/cloop /mnt/compressed

This page is powered by Blogger. Isn't yours?