Friday, April 30, 2010
USB drive not being recognized under Linux
In order to access USB drive under Linux you need to load special USB driver and support must be included in running Linux kernel. Try following command one by one to solve your problem:
Step # 1 : Make sure your external drive detected by system
Run dmesg command which print or control the kernel ring buffer:
# dmesg
OR
# dmesg | grep รข€“i USB
Output:
SLPB PCI0 HUB0 USB0 USB1 USB2 USBE
usbcore: registered new driver usbfs
usbcore: registered new driver hub
USB Universal Host Controller Interface driver v2.3
uhci_hcd 0000:00:1d.0: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
uhci_hcd 0000:00:1d.1: new USB bus registered, assigned bus number 2
hub 2-0:1.0: USB hub found
uhci_hcd 0000:00:1d.2: new USB bus registered, assigned bus number 3
usb 1-2: new full speed USB device using uhci_hcd and address 2
hub 3-0:1.0: USB hub found
As you see USB support is included in kernel. You can also verify this with following command:
# lspci -v | grep HCI
Output:
0000:00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 02) (prog-if 00 [UHCI])
0000:00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 02) (prog-if 00 [UHCI])
0000:00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 02) (prog-if 00 [UHCI])
0000:00:1d.7 USB Controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller (rev 02) (prog-if 20 [EHCI])
Step # 2 : Load USB modules/driver
If you cannot see your external USB drive in above dmesg output then try to load usb-uhci and usb-ohci modules (driver):
# modprobe usb-uhci
# modprobe usb-ohci
# modprobe usb-storage
Now again run dmesg:
# dmesg
Output:
usb 4-1: new high speed USB device using ehci_hcd and address 3
scsi2 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
Vendor: SAMSUNG Model: SV4002H Rev: 0811
Type: Direct-Access ANSI SCSI revision: 00
SCSI device sdb: 78242976 512-byte hdwr sectors (40060 MB)
sdb: assuming drive cache: write through
SCSI device sdb: 78242976 512-byte hdwr sectors (40060 MB)
sdb: assuming drive cache: write through
sdb: sdb1
sd 2:0:0:0: Attached scsi disk sdb
usb-storage: device scan complete
Step 3 : Use external USB drive
As you see device sdb assigned to an external USB drive use mount command to mount drive:
List partitions on /dev/sdb:
# fdisk -l | grep sdb
Output:
Disk /dev/sda doesn't contain a valid partition table
Disk /dev/sdb: 40.0 GB, 40060403712 bytes
/dev/sdb1 1 4870 39118243+ c W95 FAT32 (LBA)
Now mount partition:
# mount /dev/sdb1 /mnt
See also:
- Linux : How to use USB pen/flash stick
- Allow normal user to mount linux partitions, usb stick/pen device
REFERENCES
http://www.cyberciti.biz/faq/usb-drive-not-being-recognized-under-linux/
Centos Chkconfig The Boot Processes
Unlike other operating systems (Windows) each step of loading a Linux system easily understood.
Contents[hide] |
The Boot Process
It is also easy to break.
- The BIOS loads the Boot Sector (Grub) from Sector 0
- The Grub (root line in grub.conf) points to the partition containing the kernel (Linux).
- The kernel loads and initializes the devices and runs /sbin/init (process 1)
- /sbin/init runs /etc/rc.d/rc.sysinit to initilize devices.
- /sbin/init reads /etc/inittab
- /etc/rc.d/rc.sysinit run all the scripts int the approach run level directory.
GRUB
Grub is the first step in the boot process and has the greatest Oh ---- factor. But it really doesn't have to be a big problem. You may not need to boot from a live CD to fix this. There are three main parts to boot step
- root
- kernel
- initrd
Try booting and editing each of these lines in GRUB. Purposely make mistakes to learn what errors are produced.
The TAB key will do auto completions when you are editing a GRUB options.
Rescure Mode
Using the first CD to boot into Rescue mode. You can then search for the root file system and mount it to the directory /mnt/sysimage.
chroot /mnt/sysimage
grub
Following this command you need to show grub where to read the grub configuration. If the drive type may have changed, maybe because you changed from IDE to SCSI disks you will need to do a --recheck. Then install grub with the install command.
grub-install --recheck /dev/hda
grub-install /dev/hda
Redhat will ask if you want to mount the root file system. If you say no you will need to mount the root file system your self. Here are the commands to do this with the VMware system.
mkdir /mnt/root
mkdir /mnt/root/boot
mount /dev/md1 /mnt/root
mount /dev/md0 /mnt/root/boot
Fixing INITRD Modules
If the kernel is missing or corrupt you will need to reload it from the install CD.
If the initrd file is missing you you can also reload it with the kernel.
Adding missing modules to initrd:
rm -f /boot/initrd-2.6.20-1.2320.fc5.img
mkinitrd --preload=xor --preload=raid456 /boot/initrd-2.6.20-1.2320.fc5.img
2.6.20-1.2320.fc5
Manually changing initrd:
mkdir /root/initrd-tmp
cd /root/initrd-tmp
cp -a /boot/initrd-2.6.20-1.2320.fc5.img ..
mv ../initrd-2.6.20-1.2320.fc5.img ../initrd-2.6.20-1.2320.fc5.img.gz
gunzip ../initrd-2.6.20-1.2320.fc5.img.gz
cpio -i --make-directories < ../initrd-2.6.20-1.2320.fc5.img
vi init
find . -depth | cpio -o > ../initrd-2.6.20-1.2320.fc5.img
cd ..
rm -rf initrd-tmp
gzip -9 initrd-2.6.20-1.2320.fc5.img
mv initrd-2.6.20-1.2320.fc5.img.gz initrd-2.6.20-1.2320.fc5.img
mv initrd-2.6.20-1.2320.fc5.img /boot
SYSINIT
INITTAB
The file /etc/inittab controls the runlevel the system boots into.
You can override this by added the runlevel you want to the end of the kernel line in GRUB.
id:3:initrdefault:
Changing the 3 in this line will change the default runlevel to the one you want.
Runlevels
Here are the runlevels and what they mean. You should know the by heart too.
- Run level 1 is single user
- Run level 2 is Multiuser without NFS
- Run level 3 is Full Multiuser
- Run level 4 is unused
- Run level 5 is X11 windows
- Run level 6 will reboot the system
/etc/inittab not only starts rc.sysinit it also starts processes that shouldn't die. One of these is the system console/s. It controls which run level the system automatically boots to. The directory /etc/sysconfig hold config files for process started at this level.
RC scripts are kept in /etc/rc.d. The program that run the RC scripts is rc.sysinit. These scripts are what is done when you change run level with the init command.
The fastest to set runlevel services is to use the command 'ntsysv and tell it the runlevels you want to set. For example, this will display and change runlevels 3 and 5.
ntsysv --level 35
To turn on or off a RC script you can also use the command:
chkconfig --level command on/off
The option --level sets the run level to be change for the command that is turned on or off. This can also be done with the GUI system-config-services.
chkconfig --list
This command will list all the services and if they are on or off for each run level.
chkconfig --add/--del command
This command will add or delete a new command from the RC start-up scripts.
After configuring a system like Apache it is easy to forget make it start at boot time. Don't forget to reboot you system before the test is over.
You can debug the RC process by booting into single user mode and running the RC scripts in the run level by hand. You can also bypass init by adding init=/bin/bash the kernel line in GRUB.
CLONING or RESTORING a System
THIS IS NOT NEEDED FOR THE TEST
Here are some of the issues if you are cloning or restoring a system by copy all the files into empty directories and then restoring the boot process. This process involves creating all the required root directories (/ /etc /usr /bin /var /opt /home) and coping all the files back into place with their ownership and permissions maintained. Directories that are not copied include /tmp /dev /proc /mnt. The directories that are not copied do need to be created.
- The partitions and/or e2 labels may not be the same. This will require changing /etc/fstab
- Some directories will/may not be copied. This may include /dev. In witch case mounting the root file system with the chroot command will leave you without any devices.
- Grub.conf (/etc/grub/grub.conf and menu.lst) may also need editing. Both the root and kernel lines may contain references to the wrong partitions.
- /etc/mtab needs to be edited to match the new disk. Partition numbers can change and sometimes the type, like from IDE to SCSI (hda to sda).
After booting into recover mode with the install CD. You will need to mount all of the file systems into their place under /mnt/sysimage. You can them mount the live proc and dev inplace with the command:
mount -o bind /dev /mnt/sysimage/dev
mount -o bind /proc /mnt/sysimage/proc
With the file systems in place you can use the chroot command to create the write environment for fixing the master boot record and Grub.
chroot /mnt/sysimage
REFERENCES
http://linuxfanboy.com/index.php/The_Boot_Processes
Thursday, April 29, 2010
tar doesn't compress .hidden files in the same directory it is run in?
.htaccess
.news
info.txt
info.log
tar -cvpzf test.tgz ./*
./info.log
./info.txt
Furthermore if there is a .htaccess file in a subdirectory it is compressed.
Example Directory Contains:
.htaccess
.news
info.txt
info.log
/subdir/.htaccess/
tar -cvpzf test.tgz ./*<br />./info.log<br />./info.txt<br />./subdir/<br />./subdir/.htaccess
Solution:
Globbing with * does not include hidden files, whereas every file in a
directory (hidden ones included) are put into the archive. So you can
simply do
$ tar -cvpzf test.tgz .
globbing, using
$ shopt -s dotglob<br />$ tar -cvpzf test.tgz ./*<br />$ shopt -u dotglob # to disable the shell option
REFERENCES
http://www.linuxquestions.org/questions/linux-newbie-8/tar-doesnt-compress-hidden-files-in-the-same-directory-it-is-run-in-730222/
Mount LVM partitions from an external hard drive
Mount LVM partitions from an external hard drive
Q Is it possible, and if so how, to mount LVM partitions from an external hard drive? I'm thinking of my old Fedora system drive from which I would like to retrieve a single file without having to boot from it.
A As long as you have the LVM tools installed on the distro you are booting, you can mount LVM partitions from any disk (I even did it from a USB key once). Run
vgscan
vgchange -a y
as root and all the partitions should have devices created in the form /dev/volumegroup/logicalvolume, which you can then mount in the usual way:
mount /dev/volumegroup/logicalvolume /mnt/somewhere
REFERENCES
http://www.tuxradar.com/answers/296
Mounting a Linux LVM volume on External harddrive
a partition using a standard Linux file system (e.g. ext2, ext3).
# fdisk -l /dev/hda
Disk /dev/hda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device
Boot
Start
End Blocks Id System
/dev/hda1
*
1
13 104391 83 Linux
/dev/hda2
14 19457
156183930 8e Linux LVM
# mount /dev/hda2 /tmp/mnt
mount: /dev/hda2 already mounted or /tmp/mnt busy
First, let's determine the volume group containing the physical volume /dev/hda2.
# pvs
PV
VG Fmt Attr
PSize PFree
/dev/hda2 VolGroup01 lvm2 a- 148.94G 32.00M
/dev/hdb2 VolGroup00 lvm2 a- 114.94G 96.00M
Next, let's list the logical volumes in VolGroup01.
# lvdisplay /dev/VolGroup01
--- Logical volume ---
LV Name /dev/VolGroup01/LogVol00
VG Name VolGroup01
LV
UUID
zOQogm-G8I7-a4WC-T7KI-AhWe-Ex3Y-JVzFcR
LV Write Access read/write
LV Status available
# open 0
LV Size 146.97 GB
Current LE 4703
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2
--- Logical volume ---
LV
Name
/dev/VolGroup01/LogVol01
VG Name VolGroup01
LV
UUID
araUBI-4eer-uh5L-Dvnr-3bI6-4gYg-APgYy2
LV Write Access read/write
LV Status available
# open 0
LV Size 1.94 GB
Current LE 62
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:3
The logical volume I would like to "mount" (in purely the computing-related sense) is /dev/VolGroup01/LogVol00. The other logical volume is a swap partition.
# mount /dev/VolGroup01/LogVol00 /tmp/mnt
REFERENCES
http://www.brandonhutchinson.com/Mounting_a_Linux_LVM_volume.html
I've not much experience with LVM, but I did have a similar problem to
you, so here's how I solved it (Ubuntu 7.04 server).
1. Install lvm2:
sudo apt-get install lvm2
sudo cp -r /lib/lvm-200/ /lib/lvm-0
2. Take note of the LV Name for the volume you want to mount from the
output of the following command (/dev/VolGroup00/LogVol00 in my case):
sudo lvdisplay
3. Run the following commands to mount the logical volume:
sudo modprobe dm-mod
sudo vgchange -ay
sudo mkdir /mnt/old_hd
sudo mount /dev/VolGroup00/LogVol00 /mnt/old_hd
Worked for me!
REFERENCES
http://ubuntuforums.org/showthread.php?t=428292
Wednesday, April 28, 2010
How To Install Subversion with TRAC on CentOS 5.x
In this howto i will describe how to install subversion with TRAC. Subversion is an open source version control system alternative to CVS and TRAC an enhanced wiki and issue tracking system for software development projects which provides an interface to Subversion. I install it on CentOS 5.4 which is already running as Web Server. I will use sohailriaz.com source to be maintain by Subversion and TRAC to track all development.
1) Installation
To install subversion and trac on CentOS 5.4 we will use dag repositories as it has latest packages (rpms) available for said softwares.
Red Hat Enterprise Linux / CentOS 5 / i386:
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
Red Hat Enterprise Linux / CentOS 5 / x86_64:
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
Now issue yum command to install subversion and trac with pre-requisites.
yum -y install subversion trac mod_dav_svn mod_python
where mod-dav_svn and mod_python are apache modules which will be use later on to access subversion and trac.
2) Configuring Subversion.
2.1) Creating directories for Subversion.
mkdir /var/www/svn/svnrepos
mkdir /var/www/svn/auth
2.2) User Authentication.
We will create a user to access SVN repositories
htpasswd -cb /var/www/svn/auth/svn.htpasswd svnuser1 passw0rd
Adding password for user svnuser1
2.3) Create Project Repository.
Now we will create a Project Repository. It can be user define name. I will choose site-sohailriaz.com name here for my Project Repository.
svnadmin create /var/www/svn/svnrepos/site-sohailriaz.com
svn mkdir file:///var/www/svn/svnrepos/site-sohailriaz.com/branches file:///var/www/svn/svnrepos/site-sohailriaz.com/tags file:///var/www/svn/svnrepos/site-sohailriaz.com/trunk -m “Creating directories for initial import”
Committed revision 1.
Change ownership and group member to apache (default user for web server)
chown -R apache:apache /var/www/svn/svnrepos/site-sohailriaz.com/
Generate configuration for svn to view from website.
vi /etc/httpd/conf.d/svn.conf
<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath /var/www/svn/svnrepos/AuthType Basic
AuthName “SohailRiaz.com Site Repository”
AuthUserFile /var/www/svn/auth/svn.htpasswd
Require valid-user
</Location>
Start service to take the changes.
/etc/init.d/httpd restart
Now browse your site to see the SVN repository.
http://www.sohailriaz.com/svn/
It will ask the user/pass you created initially and after successful login you will see your repositories.
2.4) SVN Import for site files.
We will use svn import to import files from our site to repository to maintain the code.
svn import /home/sohail/public_html/ http://www.sohailriaz.com/svn/site-sohailriaz.com/trunk/
Authentication realm: SohailRiaz.com Site Repository
Password for ‘root’ : <enter root password>
Authentication realm: SohailRiaz.com Site Repository
Username : svnuser1
Password : passw0rd
Now browse your site and see the trunk folder, you will see your code listed there.
2.5) Branches
If you need to have multiple branches for your site then that is relatively very easy within subversion. All you need to copy from trunk to branches folder with user define name to recognized.
svn copy http://www.sohailriaz.com/svn/site-sohailriaz.com/trunk/ http://www.sohailriaz.com/svn/site-sohailriaz.com/branches/site-sohailriaz.com-branch-1 -m “1st Branch for Site SohailRiaz.com”
3) Configure Trac.
First configure trac instance using trac-admin command for svn repository site-sohailriaz.com
trac-admin /var/www/trac/site-sohailriaz.com initenv
Creating a new Trac environment at /var/www/trac/site-sohailriaz.comTrac will first ask a few questions about your environment
in order to initalize and prepare the project database.Please enter the name of your project.
This name will be used in page titles and descriptions.Project Name [My Project]> Site SohailRiaz.com
Please specify the connection string for the database to use.
By default, a local SQLite database is created in the environment
directory. It is also possible to use an already existing
PostgreSQL database (check the Trac documentation for the exact
connection string syntax).Database connection string [sqlite:db/trac.db]> <Enter>
Please specify the type of version control system,
By default, it will be svn.If you don’t want to use Trac with version control integration,
choose the default here and don’t specify a repository directory.
in the next question.Repository type [svn]> <Enter>
Please specify the absolute path to the version control
repository, or leave it blank to use Trac without a repository.
You can also set the repository location later.Path to repository [/path/to/repos]> /var/www/svn/svnrepos/site-sohailriaz.com
Please enter location of Trac page templates.
Default is the location of the site-wide templates installed with Trac.Templates directory [/usr/share/trac/templates]> <Enter>
…………………..
…………………..
…………………..
Congratulation!
Edit /etc/httpd/conf.d/trac.conf and change /var/trac to /var/www/trac at line starting from PythonOption TracEnvParentDir
vi /etc/httpd/conf.d/trac.conf
following line should be like this
PythonOption TracEnvParentDir /var/www/trac
Create user account for trac access
htpasswd -cb /var/www/trac/.htpasswd tracuser1 passw0rd
Change ownership and group member to apache of trac instances.
chown -R apache:apache /var/www/trac/site-sohailriaz.com
Restart webserver to take changes.
/etc/init.d/httpd restart
Now browse the site and you will see all available projects under trac and then open the project to browse by viewing source.
REFERENCES
http://www.sohailriaz.com/how-to-install-subversion-with-trac-on-centos-5-x/
