adding the 3TB drive - linux

A quick how-to add a `large` disk to a linux system. Why? Because I just realized how confusing and bad-written a similar post of mine is and because tonnes of friends and acquaintances just bought a `hot` in Greece microserver along with extra 3TB hard drives. This way I may not have to set them up all.

See the disks.
# lshw -C disk
  *-disk:0                
       description: ATA Disk
       product: VB0250EAVER
       physical id: 0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: HPG7
       serial: Z3T174VN
       size: 232GiB (250GB)
       capabilities: partitioned partitioned:dos
       configuration: ansiversion=5 signature=00008cb6
  *-disk:1
       description: ATA Disk
       product: WDC WD30EFRX-68A
       vendor: Western Digital
       physical id: 1
       bus info: scsi@1:0.0.0
       logical name: /dev/sdb
       version: 80.0
       serial: WD-WMC1T2590452
       size: 2794GiB (3TB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=5 guid=a605f0d3-a21a-4fee-b805-59946c3516b8
  *-disk:2
       description: ATA Disk
       product: WDC WD30EFRX-68A
       vendor: Western Digital
       physical id: 0.0.0
       bus info: scsi@2:0.0.0
       logical name: /dev/sdc
       version: 80.0
       serial: WD-WMC1T2588956
       size: 2794GiB (3TB)
       configuration: ansiversion=5


See partitions seen by the system.
# cat /proc/partitions 
major minor  #blocks  name

   8        0  244198584 sda
   8        1  242232320 sda1
   8        2          1 sda2
   8        5    1964032 sda5
   8       16 2930266584 sdb
   8       17 2930265088 sdb1
   8       32 2930266584 sdc


and what is mounted where along with file system usage.
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       228G  1.5G  215G   1% /
udev            930M  4.0K  930M   1% /dev
tmpfs           376M  232K  376M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            939M     0  939M   0% /run/shm
/dev/sdb1       2.7T  201M  2.7T   1% /data01


Apparently the new one is at /dev/sdc.

Set gpt and create one large partition
# parted /dev/sdc
GNU Parted 2.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt 
(parted) mkpart primary 0GB 3001GB                                    
(parted) print                                                            
Model: ATA WDC WD30EFRX-68A (scsi)
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3001GB  3001GB               primary
(parted) quit
Information: You may need to update /etc/fstab.                           



Format with ext4 the new partition
# mkfs.ext4 /dev/sdc1
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=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

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



Create a mount directory.
# mkdir /data02


Mount the new partition.
# mount /dev/sdc1 /data02


See mounted partitions and File System Usage.
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       228G  1.5G  215G   1% /
udev            930M  4.0K  930M   1% /dev
tmpfs           376M  236K  376M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            939M     0  939M   0% /run/shm
/dev/sdb1       2.7T  201M  2.7T   1% /data01
/dev/sdc1       2.7T  201M  2.6T   1% /data02


Unmount the new partition.
# umount /data02
make sure it is not mounted.
# mount
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sdb1 on /data01 type ext4 (rw)


Reclaim the 5% reserved for the system.
# tune2fs -m 0 /dev/sdc1
tune2fs 1.42 (29-Nov-2011)
Setting reserved blocks percentage to 0% (0 blocks)


Add the new partition and mount point to fstab.
# echo "/dev/sdc1 /data02 ext4 defaults 0 2" >> /etc/fstab


Mount everything on fstab.
# mount -a


See what is mounted where and filesystem usage again!
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       228G  1.5G  215G   1% /
udev            930M  4.0K  930M   1% /dev
tmpfs           376M  236K  376M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            939M     0  939M   0% /run/shm
/dev/sdb1       2.7T  201M  2.7T   1% /data01
/dev/sdc1       2.7T  201M  2.7T   1% /data02


done.



Adding a 3TB drive - Linux