Debianhelp.co.uk

Debian Tips in filesystems,boot,security,graphics and storage devices

How to convert existing ext2 partition to ext3?

Ext3 is a journaling file systems, and you can look at it as ext2 plus journalling. First create a journal for your file system using, tune2fs -j /dev/hdaX You can do this on a mounted or an unmounted filesystem. If you create the journal on a mounted filesystem you will see a .journal file. Do not try to access this journal file.

You can now edit your /etc/fstab to change 'ext2' to 'ext3' or mount your filesystem as ext3 using,mount -t ext3 /dev/hdaX /mnt/ With mke2fs -j /dev/hdaX you can format a raw partition as ext3. You can then mount this as ext2 as well. Just check if you have the line ext3 in the file /etc/mkinitrd/modules.

How to convert ext3 partition back to ext2?

You can just change your mount type as 'ext2'. But if you really want to make it a 'ext2', unmount the file system and do,
tune2fs -O ^has_journal /dev/hdaX Force an fsck to be on the safer,fsck.ext2 -f /dev/hdaX Get rid of the .journal file, as that doesn't do any purpose now.

How to setup /etc/vfstab file for the ext3 file system ?

Instead of just specifying the new file system as ext3, enter it as "ext3, ext2". This instructs the kernel to first try mounting as ext3. If that doesn't work for any reason, it gets mounted as ext2 (atleast!). For fsck to understand this convention, you must make a link in /sbin/ext3,ext2 to /sbin/ext2. This may sound ugly - but there is no other way.

How to avoid fsck prompts during the boot sequence?

Write 'FSCKFIX=yes' in /etc/default/rcS. You will not face the fsck problem from the next reboot onwards. However, if the disk is corrupted very badly, your presence may be required. I had done some kernel tweaks also for that. I will write  about in subsequent tips.

How to mount my windows share on Linux using samba?

Have this line in your /etc/fstab //Server/ShareName /home/ServerShare smb username=user,password=password 1 2
This would work in a home environment, where you don't mind putting the password in fstab file. If you want to be cautious, have a script ask for your password and mount the stuff using smbmount command. However, if you like to do this as non-root, specify the mount point option in /etc/fstab alongwith noauto and user options.

Disabling 'shutdown' with Cntl+Alt+Del

If you get annoyed, when you accidentally rebooted the system by pressing the three magic keys, comment out this line in /etc/inittab as,ca::ctrlaltdel:/sbin/shutdown -t3 -r now You may alternatively allow specific users with this capability by changing the line as below and adding the specific login ids in '/etc/shutdown.allow',ca::ctrlaltdel:/sbin/shutdown -a -t3 -r now

Console getting fluded with messages during Error messages on the console screen

By default /etc/syslog.conf is set to overwrite the console screen. Edit the last (or appropriate) part of this file to change this behaviour.You may also run "dmesg -n1" to quiet on-screen error messages.

I cannot boot the system

No problem, even if you didn't bother to make a boot disk during install. If lilo is broken, grab the boot disk from the Debian installation set and boot your system from it. At the boot prompt, assuming the root partition of your Linux installation is on /dev/hda12 and you want runlevel 3, enter:

boot: rescue root=/dev/hda2 3

Then you are booted into an almost fully functional system using the kernel on the floppy. There may be minor glitches due to lack of kernel features or modules.

Debian PC doesn't power-off on shutting down?

Well, you are not a lone user coming to this problem. Make sure of all these things first-

• Check your motherboard for APM support
• Your kernel is compiled with the APM support and the 'real-mode flag' is enabled
• For 2.2 kernels add the "apm=on" flag in the /etc/lilo.conf (for append="" secion) or pass at the boot time
• For SMP kernels add the "apm=power-off" also in /etc/lilo.conf or pass at the boot time
• For 2.4 kernels, do "insmod apm power_off=1"
• Use the appropriate command like poweroff or shutdown -h to shutdown your system. If you use ctr-alt-del on the command line, change the line in /etc/inittab to begin with 'ca:'
• If you still can't make it work, try using ACPI instead of APM (only for 2.4 kernels). ACPI does not need any other boot parameters

How to add have my own file get executed during the boot sequence?

Create the file in /etc/init.d/, give executable permissions and run "update-rc.d" with appropriate arguments to create the links from various run levels.

How do configure (add or delete) start-up services on debian?

Use "rcconf" and unselect or deselect your choices.

Having trouble in setting your system time?

Most probably you are not running the 'hwclock' after changing the date. Do this sequence,date MMDDhhmmCCYY; hwclock --utc; hwclock --systohc; hwclock --show Alternatively, if you have internet connection do a ntpdate <server>

Do you know of make oldconfig?

If you just applied a patch to your kernel and would like to use the newly added options, this option is very useful if you don't want to spend an hour hitting Enter through all your settings. oldconfig will take current settings as defaults, and prompts for any new options that may have appeared in this version of the kernel.

How to set default compiler options for gcc, for all the programs you compile on your system?

Have these lines in your ~/.bash_profile or /etc/profile as per your needs.
export CFLAGS=" -O3 -march=i686 -mcpu=i686"
export CXXFLAGS=$CFLAGS (for C++ stuff to compile with the same optimizations)

How to make use of my "windoze" keys on my keyboard?

Add these lines in your ~/.Xmodmap file:
keycode 115 = F13
keycode 116 = F14
keycode 117 = F15
Now add the following line to .xsession: modmap ~/.Xmodmap. Restart your window manager and now your F13, F14 and F15 keys represent the left-Win key, right-Win-key and context-menu key.

How to have the special multimedia keys on my keyboard get working in X?

Lot of the newer keyboards like Microsoft Natural Pro have lot of multimedia keys, which can be programmed. You can either create Xmodmap entries for the keys if you know the keyboard configuration or use the hotkeys package (.deb available).

How to transform the "\n" character between Unix and Msdos formats?

Use "flip" (apt-get install flip, if you don't have it already). You may use this on text or binary files.
A tip on your system security, consider removing "/etc/hosts.equiv"

This file allows other hosts to be trusted by your system. It can be used to log on to your machine without a password. If you are not running "r" commands, you should have no use for this file and it should be removed. Also, disable 'r' programs like rlogin, rsh and use ssh and scp.

How to look at the log files for 'su' usage?

grep "su.*-root" /var/log/auth.log

Can't play the audio CD while logged into Gnome as user, since only root can mount the /dev/cdrom?

If you have 'linuxconf' installed, select the drive you want to access in the 'Access local drive' section. In the Options tab select the User Mountable option. Alternatively, give mount permissions to the user in /etc/fstab as - (add 'user' in the fourth column)

/dev/cdrom /mnt/cdrom iso9660 user,exec,dev,ro,noauto 0 0

Why don't I see long filenames of my Windows CD-ROM on Linux?

If you can see the long filenames of your cd-rom under Windows but not under Linux, it may be formatted using Microsoft's proprietary Joliet filesystem. It allows for long filenames encoded using the 16-bit UNICODE format. You just need to enable the flag for 'Microsoft Joliet file system extensions' in your kernel configuration. If you want to display filenames with native language characters from Joliet CD-ROMs correctly on the screen, you need to enable support in the kernel for the appropriate NLS ISO8859 character sets.

How to read the volume label of my CD-ROM?

You may either use the utility called volname or run,
dd if=/dev/hdc bs=1 skip=32808 count=32 (use appropriate device name)

How can I tell the speed of my CD-ROM device?

This is only an approximate way of telling: This command measures how long is takes to read 3000K of data from CD:
time -p dd if=/dev/cdrom of=/dev/null bs=1k count=3000
3000+0 records in
3000+0 records out
real 7.18
user 0.03
sys 5.07
The transfer rate of single speed drives is 150 kilobytes per second, which should take about 10 seconds. At double speed it would take five seconds, quad speed would take 2.5, etc. The "real" time above is probably the best number to look at -- in this case it indicates a double speed drive. For better results, increase the amount of data or run multiple iterarion for a better approximate value.

Want to duplicate a VCD from another VCD?

cdrdao read-cd --paranoia-mode 2 --read-raw --driver generic-mmc --device 0,0,0 data.toc

How do I get my CD-Recorder (CD-RW) get to work?

Scan for CD Recorders on your system with cdparanoia -Qsv once. This might give any information on the available CD recorders on the system. Also read the man pages of cdrecord, mkisofs, cdda2wav, cdparanoia.

• Make sure that the modules sg and ide-scsi are installed in the kernel with modconf or insmod. Also have these files available on your system: cdrecord, mkisofs, cdda2wav or cdparanoia
• If SCSI device, add or edit this into /etc/lilo.conf append = "idebas=33 hdd=ide-scsi max_scsi_luns=1. Run lilo once.
• create the directory /cdrw
• Edit your /etc/fstab to mount the device (scd0 or hdd) to /cdrw
• Create any synbolic links to, /dev/cdrw
• cdrecord -scanbus and verify