Recently I got a new hard drive (3TB) for my Linux box at work. I didn’t realize that it is problematic / nightmare to do such a simple work.
First, if you try to use fdisk to add the drive, it won’t work. Or I should say… it works, but it only give you a 2TB usable space. This is a limitation of fdisk, because it can handle up to 2^32 -1 sectors (or 2TB). That’s why fdisk is not a solution here.
It seems that the only solution is using parted.
sudo parted /dev/sdd
It will return something like this:
GNU Parted 2.3 Using /dev/sdd Welcome to GNU Parted! Type 'help' to view a list of commands. (parted)
First, we want to create a label:
(parted) mklabel gpt Warning: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? Yes
Then, we want to specify the unit:
(parted) unit TB
And tell parted to use all available space:
(parted) mkpart primary 0 -0
Next, we need to review the summary:
(parted) print Model: ATA WDC WD30EZRX-00M (scsi) Disk /dev/sdd: 3.00TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File system Name Flags 1 0.00TB 3.00TB 3.00TB ext2 primary
As you can see, the size is 3TB. Don’t worry about the file system for now (ext2). If it looks good to you, now we need to leave parted.
(parted) quit Information: You may need to update /etc/fstab.
Next, we need to format the partition:
#CentOS 6 sudo mkfs.ext4 /dev/sdd1 #CentOS 7 sudo mkfs.xfs /dev/sdd1
After few seconds, it will give you some more information about your drive:
mke2fs 1.41.14 (22-Dec-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=1 blocks, Stripe width=1 blocks 183148544 inodes, 732566272 blocks 36628313 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 22357 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
Now you can use your drive, such as mounting or putting it into /etc/fstab
sudo mount /dev/sdd1 /mnt/ df /dev/sdd1 2.8T 42G 2.6T 2% /mnt
That’s it! Enjoy your new disk.
Are you sure this is alright?
Look: “Sector size (logical/physical): 512B/4096B”
For full performance you should align logical/physical sectors both to 4K (4096 bytes), otherwise performance will be severely impacted.
Thanks very much for this. I just installed 2, 3TB drives and was having some difficulties getting them to work. I basically did a cut/paste of this page, and everything worked straight away.
Did that to a WD live 3tb USB3 HDD, no problems except… Dolphin shows a 6% usage (2.7TB partition, 2.5TB free) while df shows 1% usage… Any ideas? I just got the drive so the whole 2TB limit is a new subject to me…
I think that’s normal. First of all, 3TB in Western Digital means 2.7 TB in Linux (because they have different definition on TB). By default, Linux reserves some space for its own purpose (e.g., the lost+found directory etc). If you really want to maximize the usable space, go with a different Unix like FreeBSD with ZFS. That will give you more usable space.
36628313 blocks (5.00%) reserved for the super user
answered my own question just by reading the log… sound a bit much for a storage drive, but tune2fs can fix that…
Pingback: Seagate 3TB USB hard drive does not plug and play in Linux Mint 12
Thanks a lot for your post. I too got two 3TB harddrive for my linux server without realizing of the possible issue.
I run opensuse 12.3 (64b) that I installed on a 128 GB Sata SSD drive.
After failing in many different way to format and mount my 3TB drive I found your post and tested it your method on one of the drive. I went through it and everything was fine.
On my first attempts I just mounted the newly formated /dev/sdb1 on /mnt. Worked ok. Size looked good. However when I restarted my computer there was no more /dev/sdb1.
I redid everything then mounted the drive and addeed a line in fstab. When I rebooted the computer opensuse never managed to start. It gave me the option to check a log and I found the erroro message :
Time out waiting for device-sdb1 device
Dependency failed for /mnt
So it seems opensuses can not mount this drive. Any idea if I am doing something stupid. I am not a linux expert ….
thanks a lot for your help
Since you are using SSD, you may want to Google for these terms “OpenSUSE SSD TRIM”. I know that SSD harddrive will require the TRIM support from the OS. For example, some SSD harddrive will not work on Mac OS X (which is a Unix variant) correctly because it does not have the right TRIM to the particular model. So make sure that your OS supports your SSD. If it doesn’t work, it is not a bad idea to go back to a regular hard drive.