BlackPhoenixx
May 30th, 2007, 04:16 PM
Speeding Up Your Hard Drives In Linux
This is my first post, trying to help anyone who want 's to speed up there hard drives.
If I'm wrong please correct me, because I know I'm not perfect.
WARNING THIS USE THIS GUIDE AT YOUR OWN RISK, YOU MAY DAMAGE YOUR DRIVE
Updated: 13-06-07
WARNING: Due to kernel updates it is possible for IDE drives to switch to the use of the SCSI driver,
this will cause that 'hdparm' cannot set certain parameters. Also if you changed your '/etc/fstab' to use certain devices like 'hd*' for
drive access. The mounting of these drives will fail. And your system may become crippled due to the kernel update.
SOLUTION for drive addressing in '/etc/fstab' - Use the 'UUID' of the drive instead of a device from '/dev'.
SOLUTION for the switch to SCSI driver due to kernel updates is still in research.
Credits for starting this little investigation goes to 'Berserker' for pointing out that 'hdparm' cannot set parameters on SCSI drives. Thanks.
Why this topic.
I searched the forum and was unable to find a good subject on speeding up your hard drives.
If you search the internet because you be leave your hard disk are working to slow, mostly you will come across the same solution. Enabling DMA.
Of course this is correct, and I will never even attempt to disagree. But there is more to be done.
This short tutorial is aimed at the rest of the options which are enabled by default on MS Windows, but have to be done manual in Linux.
This topic is not intended to be for advanced users but for the starters.
In this example I’m using ‘/dev/hda’ as standard, change it to the hard drive you want to apply the options.
Requirements: ‘hdparm’.
Install ‘hdparm’ run:
sudo apt-get install hdparm
Output is given italic.
A lot of people are afraid to use hdparm because it can damage your hard drive, that’s why this tutorial also includes some commands to verify for yourself if your drive support the options.
Step 1: Enabling DMA.
DMA stands for Direct Memory Access.
What does it do ?(short version).
It transfers data from the disk directly to the memory, bypassing the processor, which can and mostly will slow the data transfer.
So by enabling you gain transfer speed.
1.A Find out if your drive support DMA.
sudo hdparm -I /dev/hda |grep ‘DMA:’
- Include the colon’s.
- Replace /dev/hda with your hard drive
- I = Captial i
- To view all the information about your drive run: sudo hdparm –I /dev/hda
Output in my case:
DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 udma6
The ‘*’ tells you that your drive support that particular dma/udma mode.
In my case my drive support to udma2.
1.B. Enabling DMA from the console:
sudo hdparm -d1 /dev/hda
Output in my case:
/dev/hda:
setting using_dma to 1 (on)
using_dma = 1 (on)
This will activate DMA on your drive, but only while your system is running, to activate the setting every time you boot your system,
you will have to edit the ‘/etc/hdparm.conf’ file.
This will be discussed futher on, in step 4.
Step 2: Enabling 32Bit Input / Output
What most people don’t know is that when DMA is turned on it automatically only activates 16Bit Input / Output transfer while most systems support up to 32Bit.
So here we can gain additional speed.
To enable 32Bit Input / Output run:
sudo hdparm –c1 /dev/hda
- Replace /dev/hda with your hard drive
Output in my case:
/dev/hda:
setting 32-bit IO_support flag to 1
IO_support = 1 (32-bit)
I was unable to find a verification to find out if a drive support it, but I can tell that every system from Pentium II (or equal) and above supports it.
And hdparm refuses to change the setting if the drive does not support it.
Downside all current (E)IDE interfaces only have 16Bit over the ribbon cable to the interface.
If you are working with SATA drives you definitely want to enable this setting.
Step 3: Multiple Sector Count
What does it do ? It enables the option to send multiple data sector per I/O Interrupt.
(Hardware Noob explanation: Multiple post mail deliveries at once, instead of 1 delivery each time the postman visit your house.)
A setting of 16 or 32 is optimal for most current systems.
IMPORTANT: On the Western Digital Caviar Disk it’s known that this setting slows them down.
This setting reduces your operating system overhead by an average between 30%-50%,
and in most cases it increases data throughput anywhere between 5%-50%.
3.1 Find out what your drive supports.
sudo hdparm -I /dev/hda |grep 'R/W multiple sector transfer'
- Include the colon’s
- Replace /dev/hda with your hard drive.
Output in my case:
R/W multiple sector transfer: Max = 16 Current = 16
Look at the value after ‘Max =’ this is the maximum the drives support.
As you can see after ‘Current is says ‘16’. What we want to achieve is that both values are the same,
in my case the drive is already correctly activated, because Max and Current have the same value.
(I didn’t feel like changing it back for this tutorial, I’m sorry ;))
3.2 Enabling Multiple Sector Transfer
sudo hdparm –m# /dev/hda
- Replace # with the value you found at Step 3.1
- Replace /dev/hda with your hard drive.
(in my case I ran: sudo hdparm –m16 /dev/had)
Output in my case:
/dev/hda:
setting multcount to 16
multcount = 16 (on)
Multiple Sector Transfer is now activated.
Step 4: Making The Setting Permanent Each Time You Boot
To set these settings each time you boot you have to edit the ‘/etc/hdparm.conf’ file.
Open this file with your favorite editor as root, in my case I ran: sudo vi /etc/hdparm.conf
Scroll to the bottom of the file and add the following:
/dev/hda {
dma = on
io32_support = 1
mult_sect_io = 16
}
dma = on (activates DMA – Step 1)
io32_support = 1 (activates 32Bit Input Output – Step 2)
mult_sect_io = 16 (activates multiple sector transfer with your drive setting – Step 3, make sure you use the value determent at step 3.1)
You can run all of this for every hard drive you have. NOT CD/DVD Drives.
Just make an entry for each drive with it’s own settings.
Also if you experience slow data transfers for you CD/DVD drives you can also activate DMA on them.
Example of my /etc/hdparm.conf
/dev/hda {
dma = on
io32_support = 1
mult_sect_io = 16
}
/dev/hdb {
dma = on
}
/dev/hdc {
dma = on
io32_support = 1
mult_sect_io = 16
}
/dev/hdd {
dma = on
}
/dev/hdb and /dev/hdd are both DVD drives in my case.
The reason they have not yet the setting io32_support and mult_sect_io with these drives is because,
I don’t know for sure that these settings also apply to CD/DVD drives.
------------------
Sources Used:
- Trial And Error
- Man page hdparm
- http://www.go2linux.org/node/20
Tested On:
Kubuntu 7.04 – 32Bit
Uninstall / Removal
- Purge your drive entries from /etc/hdparm.conf
------------------
I hope this tutorial is useful to someone.
This is my first post, trying to help anyone who want 's to speed up there hard drives.
If I'm wrong please correct me, because I know I'm not perfect.
WARNING THIS USE THIS GUIDE AT YOUR OWN RISK, YOU MAY DAMAGE YOUR DRIVE
Updated: 13-06-07
WARNING: Due to kernel updates it is possible for IDE drives to switch to the use of the SCSI driver,
this will cause that 'hdparm' cannot set certain parameters. Also if you changed your '/etc/fstab' to use certain devices like 'hd*' for
drive access. The mounting of these drives will fail. And your system may become crippled due to the kernel update.
SOLUTION for drive addressing in '/etc/fstab' - Use the 'UUID' of the drive instead of a device from '/dev'.
SOLUTION for the switch to SCSI driver due to kernel updates is still in research.
Credits for starting this little investigation goes to 'Berserker' for pointing out that 'hdparm' cannot set parameters on SCSI drives. Thanks.
Why this topic.
I searched the forum and was unable to find a good subject on speeding up your hard drives.
If you search the internet because you be leave your hard disk are working to slow, mostly you will come across the same solution. Enabling DMA.
Of course this is correct, and I will never even attempt to disagree. But there is more to be done.
This short tutorial is aimed at the rest of the options which are enabled by default on MS Windows, but have to be done manual in Linux.
This topic is not intended to be for advanced users but for the starters.
In this example I’m using ‘/dev/hda’ as standard, change it to the hard drive you want to apply the options.
Requirements: ‘hdparm’.
Install ‘hdparm’ run:
sudo apt-get install hdparm
Output is given italic.
A lot of people are afraid to use hdparm because it can damage your hard drive, that’s why this tutorial also includes some commands to verify for yourself if your drive support the options.
Step 1: Enabling DMA.
DMA stands for Direct Memory Access.
What does it do ?(short version).
It transfers data from the disk directly to the memory, bypassing the processor, which can and mostly will slow the data transfer.
So by enabling you gain transfer speed.
1.A Find out if your drive support DMA.
sudo hdparm -I /dev/hda |grep ‘DMA:’
- Include the colon’s.
- Replace /dev/hda with your hard drive
- I = Captial i
- To view all the information about your drive run: sudo hdparm –I /dev/hda
Output in my case:
DMA: mdma0 mdma1 mdma2 udma0 udma1 *udma2 udma3 udma4 udma5 udma6
The ‘*’ tells you that your drive support that particular dma/udma mode.
In my case my drive support to udma2.
1.B. Enabling DMA from the console:
sudo hdparm -d1 /dev/hda
Output in my case:
/dev/hda:
setting using_dma to 1 (on)
using_dma = 1 (on)
This will activate DMA on your drive, but only while your system is running, to activate the setting every time you boot your system,
you will have to edit the ‘/etc/hdparm.conf’ file.
This will be discussed futher on, in step 4.
Step 2: Enabling 32Bit Input / Output
What most people don’t know is that when DMA is turned on it automatically only activates 16Bit Input / Output transfer while most systems support up to 32Bit.
So here we can gain additional speed.
To enable 32Bit Input / Output run:
sudo hdparm –c1 /dev/hda
- Replace /dev/hda with your hard drive
Output in my case:
/dev/hda:
setting 32-bit IO_support flag to 1
IO_support = 1 (32-bit)
I was unable to find a verification to find out if a drive support it, but I can tell that every system from Pentium II (or equal) and above supports it.
And hdparm refuses to change the setting if the drive does not support it.
Downside all current (E)IDE interfaces only have 16Bit over the ribbon cable to the interface.
If you are working with SATA drives you definitely want to enable this setting.
Step 3: Multiple Sector Count
What does it do ? It enables the option to send multiple data sector per I/O Interrupt.
(Hardware Noob explanation: Multiple post mail deliveries at once, instead of 1 delivery each time the postman visit your house.)
A setting of 16 or 32 is optimal for most current systems.
IMPORTANT: On the Western Digital Caviar Disk it’s known that this setting slows them down.
This setting reduces your operating system overhead by an average between 30%-50%,
and in most cases it increases data throughput anywhere between 5%-50%.
3.1 Find out what your drive supports.
sudo hdparm -I /dev/hda |grep 'R/W multiple sector transfer'
- Include the colon’s
- Replace /dev/hda with your hard drive.
Output in my case:
R/W multiple sector transfer: Max = 16 Current = 16
Look at the value after ‘Max =’ this is the maximum the drives support.
As you can see after ‘Current is says ‘16’. What we want to achieve is that both values are the same,
in my case the drive is already correctly activated, because Max and Current have the same value.
(I didn’t feel like changing it back for this tutorial, I’m sorry ;))
3.2 Enabling Multiple Sector Transfer
sudo hdparm –m# /dev/hda
- Replace # with the value you found at Step 3.1
- Replace /dev/hda with your hard drive.
(in my case I ran: sudo hdparm –m16 /dev/had)
Output in my case:
/dev/hda:
setting multcount to 16
multcount = 16 (on)
Multiple Sector Transfer is now activated.
Step 4: Making The Setting Permanent Each Time You Boot
To set these settings each time you boot you have to edit the ‘/etc/hdparm.conf’ file.
Open this file with your favorite editor as root, in my case I ran: sudo vi /etc/hdparm.conf
Scroll to the bottom of the file and add the following:
/dev/hda {
dma = on
io32_support = 1
mult_sect_io = 16
}
dma = on (activates DMA – Step 1)
io32_support = 1 (activates 32Bit Input Output – Step 2)
mult_sect_io = 16 (activates multiple sector transfer with your drive setting – Step 3, make sure you use the value determent at step 3.1)
You can run all of this for every hard drive you have. NOT CD/DVD Drives.
Just make an entry for each drive with it’s own settings.
Also if you experience slow data transfers for you CD/DVD drives you can also activate DMA on them.
Example of my /etc/hdparm.conf
/dev/hda {
dma = on
io32_support = 1
mult_sect_io = 16
}
/dev/hdb {
dma = on
}
/dev/hdc {
dma = on
io32_support = 1
mult_sect_io = 16
}
/dev/hdd {
dma = on
}
/dev/hdb and /dev/hdd are both DVD drives in my case.
The reason they have not yet the setting io32_support and mult_sect_io with these drives is because,
I don’t know for sure that these settings also apply to CD/DVD drives.
------------------
Sources Used:
- Trial And Error
- Man page hdparm
- http://www.go2linux.org/node/20
Tested On:
Kubuntu 7.04 – 32Bit
Uninstall / Removal
- Purge your drive entries from /etc/hdparm.conf
------------------
I hope this tutorial is useful to someone.