Setting up a large (2TB+) hard disk drive on Linux

Setting up a large (2TB+) hard disk drive on Linux

Published: Wednesday, 4 September 2013

Physically install the hard drive.

After installing the drive, check the BIOS has detected your new drive with the correct size.

Identify the device

Check that the device has been detected by linux, then identify the device name.

root@turtle:~# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb

This shows a hard drive sda with existing partitions sda1, sda2 and sda5. It also shows a hard drive sdb, but with no partitions detected. The new hard drive will have no partitions, so we can identify it as device sdb.

fdisk is not an option

root@turtle:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xbe043269.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: The size of this disk is 3.0 TB (3000592982016 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).


The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): q

It tells us to use parted with GPT format instead.

parted with gpt label

Create a partition using GPT format. I’ve chosen to use just 1 large partition that uses the whole disk.

root@turtle:~# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Error: /dev/sdb: unrecognised disk label
(parted) mklabel gpt
(parted) mkpart
Partition name?  []?
File system type?  [ext2]? ext3
Start? 0%
End? 100%
(parted) print
Model: ATA ST3000DM001-1CH1 (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  3001GB  3001GB

(parted) quit
Information: You may need to update /etc/fstab.

Verify that the new partition appears as a device.

root@turtle:~# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sda5  /dev/sdb  /dev/sdb1

The new partition sdb1 has appeared.

Format the partition

I’m using the ext3 file system. Use mkfs to format the drive.

root@turtle:~# mkfs.ext3 /dev/sdb1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183148544 inodes, 732566272 blocks
36628313 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
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

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Mount or add to /etc/fstab

root@turtle:~# mount /dev/sdb1  /mnt/sdb1/

The drive is now accessible via /mnt/sdb1.

You can also add the partitions to fstab.