Q. My SATA drive is being displayed as /dev/hda instead of /dev/sda. How do I fix this problem and make sure I get /dev/sda and speed of SATA under Linux operating systems?
A. This is usually related to BIOS settings. Reboot your system and enter into BIOS setup:
Check BIOS settings
Make sure Parallel ATA is "Enabled"
Make sure "Native Mode Operation" is set to "Serial ATA"
Also, set SATA Controller Mode option to "Enhanced"
Save the changes and reboot the server. Now Linux should rename the SATA drive from /dev/hda to /dev/sdb.
Make sure kernel is compiled with SATA support
Usually vendor kernel from Debian/RHEL/Rehat/Fedora comes with SATA enabled. Sometime you may compile custom kernel. If this is case run following command to find out if SATA kernel support is compiled:
grep -i SATA /boot/config-$(uname -r)
Sample output:
CONFIG_SATA_AHCI=m
CONFIG_SATA_INIC162X=m
CONFIG_SATA_MV=m
CONFIG_SATA_NV=m
CONFIG_SATA_PMP=y
CONFIG_SATA_PROMISE=m
CONFIG_SATA_QSTOR=m
CONFIG_SATA_SIL=m
CONFIG_SATA_SIL24=m
CONFIG_SATA_SIS=m
CONFIG_SATA_SVW=m
CONFIG_SATA_SX4=m
CONFIG_SATA_ULI=m
CONFIG_SATA_VIA=m
CONFIG_SATA_VITESSE=m
Make sure ata_piix and libata driver loaded and the disk shows as /dev/sda if DMA is enabled:
lsmod | egrep 'ata_piix|libata'
Sample output:
ata_piix 24580 5
libata 177312 5 pata_acpi,ata_generic,pata_marvell,ata_piix,ahci
scsi_mod 155212 9 ib_iser,iscsi_tcp,libiscsi,scsi_transport_iscsi,sbp2,sr_mod,sd_mod,sg,libata
dock 16656 1 libata
Reference: http://www.cyberciti.biz/faq/linux-sata-drive-displayed-as-devhda/
Thursday, August 20, 2009
Linux SATA Drive is Being Displayed as /dev/hda Instead Of /dev/sda
Category:
Hardware
— SkyHi @ Thursday, August 20, 2009
VSFTPD: Force Upload Only No Downloads
Category:
vsftpd
— SkyHi @ Thursday, August 20, 2009
Question: How do I configure my VSFTPD ftp server to upload files but disable all file download requests under Debian Linux?
Answer: You can easily configure vsftpd to disallow all download requests. You
VSFTPD ftp server download_enable option
If set to NO, all download requests will give permission denied.
Configure vsftpd to disallow all download requests
Open vsftpd.conf file:
# vi /etc/vsftpd.conf
Set download_enable to NO:
download_enable=NO
Save and close the file. Restart vsftpd ftp server:
# /etc/init.d/vsftpd restart
Answer: You can easily configure vsftpd to disallow all download requests. You
VSFTPD ftp server download_enable option
If set to NO, all download requests will give permission denied.
Configure vsftpd to disallow all download requests
Open vsftpd.conf file:
# vi /etc/vsftpd.conf
Set download_enable to NO:
download_enable=NO
Save and close the file. Restart vsftpd ftp server:
# /etc/init.d/vsftpd restart
Tar Extract a Single File(s) From a Large Tarball
Category:
Linux
— SkyHi @ Thursday, August 20, 2009
Q. I've couple of large tarballs such as www.tar and images.tar. Is it possible to extract a single file or a list of files from a large tarball such as images.tar instead of extracting the entire tarball? How do I extract specific files under Linux / UNIX operating systems?
A. GNU tar can be used to extract a single or more files from a tarball. To extract specific archive members, give their exact member names as arguments, as printed by -t option.
Extracting Specific Files
Extract a file called etc/default/sysstat from config.tar.gz tarball:
$ tar -ztvf config.tar.gz
$ tar -zxvf config.tar.gz etc/default/sysstat
$ tar -xvf {tarball.tar} {path/to/file}
Some people prefers following syntax:
tar --extract --file={tarball.tar} {file}
Extract a directory called css from cbz.tar:
$ tar --extract --file=cbz.tar css
Wildcard based extracting
You can also extract those files that match a specific globbing pattern (wildcards). For example, to extract from cbz.tar all files that begin with pic, no matter their directory prefix, you could type:
$ tar -xf cbz.tar --wildcards --no-anchored 'pic*'
To extract all php files, enter:
$ tar -xf cbz.tar --wildcards --no-anchored '*.php'
Where,
* -x: instructs tar to extract files.
* -f: specifies filename / tarball name.
* -v: Verbose (show progress while extracting files).
* -j : filter archive through bzip2, use to decompress .bz2 files.
* -z: filter archive through gzip, use to decompress .gz files.
* --wildcards: instructs tar to treat command line arguments as globbing patterns.
* --no-anchored: informs it that the patterns apply to member names after any / delimiter.
Reference: http://www.cyberciti.biz/faq/linux-unix-extracting-specific-files/
A. GNU tar can be used to extract a single or more files from a tarball. To extract specific archive members, give their exact member names as arguments, as printed by -t option.
Extracting Specific Files
Extract a file called etc/default/sysstat from config.tar.gz tarball:
$ tar -ztvf config.tar.gz
$ tar -zxvf config.tar.gz etc/default/sysstat
$ tar -xvf {tarball.tar} {path/to/file}
Some people prefers following syntax:
tar --extract --file={tarball.tar} {file}
Extract a directory called css from cbz.tar:
$ tar --extract --file=cbz.tar css
Wildcard based extracting
You can also extract those files that match a specific globbing pattern (wildcards). For example, to extract from cbz.tar all files that begin with pic, no matter their directory prefix, you could type:
$ tar -xf cbz.tar --wildcards --no-anchored 'pic*'
To extract all php files, enter:
$ tar -xf cbz.tar --wildcards --no-anchored '*.php'
Where,
* -x: instructs tar to extract files.
* -f: specifies filename / tarball name.
* -v: Verbose (show progress while extracting files).
* -j : filter archive through bzip2, use to decompress .bz2 files.
* -z: filter archive through gzip, use to decompress .gz files.
* --wildcards: instructs tar to treat command line arguments as globbing patterns.
* --no-anchored: informs it that the patterns apply to member names after any / delimiter.
Reference: http://www.cyberciti.biz/faq/linux-unix-extracting-specific-files/
Linux Find Large Files and sort du -h output by size
Q. How do I find out all large files in a directory?
A. There is no single command that can be used to list all large files. But, with the help of find command and shell pipes, you can easily list all large files.
Search or find big files Linux (50MB) in current directory, enter:
Search in my /var/log directory:
Search in current directory:
Sample output:
OR
To list all files on the system whose size is exactly 20 512-byte blocks, type:
You can also use du command as pointed out georges in the comments.
996.0 K ********** ./3dgolddenhouse.com/html/gallery/wood_b_slides
1.0 M ********** ./3dgolddenhouse.com/html/gallery/draperies_slides
1.1 M ********** ./3dgolddenhouse.com/html/gallery/roller_shades_slide
1.1 M ********** ./3dgolddenhouse.com/html/gallery/wood_shutters_slides
1.2 M ********** ./stellmnao.com/html/cchis
1.2 M ********** ./stellmnao.com/html
1.2 M ********** ./stellmnao.com
1.3 M ********** ./3dgolddenhouse.com/html/gallery/cellular_slides
1.3 M ********** ./3dgolddenhouse.com/html/gallery/faux_wood_slides
1.3 M ********** ./heretogohome.net/html/bo/app/webroot
1.5 M ********** ./3dgolddenhouse.com/html/gallery/sheer_shades_slides
1.6 M *********** ./3dgolddenhouse.com/html/gallery/vinyl_shutters_slides
1.7 M *********** ./heretogohome.net/html/bo/cake/libs
1.9 M *********** ./heretogohome.net/html/bo/app
2.8 M *********** ./heretogohome.net/html/bo/cake
3.1 M ************ ./3dgolddenhouse.com/html/images
3.1 M ************ ./3dgolddenhouse.com/html/gallery/aluminum_slides
3.2 M ************ ./3dgolddenhouse.com/html/gallery/roman_shades_slides
5.3 M ************ ./heretogohome.net/html/bo
5.3 M ************ ./heretogohome.net/html
5.3 M ************ ./heretogohome.net
18.0 M ************** ./3dgolddenhouse.com/html/gallery
21.3 M ************** ./3dgolddenhouse.com/html
21.3 M ************** ./3dgolddenhouse.com
27.8 M *************** .
Linux tip: du --max-depth=1
Reference: http://www.cyberciti.biz/faq/find-large-files-linux/
http://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size
A. There is no single command that can be used to list all large files. But, with the help of find command and shell pipes, you can easily list all large files.
Linux List All Large Files
To finds all files over 50,000KB (50MB+) in size and display their names, along with size, use following syntax:Syntax for RedHat / CentOS / Fedora Linux
find {/path/to/directory/} -type f -size +{size-in-kb}k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' Search or find big files Linux (50MB) in current directory, enter:
$ find . -type f -size +50000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' Search in my /var/log directory:
# find /var/log -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }' Syntax for Debian / Ubuntu Linux
find {/path/to/directory} -type f -size +{file-size-in-kb}k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }' Search in current directory:
$ find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'Sample output:
./.kde/share/apps/akregator/Archive/http___blogs.msdn.com_MainFeed.aspx?Type=AllBlogs.mk4: 91M ./out/out.tar.gz: 828M ./.cache/tracker/file-meta.db: 101M ./ubuntu-8.04-desktop-i386.iso: 700M ./vivek/out/mp3/Eric: 230M
Above commands will lists files that are are greater than 10,000 kilobytes in size. To list all files in your home directory tree less than 500 bytes in size, type:
$ find $HOME -size -500b OR
$ find ~ -size -500b To list all files on the system whose size is exactly 20 512-byte blocks, type:
# find / -size 20ls command: finding the largest files in a directory
You can also use ls command:$ ls -lS
$ ls -lS | less
$ ls -lS | head +10ls command: finding the smallest files in a directory
Use ls command as follows:$ ls -lSr
$ ls -lSr | less
$ ls -lSr | tail -10You can also use du command as pointed out georges in the comments.
Perl hack: To display large files
Jonathan has contributed following perl code print out stars and the length of the stars show the usage of each folder / file from smallest to largest on the box:#du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'
996.0 K ********** ./3dgolddenhouse.com/html/gallery/wood_b_slides
1.0 M ********** ./3dgolddenhouse.com/html/gallery/draperies_slides
1.1 M ********** ./3dgolddenhouse.com/html/gallery/roller_shades_slide
1.1 M ********** ./3dgolddenhouse.com/html/gallery/wood_shutters_slides
1.2 M ********** ./stellmnao.com/html/cchis
1.2 M ********** ./stellmnao.com/html
1.2 M ********** ./stellmnao.com
1.3 M ********** ./3dgolddenhouse.com/html/gallery/cellular_slides
1.3 M ********** ./3dgolddenhouse.com/html/gallery/faux_wood_slides
1.3 M ********** ./heretogohome.net/html/bo/app/webroot
1.5 M ********** ./3dgolddenhouse.com/html/gallery/sheer_shades_slides
1.6 M *********** ./3dgolddenhouse.com/html/gallery/vinyl_shutters_slides
1.7 M *********** ./heretogohome.net/html/bo/cake/libs
1.9 M *********** ./heretogohome.net/html/bo/app
2.8 M *********** ./heretogohome.net/html/bo/cake
3.1 M ************ ./3dgolddenhouse.com/html/images
3.1 M ************ ./3dgolddenhouse.com/html/gallery/aluminum_slides
3.2 M ************ ./3dgolddenhouse.com/html/gallery/roman_shades_slides
5.3 M ************ ./heretogohome.net/html/bo
5.3 M ************ ./heretogohome.net/html
5.3 M ************ ./heretogohome.net
18.0 M ************** ./3dgolddenhouse.com/html/gallery
21.3 M ************** ./3dgolddenhouse.com/html
21.3 M ************** ./3dgolddenhouse.com
27.8 M *************** .
Linux tip: du --max-depth=1
du --max-depth=1 | sort -n | awk 'BEGIN {OFMT = "%.0f"} {print $1/1024,"MB", $2}' > diskusage.txt
Reference: http://www.cyberciti.biz/faq/find-large-files-linux/
http://serverfault.com/questions/62411/how-can-i-sort-du-h-output-by-size
Domain Redirection Using a PHP Script
Category:
PHP
— SkyHi @ Thursday, August 20, 2009
Q. How do I redirect my domain name using a php server side scripting under Apache web server?
A. Under PHP you need to use header() to send a raw HTTP header.
If you want to redirect a domain to some other URL, you can use the PHP script as below
header("Location: http://example.com/");
exit();
?>
A. Under PHP you need to use header() to send a raw HTTP header.
If you want to redirect a domain to some other URL, you can use the PHP script as below
header("Location: http://example.com/");
exit();
?>
PHP Test mysql connection
<?php
$hostname="db2.example.com";
$user = "user";
$password = "password";
$link = mysql_connect("$hostname","$user","$password");
if (!$link) { die('Could not connect to MySQL: ' . mysql_error()); }
echo 'Connection OK';
$dbname = "dbai";
$selected = mysql_select_db("$dbname", $link) or die("could not open db". mysql_error());
mysql_close($link);
?>
Incremental vs Differential Backups. What's the strategic difference?
Category:
Windows Server
— SkyHi @ Thursday, August 20, 2009
Incremental backups reset the archive bit and differential backups do not.
I use a differential backup when installing something that is complex and multi-step. I can create a differential backup after each step and essentially save my work up to that point. If anything goes horribly wrong, I can restore up to the last working step and not have my changes skipped by my regular incremental backup after I am finished.
The main benefit of a differential is you only need to use the last differential and last full backup to recover all of your data in event of a loss ect.
if you use incremental your backups are a lot quicker as it only backs up any changes since the last incremental, differential backs up everything that has changed since the last full backup so they are larger.
so say you lost all your data, if you used incremental you would need to restore the last full backup and every incremental backup since then.
If you used differential, you would restore the last full backup and the last differential backup.
It all depends on how much storage and how much time you have to do the backups.
Hope this helps.
Andy
Reference: http://community.spiceworks.com/topic/30516
What's the difference between differential and incremental backups (and why should I care)?
Both differential and incremental backups are "smart" backups that save time and disk space by only backing up changed files. But they differ significantly in how they do it, and how useful the result is.
A full backup created from within Windows, of course, backs up all the files in a partition or on a disk by copying all disk sectors with data to the backup image file. Creating a full backup for unknown or damaged filesystems Acronis True Image copies all sectors to the image file, whether or not the sector contains data. This is the simplest form of backup, but it is also the most time-consuming, space-intensive and the least flexible.
Typically full backups are only done once a week and are part of an overall backup plan. Sometimes a full backup is done after a major change of the data on the disk, such as an operating system upgrade or software install. The relatively long intervals between backups mean that if something goes wrong, a lot of data is going to be lost. That's why it is wise to back up data between full backups.
Most of the information on a computer changes very slowly or not at all. This includes the applications themselves, the operating system and even most of the user data. Typically, only a small percentage of the information in a partition or disk changes on a daily, or even a weekly, basis. For that reason, it makes sense only to back up the data that has changed on a daily basis. This is the basis of sophisticated backup strategies.
Differential backups were the next step in the evolution of backup strategies. A differential backup backs up only the files that changed since the last full back. For example, suppose you do a full backup on Sunday. On Monday you back up only the files that changed since Sunday, on Tuesday you back up only the files that changed since Sunday, and so on until the next full backup. Differential backups are quicker than full backups because so much less data is being backed up. But the amount of data being backed up grows with each differential backup until the next full back up. Differential backups are more flexible than full backups, but still unwieldy to do more than about once a day, especially as the next full backup approaches.
Incremental backups also back up only the changed data, but they only back up the data that has changed since the last backup — be it a full or incremental backup. They are sometimes called "differential incremental backups," while differential backups are sometimes called "cumulative incremental backups." Confused yet? Don't be.
If you do an incremental backup on Tuesday, you only back up the data that changed since the incremental backup on Monday. The result is a much smaller, faster backup. The characteristic of incremental backups is the shorter the time interval between backups, the less data to be backed up. In fact, with sophisticated backup software like Acronis True Image, the backups are so small and so fast you can actually back up every hour, or even more frequently, depending on the work you're doing and how important it is to have current backups.
While incremental backups give much greater flexibility and granularity (time between backups), they have the reputation for taking longer to restore because the backup has to be reconstituted from the last full backup and all the incremental backups since. Acronis True Image uses special snapshot technology to rebuild the full image quickly for restoration. This makes incremental backups much more practical for the average enterprise.
Reference: http://www.acronis.com/resource/solutions/backup/2005/incremental-backups.html
I use a differential backup when installing something that is complex and multi-step. I can create a differential backup after each step and essentially save my work up to that point. If anything goes horribly wrong, I can restore up to the last working step and not have my changes skipped by my regular incremental backup after I am finished.
The main benefit of a differential is you only need to use the last differential and last full backup to recover all of your data in event of a loss ect.
if you use incremental your backups are a lot quicker as it only backs up any changes since the last incremental, differential backs up everything that has changed since the last full backup so they are larger.
so say you lost all your data, if you used incremental you would need to restore the last full backup and every incremental backup since then.
If you used differential, you would restore the last full backup and the last differential backup.
It all depends on how much storage and how much time you have to do the backups.
Hope this helps.
Andy
Reference: http://community.spiceworks.com/topic/30516
What's the difference between differential and incremental backups (and why should I care)?
Both differential and incremental backups are "smart" backups that save time and disk space by only backing up changed files. But they differ significantly in how they do it, and how useful the result is.
A full backup created from within Windows, of course, backs up all the files in a partition or on a disk by copying all disk sectors with data to the backup image file. Creating a full backup for unknown or damaged filesystems Acronis True Image copies all sectors to the image file, whether or not the sector contains data. This is the simplest form of backup, but it is also the most time-consuming, space-intensive and the least flexible.
Typically full backups are only done once a week and are part of an overall backup plan. Sometimes a full backup is done after a major change of the data on the disk, such as an operating system upgrade or software install. The relatively long intervals between backups mean that if something goes wrong, a lot of data is going to be lost. That's why it is wise to back up data between full backups.
Most of the information on a computer changes very slowly or not at all. This includes the applications themselves, the operating system and even most of the user data. Typically, only a small percentage of the information in a partition or disk changes on a daily, or even a weekly, basis. For that reason, it makes sense only to back up the data that has changed on a daily basis. This is the basis of sophisticated backup strategies.
Differential backups were the next step in the evolution of backup strategies. A differential backup backs up only the files that changed since the last full back. For example, suppose you do a full backup on Sunday. On Monday you back up only the files that changed since Sunday, on Tuesday you back up only the files that changed since Sunday, and so on until the next full backup. Differential backups are quicker than full backups because so much less data is being backed up. But the amount of data being backed up grows with each differential backup until the next full back up. Differential backups are more flexible than full backups, but still unwieldy to do more than about once a day, especially as the next full backup approaches.
Incremental backups also back up only the changed data, but they only back up the data that has changed since the last backup — be it a full or incremental backup. They are sometimes called "differential incremental backups," while differential backups are sometimes called "cumulative incremental backups." Confused yet? Don't be.
If you do an incremental backup on Tuesday, you only back up the data that changed since the incremental backup on Monday. The result is a much smaller, faster backup. The characteristic of incremental backups is the shorter the time interval between backups, the less data to be backed up. In fact, with sophisticated backup software like Acronis True Image, the backups are so small and so fast you can actually back up every hour, or even more frequently, depending on the work you're doing and how important it is to have current backups.
While incremental backups give much greater flexibility and granularity (time between backups), they have the reputation for taking longer to restore because the backup has to be reconstituted from the last full backup and all the incremental backups since. Acronis True Image uses special snapshot technology to rebuild the full image quickly for restoration. This makes incremental backups much more practical for the average enterprise.
Reference: http://www.acronis.com/resource/solutions/backup/2005/incremental-backups.html
Subscribe to:
Posts (Atom)
