at some point servers do need storage expansion, I got this ubuntu server 14:04 running on Hyper V, and as it was running out of space so here is this how to about Ubuntu Server add new hard drive.
Lets start with listing/getting information about drives attached to server.
sudo lshw -C disk
this will present you with information about current or newly attached drives. as below
————————————————————————————–
*-disk:0
description: SCSI Disk
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
size: 50GiB (53GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: guid=fb9fc69a-9620-40e7-b1af-86d5e32c56b0 sectorsize=4096
*-disk:1
description: SCSI Disk
physical id: 0.0.2
bus info: scsi@0:0.0.2
logical name: /dev/sdb
size: 20GiB (21GB)
capabilities: partitioned partitioned:dos
configuration: sectorsize=4096 signature=078fcf65
*-cdrom
description: SCSI CD-ROM
physical id: 0.0.1
bus info: scsi@0:0.0.1
logical name: /dev/cdrom
logical name: /dev/sr0
capabilities: audio
configuration: status=ready
*-disk:2
description: SCSI Disk
physical id: 0.0.3
bus info: scsi@0:0.0.3
logical name: /dev/sdc
size: 10GiB (10GB)
configuration: sectorsize=4096
————————————————————————————————-
now we can see all disks and newly add disk here is *-disk2, NOTE DOWN logical name : /dev/sdc
so its “sdc” disk that I need to add to server.
Lets partition the disk using below cmd
sudo fdisk /dev/sdc
type m for further information on FDISK usage
————————————————————–
root@ubuntus1:~# sudo fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb9e19996.
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)
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the DOS compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help):
——————————————————————————
type n to create new partition.
I will use primary so type p for primary. and just hit ENTER for next 2 prompts about number and size as i want to just have single partition using all size. so start and finish point keep default.
Finally type w and hit enter to write information about partitioning. and this will come out of FDISK menu.
After creating single partition next we will need to format the partition , I will be using EXT3 , commands for EXT3 and EXT4 are same. so its SDC1 we are going to format.
sudo mkfs -t ext3 /dev/sdc1
Now if all goes good this should format the disk and ready for mount. But I had little issue here due to reason that I allready had DELL APP ASSURE agent installed and i got this error.
Creating journal (32768 blocks): mkfs.ext3: symbol lookup error: mkfs.ext3: undefined symbol: ext2fs_add_journal_inode2, if you don’t have DELL APPASSURE Agent installed format should finish fine for you as normal .
Next step is to create mount point and mount the newly formatted drive and add info for automatically boot on startup
lets create mount point i will go upto top level by cd .. , cd .. just to ensure not creating new dir at wrong place.
mkdir data2
now edit fstab to add mount point informaiton
vi /etc/fstab
and add below line to end of file
/dev/sdc1 /data2 ext3 defaults 0 2
save/quit your editor. make sure you use device information and mount point name etc according to your server
sudo mount -a
this will mount drive. also it will be mounted on start up etc.
just to confirm use “df -h” to display drives information
———————————————————————
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 48G 8.7G 37G 20% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 482M 4.0K 482M 1% /dev
tmpfs 99M 252K 99M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 493M 0 493M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/sda1 511M 3.4M 508M 1% /boot/efi
/dev/sdb1 20G 45M 19G 1% /media/cryodata1
/dev/sdc1 9.8G 23M 9.2G 1% /data2
——————————————————
as we can see last line shows us /dev/sdc1 is mounted on /data2
hope this will help someone.
Regards
Harjeet Singh