Wednesday, July 8, 2015

Add a second disk on Amazon AWS EC2

Add a second disk on Amazon AWS EC2

To check the partition file:

# cat /proc/partitions

major minor  #blocks  name

 202        0    8388608 xvda
 202        1    8387584 xvda1
 202       80    1048576 xvdf

To see the filesystem type:

# df -hT

Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/xvda1     xfs       8.0G  1.4G  6.7G  17% /
devtmpfs       devtmpfs  482M     0  482M   0% /dev
tmpfs          tmpfs     497M     0  497M   0% /dev/shm
tmpfs          tmpfs     497M   13M  484M   3% /run
tmpfs          tmpfs     497M     0  497M   0% /sys/fs/cgroup

Or

# blkid -o value -s TYPE /dev/xvda1

xfs

Or

# file -Ls /dev/xvda1

/dev/xvda1: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)

Or

# ls -l /dev/block/

lrwxrwxrwx. 1 root root 7 Feb 25 22:05 202:0 -> ../xvda
lrwxrwxrwx. 1 root root 8 Feb 25 22:05 202:1 -> ../xvda1
lrwxrwxrwx. 1 root root 7 Feb 26 01:04 202:80 -> ../xvdf

# file -Ls /dev/block/202:1

/dev/block/202:1: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)

To format the disk:

# mkfs.xfs /dev/xvdf

meta-data=/dev/xvdf              isize=256    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

# file -Ls /dev/xvdf

/dev/xvdf: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)

To find the UUID of the disk:

# ls -l /dev/disk/by-uuid/

total 0
lrwxrwxrwx. 1 root root 11 Feb 25 22:05 0f790447-ebef-4ca0-b229-d0aa1985d57f -> ../../xvda1
lrwxrwxrwx. 1 root root 10 Feb 26 18:23 49c0828c-0827-4d0b-82cd-19d75d293ddf -> ../../xvdf

Create a directory without access permissions (mode 000) so that nobody will write anything to the directory when the filesystem is not mounted:

# mkdir -m 000 /vol

To mount the disk:

# mount -t xfs /dev/xvdf /vol

If you wish this device to mount automatically when you reboot the server make sure you add this to your fstab file:

# vim /etc/fstab

UUID=49c0828c-0827-4d0b-82cd-19d75d293ddf /vol xfs defaults 0 2

No comments: