Tuesday, February 17, 2015

Add a new disk to a Linux machine (EC2 and Ubuntu in this case)

You need more space. Create a new volume in EC2 and then attach it to the running machine. Then, log in to the machine via Putty or whatever you prefer.




fdisk -l should show the new volume, but of course it's not partitioned. This gives you the /dev/xvdf path (or whatever)


fdisk /dev/xvdf

n

1 (likely will be default)

enter (default)

enter (default)

w (writes the partition to the disk)

mkfs -t ext3 /dev/xvdf1 (that "1" at the end refers to the partition number you typed in (or selected because it was default) just above)

tune2fs -m 1 /dev/xvdf1 (reserve only 1% of space for root user - it's 5% by default, so it prevents non-root users from using this reserved space)


Now you need to mount this new disk:



mkdir /backup (I'm mounting this disk to use as a backup volume)

nano /etc/fstab (edit the fstab file, which defines which disks are mounted where on bootup)

create a new line that looks like this (then save and exit):

/dev/xvdf1 /backup ext3 defaults 0 0

mount -a (mounts all the stuff in /etc/fstab)


Now you should see your new volume showing up in /backup





No comments:

Post a Comment