Setting up a large (2TB+) hard disk drive on Linux
Physically install the hard drive.
Section titled “Physically install the hard drive.”After installing the drive, check the BIOS has detected your new drive with the correct size.
Identify the device
Section titled “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/sdbThis 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
Section titled “fdisk is not an option”root@turtle:~# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding 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 volumeslarger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUIDpartition table format (GPT).
The device presents a logical sector size that is smaller thanthe physical sector size. Aligning to a physical sector (or optimalI/O) size boundary is recommended, or performance may be impacted.
Command (m for help): qIt tells us to use parted with GPT format instead.
parted with gpt label
Section titled “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/sdbGNU Parted 2.3Using /dev/sdbWelcome to GNU Parted! Type 'help' to view a list of commands.(parted) printError: /dev/sdb: unrecognised disk label(parted) mklabel gpt(parted) mkpartPartition name? []?File system type? [ext2]? ext3Start? 0%End? 100%(parted) printModel: ATA ST3000DM001-1CH1 (scsi)Disk /dev/sdb: 3001GBSector size (logical/physical): 512B/4096BPartition Table: gpt
Number Start End Size File system Name Flags 1 1049kB 3001GB 3001GB
(parted) quitInformation: You may need to update /etc/fstab.Verify that the new partition appears as a device.
Section titled “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/sdb1The new partition sdb1 has appeared.
Format the partition
Section titled “Format the partition”I’m using the ext3 file system. Use mkfs to format the drive.
root@turtle:~# mkfs.ext3 /dev/sdb1mke2fs 1.42 (29-Nov-2011)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks183148544 inodes, 732566272 blocks36628313 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=022357 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock 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: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneMount or add to /etc/fstab
Section titled “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.