<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.amahi.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Whetu</id>
	<title>Amahi Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.amahi.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Whetu"/>
	<link rel="alternate" type="text/html" href="https://wiki.amahi.org/index.php/Special:Contributions/Whetu"/>
	<updated>2026-04-09T10:33:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.amahi.org/index.php?title=Virus_Scan_Shares&amp;diff=85096</id>
		<title>Virus Scan Shares</title>
		<link rel="alternate" type="text/html" href="https://wiki.amahi.org/index.php?title=Virus_Scan_Shares&amp;diff=85096"/>
		<updated>2014-07-20T00:29:14Z</updated>

		<summary type="html">&lt;p&gt;Whetu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;ClamAV is an open source (GPL) antivirus engine designed for detecting Trojans, viruses, malware and other malicious threats on Linux. In this article, we will only be configuring ClamAV to run scheduled/on-demand scans; not resident scans.&lt;br /&gt;
&lt;br /&gt;
== Install ==&lt;br /&gt;
* Install required ClamAV packages&lt;br /&gt;
 yum install clamav clamav-update&lt;br /&gt;
* Edit '''/etc/freshclam.conf''' and make the following changes:&lt;br /&gt;
** Comment out “Example”&lt;br /&gt;
** Uncomment lines&lt;br /&gt;
*** “DNSDatabaseInfo current.cvd.clamav.net”&lt;br /&gt;
*** “DatabaseMirror db.XY.clamav.net” (replace XY with your [http://www.iana.org/cctld/cctld-whois.htm country code])&lt;br /&gt;
** Ensure line “DatabaseMirror database.clamav.net” is uncommented&lt;br /&gt;
* Update ClamAV’s signatures&lt;br /&gt;
 /usr/bin/freshclam&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' ClamAV will update automatically, as part of /etc/cron.daily/freshclam.&lt;br /&gt;
&lt;br /&gt;
== Configure Daily Scan ==&lt;br /&gt;
In this example, we will configure a cronjob to scan the Docs share every day:&lt;br /&gt;
* Create '''/etc/cron.daily/manual_clamscan''' and add the text from &amp;quot;a&amp;quot; or &amp;quot;b&amp;quot;:&lt;br /&gt;
:a.  &amp;lt;u&amp;gt;Scan&amp;lt;/u&amp;gt; - Change SCAN_DIR to the directory that you want to scan.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 SCAN_DIR=&amp;quot;/var/hda/files/docs&amp;quot;&lt;br /&gt;
 LOG_FILE=&amp;quot;/var/log/clamav/manual_clamscan.log&amp;quot;&lt;br /&gt;
 /usr/bin/clamscan -i -r $SCAN_DIR &amp;gt;&amp;gt; $LOG_FILE&lt;br /&gt;
:b.  &amp;lt;u&amp;gt;Scan with email notifications&amp;lt;/u&amp;gt; - Change SCAN_DIR to the directory that you want to scan, EMAIL and EMAIL_FROM to your email addresses.&lt;br /&gt;
&amp;lt;pre&amp;gt;#!/bin/bash&lt;br /&gt;
# Email alert cron job script for ClamAV&lt;br /&gt;
# Original, unmodified script by: Deven Hillard&lt;br /&gt;
#(http://www.digitalsanctuary.com/tech-blog/debian/automated-clamav-virus-scanning.html)&lt;br /&gt;
# Modified to show infected and/or removed files&lt;br /&gt;
# Directories to scan&lt;br /&gt;
SCAN_DIR=&amp;quot;/var/hda/files/docs&amp;quot;&lt;br /&gt;
# Location of log file&lt;br /&gt;
LOG_FILE=&amp;quot;/var/log/clamav/manual_clamscan.log&amp;quot;&lt;br /&gt;
# Uncomment to have scan remove files&lt;br /&gt;
#AGGRESSIVE=1&lt;br /&gt;
# Uncomment to have scan not remove files&lt;br /&gt;
AGGRESSIVE=0&lt;br /&gt;
# Email Subject&lt;br /&gt;
SUBJECT=&amp;quot;Infections detected on `hostname`&amp;quot;&lt;br /&gt;
# Email To&lt;br /&gt;
EMAIL=&amp;quot;your.email@your.domain.com&amp;quot;&lt;br /&gt;
# Email From&lt;br /&gt;
EMAIL_FROM=&amp;quot;clamav@server.hostname.com&amp;quot;&lt;br /&gt;
check_scan () {&lt;br /&gt;
    # If there were infected files detected, send email alert&lt;br /&gt;
    if [ `tail -n 12 ${LOG_FILE}  | grep Infected | grep -v 0 | wc -l` != 0 ]&lt;br /&gt;
    then&lt;br /&gt;
    # Count number of infections&lt;br /&gt;
        SCAN_RESULTS=$(tail -n 10 $LOG_FILE | grep 'Infected files')&lt;br /&gt;
        INFECTIONS=${SCAN_RESULTS##* }&lt;br /&gt;
 &lt;br /&gt;
        EMAILMESSAGE=`mktemp /tmp/virus-alert.XXXXX`&lt;br /&gt;
        echo &amp;quot;To: ${EMAIL}&amp;quot; &amp;gt;&amp;gt;  ${EMAILMESSAGE}&lt;br /&gt;
        echo &amp;quot;From: ${EMAIL_FROM}&amp;quot; &amp;gt;&amp;gt;  ${EMAILMESSAGE}&lt;br /&gt;
        echo &amp;quot;Subject: ${SUBJECT}&amp;quot; &amp;gt;&amp;gt;  ${EMAILMESSAGE}&lt;br /&gt;
        echo &amp;quot;Importance: High&amp;quot; &amp;gt;&amp;gt; ${EMAILMESSAGE}&lt;br /&gt;
        echo &amp;quot;X-Priority: 1&amp;quot; &amp;gt;&amp;gt; ${EMAILMESSAGE}&lt;br /&gt;
        if [ $AGGRESSIVE = 1 ]&lt;br /&gt;
        then&lt;br /&gt;
                echo -e &amp;quot;\n`tail -n $((10 + ($INFECTIONS*2))) $LOG_FILE`&amp;quot; &amp;gt;&amp;gt; ${EMAILMESSAGE}&lt;br /&gt;
        else&lt;br /&gt;
                echo -e &amp;quot;\n`tail -n $((10 + $INFECTIONS)) $LOG_FILE`&amp;quot; &amp;gt;&amp;gt; ${EMAILMESSAGE}&lt;br /&gt;
        fi&lt;br /&gt;
        sendmail -t &amp;lt; ${EMAILMESSAGE}&lt;br /&gt;
    fi&lt;br /&gt;
}&lt;br /&gt;
if [ $AGGRESSIVE = 1 ]&lt;br /&gt;
then&lt;br /&gt;
        /usr/bin/clamscan -ri --remove $SCAN_DIR &amp;gt;&amp;gt; $LOG_FILE&lt;br /&gt;
else&lt;br /&gt;
        /usr/bin/clamscan -ri $SCAN_DIR &amp;gt;&amp;gt; $LOG_FILE&lt;br /&gt;
fi&lt;br /&gt;
check_scan&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Give our cron script executable permissions:&lt;br /&gt;
 chmod +x /etc/cron.daily/manual_clamscan&lt;br /&gt;
* Create empty log file&lt;br /&gt;
 mkdir -p /var/log/clamav&lt;br /&gt;
 touch /var/log/clamav/manual_clamscan.log&lt;br /&gt;
* (OPTIONAL) Run the script&lt;br /&gt;
 /etc/cron.daily/manual_clamscan&lt;br /&gt;
&lt;br /&gt;
And you’re done! That should be the minimum required to install ClamAV and Perform a daily scan of a specific directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''NOTE:'''  You will need to enable email on your HDA to use option &amp;quot;b&amp;quot;.  See [[Main_Page#Community_Tutorials|Community Tutorials]] for guidance.&lt;br /&gt;
&lt;br /&gt;
==== Incremental Daily and Full Weekly Scans ====&lt;br /&gt;
You can expand on the above by making a daily cronjob script that only scans files changed in the last 24 hours, and a weekly cronjob script that does a full filesystem scan.  You may choose to do this for reasons of efficiency, as scanning only the files changed in the last 24 hours is an order of magnitude faster.  Your daily cron file would look something more like this:&lt;br /&gt;
{{Code|Code =&lt;br /&gt;
#!/usr/bin/env bash&lt;br /&gt;
&lt;br /&gt;
# Variables&lt;br /&gt;
DATE=$(date +%Y%m%d)&lt;br /&gt;
DIR=&amp;quot;/var/log/clamav&amp;quot;&lt;br /&gt;
LIST=&amp;quot;${DIR}/scan.$DATE&amp;quot;&lt;br /&gt;
RESULTS=&amp;quot;${DIR}/scanresults.${DATE}&amp;quot;&lt;br /&gt;
# A list of partitions and/or directories to scan, in this example /, /boot and /home are on separate partitions&lt;br /&gt;
SCANDIRS=&amp;quot;/ /boot /home&amp;quot;&lt;br /&gt;
# Number of days to keep files generated by this script.  Default is 7.&lt;br /&gt;
LOGROTATION=7&lt;br /&gt;
&lt;br /&gt;
# Remove files older than the number of days set with the $LOGROTATION variable.&lt;br /&gt;
#  One might choose to comment this out and keep the files for trend-tracing, breakfix etc), &lt;br /&gt;
find ${DIR} -name &amp;quot;scan*&amp;quot; -mtime +${LOGROTATION} -exec rm -f {} \;&lt;br /&gt;
&lt;br /&gt;
# Generate a list of files created in the last 24 hours, this list is fed into clamscan&lt;br /&gt;
# Because we're using -mount to prevent unwanted filesystem traversal, &lt;br /&gt;
# you'll need to specify per partition or directory with the SCANDIRS variable.&lt;br /&gt;
for S in ${SCANDIRS}; do&lt;br /&gt;
	find &amp;quot;${S}&amp;quot; -mount -mtime 0 &amp;gt;&amp;gt; &amp;quot;${LIST}&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# Run clamscan against the list of files and pipe the results out to the results file&lt;br /&gt;
# -i prints only infected files, -f is the list of files to scan, and -l is the output log&lt;br /&gt;
clamscan -i -f &amp;quot;${LIST}&amp;quot; -l &amp;quot;${RESULTS}&amp;quot;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Using Greyhole ==&lt;br /&gt;
You will need to do some additional setup to scan files when using Greyhole.&lt;br /&gt;
&lt;br /&gt;
* Set up [https://wiki.amahi.org/index.php/Mount_Shares_Locally mount shares locally]&lt;br /&gt;
* Ensure the SCAN_DIR= &amp;lt;code&amp;gt;/mnt/samba/share&amp;lt;/code&amp;gt; and not &amp;lt;code&amp;gt;/var/hda/files/share&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now when the daily scan runs, it will scan the Greyhole enabled share correctly.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
* [https://www.centosblog.com/how-to-install-clamav-and-configure-daily-scanning-on-centos/ How to Install ClamAV and Configure Daily Scanning on CentOS]&lt;br /&gt;
&lt;br /&gt;
* [https://hacking.im/automated-clam-antivirus-scanning-for-centos-servers Automated Clam AntiVirus scanning for CentOS/Ubuntu/Debian servers]&lt;/div&gt;</summary>
		<author><name>Whetu</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.amahi.org/index.php?title=Partitions_Over_2.1_TB&amp;diff=45775</id>
		<title>Partitions Over 2.1 TB</title>
		<link rel="alternate" type="text/html" href="https://wiki.amahi.org/index.php?title=Partitions_Over_2.1_TB&amp;diff=45775"/>
		<updated>2011-08-24T01:18:02Z</updated>

		<summary type="html">&lt;p&gt;Whetu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
As hard drives have increased in capacity over time, some clever workarounds have been engineered to keep breaking barriers, such as the move from CHS to LBA.  Unfortunately, with older style MBR partitions, there is a limit of 2.1TB that simply cannot be worked around using an MBR partition.  We have to instead use newer GPT style partitions.&lt;br /&gt;
&lt;br /&gt;
I'm not going to delve into the history too much, you can google/wikipedia it yourself if you like.&lt;br /&gt;
&lt;br /&gt;
So, if you've just purchased a snazzy new 3TB drive like a Western Digital Caviar Green, and you're scratching your head as to why you can't get the full capacity, here's the fix.&lt;br /&gt;
&lt;br /&gt;
=Assumptions=&lt;br /&gt;
The below documentation assumes you have an existing boot drive with Amahi, namely /dev/sda.  Your &amp;gt;2.1TB HDD will be /dev/sdb&lt;br /&gt;
&lt;br /&gt;
The instructions also assume a Linux terminal, such as that on your Amahi box (either using its console, the Terminal application within the GUI, or SSH'd in)&lt;br /&gt;
&lt;br /&gt;
=Warning=&lt;br /&gt;
BE ABSOLUTELY SURE THAT YOU ARE RUNNING THESE COMMANDS AGAINST THE CORRECT DRIVE.  I ACCEPT NO RESPONSIBILITY FOR ANY DATA LOSS ETC!&lt;br /&gt;
&lt;br /&gt;
=OK, Let's do it=&lt;br /&gt;
First we label the drive with a GPT partition&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb mklabel gpt&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we select sectors as a unit of measurement&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb unit s&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we make the partition.  &lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb mkpart primary ext2 2048 -1&lt;br /&gt;
}}&lt;br /&gt;
Parted may complain about the last sector and will automatically suggest a correct sector, just say Yes to the prompt.&lt;br /&gt;
&lt;br /&gt;
We make it as a primary partition, ext2 filesystem, and we carefully select the sectors.  The first number MUST be divisible by 8, so you can try 40, 48, 56, 64 etc...  For me these numbers threw up errors, so I just went to 2048 and everything worked fine, and in the grand scheme of a 3TB drive, the extra sectors don't really matter :)&lt;br /&gt;
&lt;br /&gt;
The reason that the starting sector is divisible by 8 is for aligning the sectors.  This is because HDD's have traditionally been based around 512-byte sectors, yet newer, higher capacity HDD's are now arriving based around 4096-byte (a.k.a. 4k) sectors.  The partitioning will still work with 512-bytes, but the drive's performance will be drastically impacted - in some testing it can be twice as slow, in others up to 25 times slower, depending on the sector alignment.  So it's important to get this right!!!&lt;br /&gt;
&lt;br /&gt;
=Alternative Parted usage=&lt;br /&gt;
Instead of the sequence of one liners up there, you can enter into parted itself like this.  I give this as I don't know how your version of parted is going to behave.  The interactive stuff from parted has been removed:&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb&lt;br /&gt;
(parted) mklabel gpt&lt;br /&gt;
(parted) unit s&lt;br /&gt;
(parted) mkpart primary ext2 2048 -1&lt;br /&gt;
(parted) quit&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=Format the drive!=&lt;br /&gt;
Finally, let's get that drive formatted to a nice ext4 volume:&lt;br /&gt;
{{Code|&lt;br /&gt;
mkfs.ext4 -T largefile4 /dev/sdb1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=Adding the drive to your HDA=&lt;br /&gt;
Normally to add a drive to Amahi, you would run the script '''hda-diskmount''', which searches for any unmounted drives and mounts them.  Unfortunately, this script doesn't yet cater for GPT partitions.  It runs an '''fdisk -l''' and searches out drives with a Linux system type, and with what it finds it mounts any that aren't mounted.&lt;br /&gt;
&lt;br /&gt;
If we run '''fdisk -l''' by itself, we will see that our new drive doesn't return a system type of 'Linux', instead it returns 'GPT' as well as a warning:&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes&lt;br /&gt;
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors&lt;br /&gt;
Units = sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 4096 bytes&lt;br /&gt;
I/O size (minimum/optimal): 4096 bytes / 4096 bytes&lt;br /&gt;
Disk identifier: 0x00000000&lt;br /&gt;
&lt;br /&gt;
   Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;
/dev/sdb1               1  4294967295  2147483647+  ee  GPT&lt;br /&gt;
Partition 1 does not start on physical sector boundary.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
So hda-diskmount correctly ignores the drive.  You can either [http://forums.amahi.org/viewtopic.php?f=15&amp;amp;t=2326 fix hda-diskmount], or you can manually mount the drives with the instructions below.&lt;br /&gt;
&lt;br /&gt;
First we make our mount point&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
mkdir /var/hda/files/drives/sdb1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Next we exercise good practice and backup our fstab file, I like to use `date +%Y%m%d` to give the name a date stamp e.g. /etc/fstab.20110731 represents a backup done on the 31st of July, 2011.  This isn't necessary, you could just use something like 'fstab.old', but date-stamping your file backups is a good habit to get into&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= cp /etc/fstab /etc/fstab.`date +%Y%m%d`&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we adjust the fstab file&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= echo -e /dev/sdb1$'\t\t'/var/hda/files/drives/sdb1$'\t'ext4$'\t'defaults$'\t'1 1 &amp;gt;&amp;gt; /etc/fstab&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
What this does is adds a line to the /etc/fstab file, telling it that when Amahi boots, it has to mount the drive.  The $'\t' entries simply mean 'put in a tab space'&lt;br /&gt;
&lt;br /&gt;
If you now run '''cat /etc/fstab''' you should see a nice entry at the bottom, similar to this&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= cat /etc/fstab&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# /etc/fstab&lt;br /&gt;
# Created by anaconda on Thu Jul 28 23:56:48 2011&lt;br /&gt;
#&lt;br /&gt;
# Accessible filesystems, by reference, are maintained under '/dev/disk'&lt;br /&gt;
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info&lt;br /&gt;
#&lt;br /&gt;
/dev/mapper/vg_hda-LogVol01 /                       ext4    defaults        1 1&lt;br /&gt;
UUID=cc1204dd-a4f8-42f8-8736-b5970251a865 /boot                   ext4    defaults        1 2&lt;br /&gt;
/dev/mapper/vg_hda-LogVol00 swap                    swap    defaults        0 0&lt;br /&gt;
tmpfs                   /dev/shm                tmpfs   defaults        0 0&lt;br /&gt;
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0&lt;br /&gt;
sysfs                   /sys                    sysfs   defaults        0 0&lt;br /&gt;
proc                    /proc                   proc    defaults        0 0&lt;br /&gt;
/dev/sdb1		/var/hda/files/drives/sdb1	ext4	defaults	1 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you can either reboot to allow the fstab file to mount your new drive, or you can simply run '''mount -a'''&lt;br /&gt;
&lt;br /&gt;
Now if you run mount by itself, you should see your drive listed e.g.&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= mount&lt;br /&gt;
/dev/mapper/vg_hda-LogVol01 on / type ext4 (rw)&lt;br /&gt;
proc on /proc type proc (rw)&lt;br /&gt;
sysfs on /sys type sysfs (rw)&lt;br /&gt;
devpts on /dev/pts type devpts (rw,gid=5,mode=620)&lt;br /&gt;
tmpfs on /dev/shm type tmpfs (rw)&lt;br /&gt;
/dev/sda1 on /boot type ext4 (rw)&lt;br /&gt;
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)&lt;br /&gt;
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)&lt;br /&gt;
fusectl on /sys/fs/fuse/connections type fusectl (rw)&lt;br /&gt;
/dev/sdd1 on /media/520abb16-ac7c-4f65-9cc3-9e536c93dca2 type ext4 (rw,nosuid,nodev,uhelper=udisks)&lt;br /&gt;
/dev/sdb1 on /var/hda/files/drives/sdb1 type ext4 (rw)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=A note about Western Digital drives=&lt;br /&gt;
Western Digital make some nice hardware, but they are also incredibly stupid.  Many of their hard drives will automatically park their heads every 8 seconds, which wears out the hard drives very quickly, in some cases the HDD's will reach their design limit (300k parks for consumer, 600k parks for enterprise) within 3-4 months!!!  This isn't to say that the drives will necessarily die within 3-4 months, but it's still not good!&lt;br /&gt;
&lt;br /&gt;
Fortunately we can fix this using a Western Digital tool named wdidle3.  You can download it [http://support.wdc.com/product/download.asp?groupid=609&amp;amp;sid=113 here].&lt;br /&gt;
&lt;br /&gt;
Create a bootable usb drive using [http://www.freedos.org/freedos/files/ FreeDOS] and [http://unetbootin.sourceforge.net/ unetbootin], then copy wdidle.exe onto the usb drive.  Boot up your Amahi box to FreeDOS and enter the following commands:&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
c:\&lt;br /&gt;
wdidle3 /R&lt;br /&gt;
wdidle3 /S300&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This cd's you to the usb drive's root, then we run wdidle3 /R to display the current drive status, then we run wdidle3 /S300 to set the park time to 5 minutes.  Alternatively you could run wdidle3 /D to completely disable the parking.&lt;br /&gt;
&lt;br /&gt;
When you're done, simply restart the PC!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
n.b. Unetbootin was a bit finnicky for me, I found that if I created the drive with a FreeDOS live CD that it wouldn't work, but if I then re-created using unetbootin's automatic distribution download feature, the USB stick worked a treat.  YMMV.&lt;/div&gt;</summary>
		<author><name>Whetu</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.amahi.org/index.php?title=Partitions_Over_2.1_TB&amp;diff=43231</id>
		<title>Partitions Over 2.1 TB</title>
		<link rel="alternate" type="text/html" href="https://wiki.amahi.org/index.php?title=Partitions_Over_2.1_TB&amp;diff=43231"/>
		<updated>2011-07-31T01:36:53Z</updated>

		<summary type="html">&lt;p&gt;Whetu: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
As hard drives have increased in capacity over time, some clever workarounds have been engineered to keep breaking barriers, such as the move from CHS to LBA.  Unfortunately, with older style MBR partitions, there is a limit of 2.1TB that simply cannot be worked around using an MBR partition.  We have to instead use newer GPT style partitions.&lt;br /&gt;
&lt;br /&gt;
I'm not going to delve into the history too much, you can google/wikipedia it yourself if you like.&lt;br /&gt;
&lt;br /&gt;
So, if you've just purchased a snazzy new 3TB drive like a Western Digital Caviar Green, and you're scratching your head as to why you can't get the full capacity, here's the fix.&lt;br /&gt;
&lt;br /&gt;
=Assumptions=&lt;br /&gt;
The below documentation assumes you have an existing boot drive with Amahi, namely /dev/sda.  Your &amp;gt;2.1TB HDD will be /dev/sdb&lt;br /&gt;
&lt;br /&gt;
The instructions also assume a Linux terminal, such as that on your Amahi box (either using its console, the Terminal application within the GUI, or SSH'd in)&lt;br /&gt;
&lt;br /&gt;
=Warning=&lt;br /&gt;
BE ABSOLUTELY SURE THAT YOU ARE RUNNING THESE COMMANDS AGAINST THE CORRECT DRIVE.  I ACCEPT NO RESPONSIBILITY FOR ANY DATA LOSS ETC!&lt;br /&gt;
&lt;br /&gt;
=OK, Let's do it=&lt;br /&gt;
First we label the drive with a GPT partition&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb mklabel gpt&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we select sectors as a unit of measurement&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb unit s&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we make the partition.  &lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb mkpart primary ext2 2048 -1&lt;br /&gt;
}}&lt;br /&gt;
Parted may complain about the last sector and will automatically suggest a correct sector, just say Yes to the prompt.&lt;br /&gt;
&lt;br /&gt;
We make it as a primary partition, ext2 filesystem, and we carefully select the sectors.  The first number MUST be divisible by 8, so you can try 40, 48, 56, 64 etc...  For me these numbers threw up errors, so I just went to 2048 and everything worked fine, and in the grand scheme of a 3TB drive, the extra sectors don't really matter :)&lt;br /&gt;
&lt;br /&gt;
The reason that the starting sector is divisible by 8 is for aligning the sectors.  This is because HDD's have traditionally been based around 512-byte sectors, yet newer, higher capacity HDD's are now arriving based around 4096-byte (a.k.a. 4k) sectors.  The partitioning will still work with 512-bytes, but the drive's performance will be drastically impacted - in some testing it can be twice as slow, in others up to 25 times slower, depending on the sector alignment.  So it's important to get this right!!!&lt;br /&gt;
&lt;br /&gt;
=Alternative Parted usage=&lt;br /&gt;
Instead of the sequence of one liners up there, you can enter into parted itself like this.  I give this as I don't know how your version of parted is going to behave.  The interactive stuff from parted has been removed:&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb&lt;br /&gt;
(parted) mklabel gpt&lt;br /&gt;
(parted) unit s&lt;br /&gt;
(parted) mkpart primary ext2 2048 -1&lt;br /&gt;
(parted) quit&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=Format the drive!=&lt;br /&gt;
Finally, let's get that drive formatted to a nice ext4 volume:&lt;br /&gt;
{{Code|&lt;br /&gt;
mkfs.ext4 -T largefile4 /dev/sdb1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=Adding the drive to your HDA=&lt;br /&gt;
Normally to add a drive to Amahi, you would run the script hda-diskmount, which searches for any unmounted drives and mounts them.  Unfortunately, this script doesn't yet cater for GPT partitions.  It runs an '''fdisk -l''' and searches out drives with a Linux system type, and with what it finds it mounts any that aren't mounted.&lt;br /&gt;
&lt;br /&gt;
If we run '''fdisk -l''' by itself, we will see that our new drive doesn't return a system type of 'Linux', instead it returns 'GPT' as well as a warning:&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes&lt;br /&gt;
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors&lt;br /&gt;
Units = sectors of 1 * 512 = 512 bytes&lt;br /&gt;
Sector size (logical/physical): 512 bytes / 4096 bytes&lt;br /&gt;
I/O size (minimum/optimal): 4096 bytes / 4096 bytes&lt;br /&gt;
Disk identifier: 0x00000000&lt;br /&gt;
&lt;br /&gt;
   Device Boot      Start         End      Blocks   Id  System&lt;br /&gt;
/dev/sdb1               1  4294967295  2147483647+  ee  GPT&lt;br /&gt;
Partition 1 does not start on physical sector boundary.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
So hda-diskmount correctly ignores the drive.&lt;br /&gt;
&lt;br /&gt;
First we make our mount point&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
mkdir /var/hda/files/drives/sdb1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Next we exercise good practice and backup our fstab file, I like to use `date +%Y%m%d` to give the name a date stamp e.g. /etc/fstab.20110731 represents a backup done on the 31st of July, 2011.  This isn't necessary, you could just use something like 'fstab.old', but date-stamping your file backups is a good habit to get into&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= cp /etc/fstab /etc/fstab.`date +%Y%m%d`&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we adjust the fstab file&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= echo -e /dev/sdb1$'\t\t'/var/hda/files/drives/sdb1$'\t'ext4$'\t'defaults$'\t'1 1 &amp;gt;&amp;gt; /etc/fstab&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
What this does is adds a line to the /etc/fstab file, telling it that when Amahi boots, it has to mount the drive.  The $'\t' entries simply mean 'put in a tab space'&lt;br /&gt;
&lt;br /&gt;
If you now run '''cat /etc/fstab''' you should see a nice entry at the bottom, similar to this&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= cat /etc/fstab&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# /etc/fstab&lt;br /&gt;
# Created by anaconda on Thu Jul 28 23:56:48 2011&lt;br /&gt;
#&lt;br /&gt;
# Accessible filesystems, by reference, are maintained under '/dev/disk'&lt;br /&gt;
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info&lt;br /&gt;
#&lt;br /&gt;
/dev/mapper/vg_hda-LogVol01 /                       ext4    defaults        1 1&lt;br /&gt;
UUID=cc1204dd-a4f8-42f8-8736-b5970251a865 /boot                   ext4    defaults        1 2&lt;br /&gt;
/dev/mapper/vg_hda-LogVol00 swap                    swap    defaults        0 0&lt;br /&gt;
tmpfs                   /dev/shm                tmpfs   defaults        0 0&lt;br /&gt;
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0&lt;br /&gt;
sysfs                   /sys                    sysfs   defaults        0 0&lt;br /&gt;
proc                    /proc                   proc    defaults        0 0&lt;br /&gt;
/dev/sdb1		/var/hda/files/drives/sdb1	ext4	defaults	1 1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now you can either reboot to allow the fstab file to mount your new drive, or you can simply run '''mount -a'''&lt;br /&gt;
&lt;br /&gt;
Now if you run mount by itself, you should see your drive listed e.g.&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
Code= mount&lt;br /&gt;
/dev/mapper/vg_hda-LogVol01 on / type ext4 (rw)&lt;br /&gt;
proc on /proc type proc (rw)&lt;br /&gt;
sysfs on /sys type sysfs (rw)&lt;br /&gt;
devpts on /dev/pts type devpts (rw,gid=5,mode=620)&lt;br /&gt;
tmpfs on /dev/shm type tmpfs (rw)&lt;br /&gt;
/dev/sda1 on /boot type ext4 (rw)&lt;br /&gt;
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)&lt;br /&gt;
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)&lt;br /&gt;
fusectl on /sys/fs/fuse/connections type fusectl (rw)&lt;br /&gt;
/dev/sdd1 on /media/520abb16-ac7c-4f65-9cc3-9e536c93dca2 type ext4 (rw,nosuid,nodev,uhelper=udisks)&lt;br /&gt;
/dev/sdb1 on /var/hda/files/drives/sdb1 type ext4 (rw)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=A note about Western Digital drives=&lt;br /&gt;
Western Digital make some nice hardware, but they are also incredibly stupid.  Many of their hard drives will automatically park their heads every 8 seconds, which wears out the hard drives very quickly, in some cases the HDD's will reach their design limit (300k parks for consumer, 600k parks for enterprise) within 3-4 months!!!  This isn't to say that the drives will necessarily die within 3-4 months, but it's still not good!&lt;br /&gt;
&lt;br /&gt;
Fortunately we can fix this using a Western Digital tool named wdidle3.  You can download it [http://support.wdc.com/product/download.asp?groupid=609&amp;amp;sid=113 here].&lt;br /&gt;
&lt;br /&gt;
Create a bootable usb drive using [http://www.freedos.org/freedos/files/ FreeDOS] and [http://unetbootin.sourceforge.net/ unetbootin], then copy wdidle.exe onto the usb drive.  Boot up your Amahi box to FreeDOS and enter the following commands:&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
c:\&lt;br /&gt;
wdidle3 /R&lt;br /&gt;
wdidle3 /S300&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This cd's you to the usb drive's root, then we run wdidle3 /R to display the current drive status, then we run wdidle3 /S300 to set the park time to 5 minutes.  Alternatively you could run wdidle3 /D to completely disable the parking.&lt;br /&gt;
&lt;br /&gt;
When you're done, simply restart the PC!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
n.b. Unetbootin was a bit finnicky for me, I found that if I created the drive with a FreeDOS live CD that it wouldn't work, but if I then re-created using unetbootin's automatic distribution download feature, the USB stick worked a treat.  YMMV.&lt;/div&gt;</summary>
		<author><name>Whetu</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.amahi.org/index.php?title=Partitions_Over_2.1_TB&amp;diff=43225</id>
		<title>Partitions Over 2.1 TB</title>
		<link rel="alternate" type="text/html" href="https://wiki.amahi.org/index.php?title=Partitions_Over_2.1_TB&amp;diff=43225"/>
		<updated>2011-07-30T03:51:23Z</updated>

		<summary type="html">&lt;p&gt;Whetu: Created page with &amp;quot;=Introduction= As hard drives have increased in capacity over time, some clever workarounds have been engineered to keep breaking barriers, such as the move from CHS to LBA.  Unf...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
As hard drives have increased in capacity over time, some clever workarounds have been engineered to keep breaking barriers, such as the move from CHS to LBA.  Unfortunately, with older style MBR partitions, there is a limit of 2.1TB that simply cannot be worked around using an MBR partition.  We have to instead use newer GPT style partitions.&lt;br /&gt;
&lt;br /&gt;
I'm not going to delve into the history too much, you can google/wikipedia it yourself if you like.&lt;br /&gt;
&lt;br /&gt;
So, if you've just purchased a snazzy new 3TB drive like a Western Digital Caviar Green, and you're scratching your head as to why you can't get the full capacity, here's the fix.&lt;br /&gt;
&lt;br /&gt;
=Assumptions=&lt;br /&gt;
The below documentation assumes you have an existing boot drive with Amahi, namely /dev/sda.  Your &amp;gt;2.1TB HDD will be /dev/sdb&lt;br /&gt;
&lt;br /&gt;
The instructions also assume a Linux terminal, such as that on your Amahi box (either using its console, the Terminal application within the GUI, or SSH'd in)&lt;br /&gt;
&lt;br /&gt;
=Warning=&lt;br /&gt;
BE ABSOLUTELY SURE THAT YOU ARE RUNNING THESE COMMANDS AGAINST THE CORRECT DRIVE.  I ACCEPT NO RESPONSIBILITY FOR ANY DATA LOSS ETC!&lt;br /&gt;
&lt;br /&gt;
=OK, Let's do it=&lt;br /&gt;
First we label the drive with a GPT partition&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb mklabel gpt&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we select sectors as a unit of measurement&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb unit s&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Now we make the partition.  &lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb mkpart primary ext2 2048 -1&lt;br /&gt;
}}&lt;br /&gt;
Parted may complain about the last sector and will automatically suggest a correct sector, just say Yes to the prompt.&lt;br /&gt;
&lt;br /&gt;
We make it as a primary partition, ext2 filesystem, and we carefully select the sectors.  The first number MUST be divisible by 8, so you can try 40, 48, 56, 64 etc...  For me these numbers threw up errors, so I just went to 2048 and everything worked fine, and in the grand scheme of a 3TB drive, the extra sectors don't really matter :)&lt;br /&gt;
&lt;br /&gt;
The reason that the starting sector is divisible by 8 is for aligning the sectors.  This is because HDD's have traditionally been based around 512-byte sectors, yet newer, higher capacity HDD's are now arriving based around 4096-byte (a.k.a. 4k) sectors.  The partitioning will still work with 512-bytes, but the drive's performance will be drastically impacted - in some testing it can be twice as slow, in others up to 25 times slower, depending on the sector alignment.  So it's important to get this right!!!&lt;br /&gt;
&lt;br /&gt;
=Alternative Parted usage=&lt;br /&gt;
Instead of the sequence of one liners up there, you can enter into parted itself like this.  I give this as I don't know how your version of parted is going to behave.  The interactive stuff from parted has been removed:&lt;br /&gt;
{{Code|&lt;br /&gt;
parted /dev/sdb&lt;br /&gt;
(parted) mklabel gpt&lt;br /&gt;
(parted) unit s&lt;br /&gt;
(parted) mkpart primary ext2 2048 -1&lt;br /&gt;
(parted) quit&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=Format the drive!=&lt;br /&gt;
Finally, let's get that drive formatted to a nice ext4 volume:&lt;br /&gt;
{{Code|&lt;br /&gt;
mkfs.ext4 -T largefile4 /dev/sdb1&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=A note about Western Digital drives=&lt;br /&gt;
Western Digital make some nice hardware, but they are also incredibly stupid.  Many of their hard drives will automatically park their heads every 8 seconds, which wears out the hard drives very quickly, in some cases the HDD's will reach their design limit (300k parks for consumer, 600k parks for enterprise) within 3-4 months!!!  This isn't to say that the drives will necessarily die within 3-4 months, but it's still not good!&lt;br /&gt;
&lt;br /&gt;
Fortunately we can fix this using a Western Digital tool named wdidle3.  You can download it [http://support.wdc.com/product/download.asp?groupid=609&amp;amp;sid=113 here].&lt;br /&gt;
&lt;br /&gt;
Create a bootable usb drive using [http://www.freedos.org/freedos/files/ FreeDOS] and [http://unetbootin.sourceforge.net/ unetbootin], then copy wdidle.exe onto the usb drive.  Boot up your Amahi box to FreeDOS and enter the following commands:&lt;br /&gt;
&lt;br /&gt;
{{Code|&lt;br /&gt;
c:\&lt;br /&gt;
wdidle3 /R&lt;br /&gt;
wdidle3 /S300&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
This cd's you to the usb drive's root, then we run wdidle3 /R to display the current drive status, then we run wdidle3 /S300 to set the park time to 5 minutes.  Alternatively you could run wdidle3 /D to completely disable the parking.&lt;br /&gt;
&lt;br /&gt;
When you're done, simply restart the PC!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
n.b. Unetbootin was a bit finnicky for me, I found that if I created the drive with a FreeDOS live CD that it wouldn't work, but if I then re-created using unetbootin's automatic distribution download feature, the USB stick worked a treat.  YMMV.&lt;/div&gt;</summary>
		<author><name>Whetu</name></author>
		
	</entry>
</feed>