Saturday, February 16, 2008

How to Obtain BIOS Information Remotely

dmidecode is very useful as it provides the details about your system such as the number of memory slots, BIOS version, etc.

root@V2000# dmidecode
# dmidecode 2.9
SMBIOS 2.31 present.
18 structures occupying 595 bytes.
Table at 0x000DC010.

Handle 0x0000, DMI type 0, 20 bytes
BIOS Information
Vendor: Hewlett-Packard
Version: F.25
Release Date: 03/23/2006
Address: 0xE5BF0
Runtime Size: 107536 bytes
ROM Size: 512 kB
Characteristics:
PCI is supported
PC Card (PCMCIA) is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported

Handle 0x0001, DMI type 1, 25 bytes
System Information
Manufacturer: Hewlett-Packard
Product Name: Presario V2000 (PV340AV#ABA)
Version: Rev 1
Serial Number: XXXXXXXXX
UUID: XXXXXXX-XXXX-XXXX-XXXX-XXXXXXX
Wake-up Type: Power Switch

Handle 0x0002, DMI type 2, 8 bytes
Base Board Information
Manufacturer: Quanta
Product Name: 3097
Version: 47.0E
Serial Number: None

Handle 0x0003, DMI type 3, 21 bytes
Chassis Information
Manufacturer: Quanta
Type: Notebook
Lock: Not Present
Version: N/A
Serial Number: None
Asset Tag:
Boot-up State: Safe
Power Supply State: Safe
Thermal State: Safe
Security Status: None
OEM Information: 0x00000000
Height: 52 U
Number Of Power Cords: 18
Contained Elements: 0

Handle 0x0004, DMI type 4, 35 bytes
Processor Information
Socket Designation: U23
Type: Central Processor
Family: Opteron
Manufacturer: AMD
ID: 42 0F 02 00 FF FB 8B 07
Signature: Family 15, Model 36, Stepping 2
Flags:
FPU (Floating-point unit on-chip)
VME (Virtual mode extension)
DE (Debugging extension)
PSE (Page size extension)
TSC (Time stamp counter)
MSR (Model specific registers)
PAE (Physical address extension)
MCE (Machine check exception)
CX8 (CMPXCHG8 instruction supported)
APIC (On-chip APIC hardware supported)
SEP (Fast system call)
MTRR (Memory type range registers)
PGE (Page global enable)
MCA (Machine check architecture)
CMOV (Conditional move instruction supported)
PAT (Page attribute table)
PSE-36 (36-bit page size extension)
CLFSH (CLFLUSH instruction supported)
MMX (MMX technology supported)
FXSR (Fast floating-point save and restore)
SSE (Streaming SIMD extensions)
SSE2 (Streaming SIMD extensions 2)
Version: AMD Turion(tm) 64 Mobile ML
Voltage: 2.2 V
External Clock: 200 MHz
Max Speed: 1600 MHz
Current Speed: 1600 MHz
Status: Populated, Enabled
Upgrade: ZIF Socket
L1 Cache Handle: Not Provided
L2 Cache Handle: 0x0005
L3 Cache Handle: Not Provided
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified

Handle 0x0005, DMI type 7, 19 bytes
Cache Information
Socket Designation: L2 Cache
Configuration: Enabled, Socketed, Level 2
Operational Mode: Write Back
Location: Internal
Installed Size: 1024 KB
Maximum Size: 1024 KB
Supported SRAM Types:
Burst
Pipeline Burst
Installed SRAM Type: Synchronous
Speed: Unknown
Error Correction Type: Unknown
System Type: Unknown
Associativity: Unknown

Handle 0x0006, DMI type 9, 13 bytes
System Slot Information
Designation: MiniPCI Slot J20
Type: 32-bit PCI
Current Usage: Available
Length: Long
ID: 0
Characteristics:
5.0 V is provided
3.3 V is provided
PME signal is supported

Handle 0x0007, DMI type 10, 6 bytes
On Board Device Information
Type: Video
Status: Enabled
Description: 128

Handle 0x0008, DMI type 11, 5 bytes
OEM Strings
String 1: $HP$

Handle 0x0009, DMI type 16, 15 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 4 GB
Error Information Handle: Not Provided
Number Of Devices: 2

Handle 0x000A, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x0009
Error Information Handle: No Error
Total Width: 32 bits
Data Width: 32 bits
Size: 512 MB
Form Factor: DIMM
Set: 1
Locator: U5
Bank Locator: Channel A0
Type: DRAM
Type Detail: Synchronous
Speed: Unknown
Manufacturer: Not Specified
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified

Handle 0x000B, DMI type 17, 27 bytes
Memory Device
Array Handle: 0x0009
Error Information Handle: No Error
Total Width: 32 bits
Data Width: 32 bits
Size: 512 MB
Form Factor: DIMM
Set: 1
Locator: U6
Bank Locator: Channel A3
Type: DRAM
Type Detail: Synchronous
Speed: Unknown
Manufacturer: Not Specified
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified

Handle 0x000C, DMI type 19, 15 bytes
Memory Array Mapped Address
Starting Address: 0x00000000000
Ending Address: 0x0003FFFFFFF
Range Size: 1 GB
Physical Array Handle: 0x0009
Partition Width: 0

Handle 0x000D, DMI type 20, 19 bytes
Memory Device Mapped Address
Starting Address: 0x00000000000
Ending Address: 0x0001FFFFFFF
Range Size: 512 MB
Physical Device Handle: 0x000A
Memory Array Mapped Address Handle: 0x000C
Partition Row Position: 2
Interleave Position: 2
Interleaved Data Depth: 2

Handle 0x000E, DMI type 32, 20 bytes
System Boot Information
Status:

Handle 0x000F, DMI type 126, 4 bytes
Inactive

Handle 0x0010, DMI type 127, 4 bytes
End Of Table

Handle 0x0011, DMI type 127, 4 bytes
End Of Table

Tuesday, August 21, 2007

How to Keep Hardware Clock in Local Time


If you dual boot or multiple boot different systems (Linux/Windows), you should keep your system clock in local time meaning you want to disable UTC; otherwise, the clock will be inconsistent between different systems.

Fedora/Red Hat systems:

newemachine# vi /etc/sysconfig/clock
Change 'True' to 'False' in the line where it says 'UTC=True'

Ubuntu/Debian Systems:
newemachine# vi /etc/default/rcS
Change 'yes' to 'no' in the line where it says 'UTC=yes'

Reference

Friday, August 10, 2007

Have fun experimenting with RAID


If your kernel compiled with RAID support and your system supports RAID, the /proc/mdstat exists

[shanren@newemachines ~]$ cat /proc/mdstat
Personalities :
unused devices:


I have reserved two equal-sized unformatted partitions
[shanren@newemachines ~]$ egrep '(sda4|sdb3|blocks)' /proc/partitions
major minor #blocks name
8 4 9052627 sda4
8 19 9052627 sdb3


Let's grab mdadm--RAID administration tool
[root@newemachines shanren]# yum -y install mdadm
Loading "installonlyn" plugin
Setting up Install Process
Parsing package install arguments
fedora 100% |=========================| 2.1 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package mdadm.i386 0:2.6.2-4.fc7 set to be updated

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
mdadm i386 2.6.2-4.fc7 updates 817 k

Transaction Summary
=============================================================================
Install 0 Package(s)
Update 1 Package(s)
Remove 0 Package(s)

Total download size: 817 k
Downloading Packages:
(1/1): mdadm-2.6.2-4.fc7. 100% |=========================| 817 kB 00:11
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : mdadm ######################### [1/2]
Cleanup : mdadm ######################### [2/2]

Updated: mdadm.i386 0:2.6.2-4.fc7
Complete!


I want to construct RAID 1 with two partitions on separate hard drives and format it with ext3 file system
[root@newemachines shanren]# /sbin/mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/sda4 /dev/sdb3
mdadm: size set to 9052544K
mdadm: array /dev/md0 started.

[root@newemachines shanren]# /sbin/mkfs.ext3 /dev/md0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1133440 inodes, 2263136 blocks
113156 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2319450112
70 block groups
32768 blocks per group, 32768 fragments per group
16192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

Checking the status of building the RAID
[root@newemachines shanren]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb3[1] sda4[0]
9052544 blocks [2/2] [UU]
[==========>..........] resync = 50.0% (4530496/9052544) finish=5.0min speed=15035K/sec

unused devices:

[root@newemachines shanren]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb3[1] sda4[0]
9052544 blocks [2/2] [UU]

unused devices:

Mount the RAID
[root@newemachines shanren]# mkdir /mnt/raid
[root@newemachines shanren]# mount -t ext3 -v /dev/md0 /mnt/raid
/dev/md0 on /mnt/raid type ext3 (rw)


Create the configuration file for mdadm so I can assemble the created array easily later on. I use mdadm with --detail option to obtain the detailed array information and add that information to /etc/mdadm.conf. My final mdadm.conf is shown.
[root@newemachines shanren]# /sbin/mdadm --detail --scan
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=00c674c9:04162ff3:124ba3d9:31646810
[root@newemachines ~]# cat /etc/mdadm.conf
DEVICE /dev/sda4 /dev/sdb3
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=00c674c9:04162ff3:124ba3d9:31646810 devices=/dev/sda4,/dev/sdb3


Should we check how well RAID 1 perform?
[root@newemachines shanren]# ls -lh debian-testing-i386-netinst.iso |cut -d" " -f5
159M
[root@newemachines shanren]# time cp debian-testing-i386-netinst.iso Desktop/

real 0m0.720s
user 0m0.018s
sys 0m0.629s
[root@newemachines shanren]# time cp debian-testing-i386-netinst.iso /mnt/raid/

real 0m0.697s
user 0m0.019s
sys 0m0.613s

[root@newemachines shanren]# ls -lh F-7-i386-DVD.iso |cut -d" " -f5
2.8G
[root@newemachines shanren]# time cp F-7-i386-DVD.iso Desktop/

real 3m18.350s
user 0m0.422s
sys 0m14.498s
[root@newemachines shanren]# time cp F-7-i386-DVD.iso /mnt/raid/

real 7m14.209s
user 0m0.453s
sys 0m13.556s
As the file size increases, the overhead of RAID 1 becomes quite noticeable.

I would like to see if RAID 1 does what it is supposed to do--Mirroring
[root@newemachines shanren]# umount /dev/md0
[root@newemachines shanren]# /sbin/mdadm --stop /dev/md0
mdadm: stopped /dev/md0

[root@newemachines shanren]# mkdir /mnt/raiddevice0 /mnt/raiddevice1
[root@newemachines ~]# mount /dev/sda4 /mnt/raiddevice0
[root@newemachines ~]# mount /dev/sdb3 /mnt/raiddevice1

[root@newemachines ~]# md5 /mnt/raiddevice0/F-7-i386-DVD.iso
355bdb01b0268a4bb7c757f2737dcf7c /mnt/raiddevice0/F-7-i386-DVD.iso
[root@newemachines ~]# md5 /mnt/raiddevice1/F-7-i386-DVD.iso
355bdb01b0268a4bb7c757f2737dcf7c /mnt/raiddevice1/F-7-i386-DVD.iso
Obviously, it does because the md5 of the files written to two RAID devices is the same

Let's clean it up...
[root@newemachines ~]# umount /mnt/raiddevice0 /mnt/raiddevice1
[root@newemachines ~]# rmdir /mnt/raiddevice0 /mnt/raiddevice1
[root@newemachines shanren]# /sbin/mdadm --assemble --verbose /dev/md0
mdadm: looking for devices for /dev/md0
mdadm: /dev/sda4 is identified as a member of /dev/md0, slot 0.
mdadm: /dev/sdb3 is identified as a member of /dev/md0, slot 1.
mdadm: added /dev/sdb3 to /dev/md0 as 1
mdadm: added /dev/sda4 to /dev/md0 as 0
mdadm: /dev/md0 has been started with 2 drives.


Reference: Link 1, Link 2, Link 3

Monday, July 30, 2007

Quick way to find out what types of file systems you can under FreeBSD on your machine


Open a terminal and run:

ls /sbin/mount_*


The following tells the kinds of file systems I can mount under my FreeBSD such as ntfs, ext2fs(linux ext2, ext3 file systems) and etc.
newemachine# ls /sbin/mount_*
/sbin/mount_cd9660      /sbin/mount_mfs         /sbin/mount_procfs
/sbin/mount_devfs /sbin/mount_msdosfs /sbin/mount_reiserfs
/sbin/mount_ext2fs /sbin/mount_nfs /sbin/mount_std
/sbin/mount_fdescfs /sbin/mount_nfs4 /sbin/mount_udf
/sbin/mount_linprocfs /sbin/mount_ntfs /sbin/mount_umapfs
/sbin/mount_linsysfs /sbin/mount_nullfs /sbin/mount_unionfs

Say, now I plug in a USB drive have two slices. The first slice da0s1 is a NTFS file system and the second slice da0s2 is an ext3 file system. I can mount them as follows:
newemachine# mount -t ntfs /dev/da0s1 /media
newemachine# mount -t ext2fs /dev/da0s2 /mnt

Sunday, June 10, 2007

How to Add Startup Programs (Linux & FreeBSD)


This applies to different desktop managers (XDM, GDM, and KDM)

newemachine$ vi ~/.xsession

then put your commands to the following in the file

#!/bin/sh
gnome-terminal &
exec /usr/bin/gnome-session

This runs gnome-terminal after you log into a Gnome session. You can substitute 'gnome-terminal' with other commands that you want to run. 'exec /usr/bin/gnome-session' is required here; otherwise, as soon as starting gnome-terminal process finishes, you will be taken back to the log in window. The directory of window managers such as Gnome varies from distribution to distribution. If you run a different window manager, you want to change '/usr/bin/gnome-session' accordingly.
newemachine$ chmod u+x ~/.xsession
.xsession has to be executable to get this working.

Saturday, June 2, 2007

Learning FreeBSD


How to Install a FreeBSD Application

  • install pre-compiled applications
  • newemachine# pkg_add -r bash
    The above command installs precompiled Bash application.

  • install ports
  • newemachine# cd /usr/ports/www/bash
    newemachine# make install clean
    The above command download necessary source pre, then compile and install it.

How to find a FreeBSD Application
  • Option 1: (If you know the exact application name)
  • newemachine# whereis xclock
    xclock: /usr/local/bin/xclock /usr/share/man/man1/xclock.1.gz /usr/ports/x11/xclock

  • Option 2:
  • newemachine# cd /usr/ports
    newemachine# make search name=xclock
    Port: xclock-1.0.2
    Path: /usr/ports/X11/xclock
    Info: Analog and digital clock for X
    .......

How to Give User Superuser Privilege
  • allow a user to sudo
  • newemachine# pkg_add -r sudo
    newemachine# /usr/local/sbin/visudo

    then add the following line after 'root ALL=(ALL) ALL'
    shawn ALL=(ALL) ALL
    this gives user shawn the superuser privilege

  • allow a user to su
  • newemachine# vi /etc/group
    then add change 'wheel:*:0:root' to 'wheel:*:0:root,shawn', this adds user shawn to the wheel group which have the superuser privilege.

How to Configure X
  • create a X server configuration file
  • newemachine# Xorg -configure

  • test newly created configuration file
  • newemachine# X -config /root/xorg.conf.new
    If you see a gray screen with x mouse cursor, then X is running ok. Now Ctrl + Alt + Backspace to exit X

  • fine-tune X configuration
  • newemachine# mv /root/xorg.conf.new /etc/X11/xorg.conf

    Move tested configuration to the system-wide configuration directory
    newemachine# vi /etc/X11/xorg.conf

    Under Section "Screen", add a line DefaultDepth 24 after the line where it says Monitor "Monitor0"
    then under SubSection "Display", add a line Modes "1024x768" (#change to your own screen resolution) after the line where it says Depth 24
    newemachine# startx
    start the X server!
How to Configure Sound Card
  • load a set of common sound device drivers
  • newemachine# kldload snd_driver

  • test loaded sound card driver
  • newemachine# cat /dev/sndstat
    You will see something similar to the following:
    FreeBSD Audio Driver (newpcm)
    Installed devices:
    pcm0: at io 0xffa7f800, 0xffa7f400 irq 17 bufsz 16384 kld snd_ich (1p/1r/0v channels duplex default)
    This means that my actual sound card driver is snd_ich; therefore, I can load snd_ich instead of snd_driver.
    newemachine# kldload snd_ich

  • load modules at boot
  • newemachine# vi /boot/loader.conf

    add snd_ich_load="YES" to the file

Thursday, May 31, 2007

OSes

Too many operating systems to choose from? Or you only use Windows? Read on:
--> Plain English: FreeBSD vs Linux vs Windows
--> Kernel Talk: A Comparison of Solaries, Linux, and FreeBSD Kernels