# Using a 3TB drive with linux



## wmorri

So I recently got a 3TB drive, and wanted to use it on my latest computer. That said I have since found out that it is just about useless, as the MBR can't recognize it. Not sure what I need to do to have it work on linux. Looking for a little help.


----------



## SpywareDr

1) Does your system's BIOS support 3TB?

2) If you're trying to use 512-byte sectors, the MBR partition table can only handle 2^32 x 512 = 2,199,023,255,552 (2.2 GB).


----------



## hal8000

Drives above 2.2TB need to be formatted with a GPT partition table, short for GUID Partition Table.

The advantages of GPT are many including a maximum of 128 partitions
(no primary or logical partitions) and 64bit addressing for LBA sector numbers
increasing the maximum addressable disk size to 2 Zebibyte (ZiB).
1 ZiB = 2^70 bytes so youre not going to run out of disk space for a while.

Once the disk has been partition with a GPT it can be read with grub2 so you should find all is well again. 
Your system BIOS does not really matter as BIOS only has to initialize hardware for windows. 
Your BIOS may in fact recognise your drive as a smaller capacity drive, but this does not matter because after grub has loaded, control is passed to the linux kernel (and all hardware is initiaised again). Both grub2 and the kernel can read GPT so your 3TB drive will be fully functional again.

The MacOSX has always used a GPT partition table so there is no problem with large drives on Macs.

Here is a link for GPT:
https://wiki.archlinux.org/index.php/GUID_Partition_Table

Gparted or the gparted fdisk tool should allow you to create partitions on your new drive.
What I would suggest is again to start with 3 partitions ( if this is a new install) of /, /swap and /home or maybe a larger partition if it is used for backup.

I have a spare 160G HD which I am going to experiment with with a gpt partition table.
I'm pretty sure the kernel will still call the drive /dev/sda1 etc so creating a new ext4 filesystem should be the same
mkfs.ext4 /dev/sda1

I'll check back tomorrow for updates from you.


----------



## hal8000

Large Disk Howto

A very quick quide on how to use large disks > 2.2TB
Your system BIOS may see the drive as a different size (in windows).
On FreeBSD, NAS storage devices, Mac's and Linux that use a GPT GUID Partition table this is not a problem.

When booting any linux or FreeBSD system, one of the first jobs for the kernel is to initialise all hardware. 

Requirements
Any kernel > 2.6.29
Grub2 as Bootloader
Gparted to create partitions

As an example I had a spare 160G IDE hard drive that I connected via a USB caddy to a working Mint 14 system. The disk had a single ext3 partition and was recognised as sdc1

Creating the GPT Partition Table
As root (or sudo)
sudo parted /dev/sdc
mklabel gpt

The above command strips all partitions and creates a new blank GPT partition table.

Creating the partitions
The gparted format requires just start and end sizes in GB and a partition name, so
sudo gparted /dev/sdc
mkpart Backup 0 40G

(the above command creates a 40G Partition called Backup) Gparted reserves
the first 34 sectors for its partition table so will start at 17k which is neglibible
compared to 40G.

Creating a Filesystem
Gparted can also create the filesystem but does not support ext3 or ext4 at this time. An ext3 filesystem will be created with normal fdisk. quit gparted

sudo mkfs.ext3 /dev/sdc1

Partitions in a GPT table are recognised by the kernel as standard unix naming conventions, e,g, sdc1 is the first partition and so on.

After formatting the partition, the kernel has to reload disk parameters so either reload, or unmount and remount if drive is removable.



Create another Gparted Partition.
I'll create a second partition called Images:

sudo gparted /dev/sdc
mkpart Images 40G 80G

To list partionions just type print:

orac anc # parted /dev/sdc
GNU Parted 2.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print 
Model: WDC WD16 00AVBB-63SYA0 (scsi)
Disk /dev/sdc: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 17.4kB 40.0GB 40.0GB ext3 Backup
2 40.0GB 80.0GB 40.0GB ext3 Images

The start and end sizes are shown and name of Partition.

The standard linux fdisk, sfdisk and cfdisk do not support the new partition table. If you try to read the disk you will see a message similar to:

# fdisk /dev/sdc

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.


To format the second GPT partition quit gparted and type
sudo mkfs.ext3 /dev/sdc2

Again, either reboot or unmount and mount the hard drive to use the new file system.

To Mount a GPT Drive at Boot
Again this is simply options in your filesystem table so add a line to /etc/fstab
/dev/sdc1 /media/Backup ext3 defaults,users,exec 0 2

The above line will mount the new disk at mount point /media/Backup (which must be created first).


The GPT table works with large disks up to 2ZiB, 128 partitions and is compatible with standard linux format tools.


Use of Gparted.
Gparted is a GUI to parted which will be faster and easier to use for most people. Gparted even allows resizing of partitions, but make sure you backup any data before resizing.

Further Reading and Examples:

Fun with GPT partitioning


----------



## wmorri

Hi hal,

Sorry it took me so long to work on this. I was able to follow your steps up to creating a filesystem. I have been noticing that the drive is still only being recognized as a 31.5GB drive. Not sure why this is. I am using a Western Digital Red WD30EFRX. I don't think that it should matter though.


----------



## hal8000

Hi Wmorri,
Is that the size that BIOS reports or that seen by linux?
I would create a filesystem copy a few files then try:

df -h

It may report a different size.


----------



## joeten

Hi hal was this the idea Installing my 3TB hard drive on Debian linux step by step | BuildCube Tech Blog


----------



## hal8000

I tried searching for a blog like that but couldnt find anything suitable. The guide I wrote is essentially the same as the link, you can use 100% of the drive or a size in MB or GB and label the images as backup/ images/ whatever you like really.
A GUID table naming scheme is possibly a little easier than the standard linux naming scheme using sda1, sda2 , etc. Also you're not limited to 16 partitions, like you are with an Intel partition table and scsi emulation.
All in all a good find!


----------



## joeten

Thanks I got lucky I saw the thread and was intrigued as it was the first I had seen the question for linux don't ask me why I was


----------



## electroken

I was considering buying a 3tb drive and I want to use it as a data drive to contain movies etc and have it seen by both linux systems and windows. From what I see above I am beginning to think that is not going to be possible. I had looked into this when I saw that windows was going to have to use some special software from the drive manufacturer to be able to see the drive properly. Am I correct that i am going to have some real issues having the drive seen by windows and by linux?


----------



## hal8000

electroken said:


> I was considering buying a 3tb drive and I want to use it as a data drive to contain movies etc and have it seen by both linux systems and windows. From what I see above I am beginning to think that is not going to be possible. I had looked into this when I saw that windows was going to have to use some special software from the drive manufacturer to be able to see the drive properly. Am I correct that i am going to have some real issues having the drive seen by windows and by linux?


Windows wont recognise a drive that large, it may do if its external USB:

Everything You Need to Know About 3TB Hard Drives | PCWorld

However for movies and large files the worst thing you could do is format it with a weak filesystem like NTFS. Within days it will become fragmented, and this will accelerate wear and tear on the drive.
Use a journalledd filesystem like ext3 or ext4 and not only will the drive last longer but be almost immune to fragmentation. My Humax Foxsat HDR uses linux and the hard drive is already formatted as ext3, as are all linux based satellite receivers. Mac also use a journalled hfs+ filesystem and Mac's also use a GPT partition table as standard.

If its a media streaming solution you need then start a new thread, as there are distros already made for this like Mythbuntu, or you can install UPnp/DLNA streaming software like minidlna, mediatomb or twonky. Hope that helps.


----------



## electroken

Yes I do understand what you are saying. I will probably stick with using 2tb< drives and avoid the issues. But I am sure that simply storing files one after another hardly ever causes a drive to become fragmented. That is usually the result of numerous files saves and erases and then more files saved etc. I was told one time that the easiest way to defragment a drive is to copy off all the files to another drive and then reformat the drive and then copy the files all back to the drive.
My main issue though is that when I put the movie files on this drive it will be read not only by linux systems but by computers and other programs which use windows media player as a base to show the movie. Windows will not see the drive as far as I know. I have a stand-alone device called Xtreamer which will probably not see the drive either. Sigh! It will be so much better when either windows goes away or there is some way for all the systems to cooperate in these issues.


----------



## hal8000

electroken said:


> My main issue though is that when I put the movie files on this drive it will be read not only by linux systems but by computers and other programs which use windows media player as a base to show the movie.
> Sigh! It will be so much better when either windows goes away or there is some way for all the systems to cooperate in these issues.


One way is to create dual boot installations of windows and linux, this may or may not be a possible solution for you.


----------

