Thursday, July 11, 2013

mount a new file system on CentOS for EC2

1. create a new volume on AWS EC2 first. (use standard for example)
2. then attach it to the instance you want to mount on. (as a device name for example /dev/sdf)
3. ssh your instance and try to mount it.

of course, change to root using $sudo -s

4. $fdisk /dev/sdf

if there is no any partition, use n to create a new one.
then use w to sync and quit

5. $/sbin/mkfs.ext4 -L /backup /dev/sdf1

to format the whole partition to ext 4 format.

6. $mkdir /your_mount_point

make a mount point

7. $mount /dev/sdf1 /your_mount_point

8. $df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1              8256952   7359700    477824  94% /
none                    290848       116    290732   1% /dev
none                    325224         0    325224   0% /dev/shm
none                    325224        56    325168   1% /var/run
none                    325224         0    325224   0% /var/lock
none                    325224         0    325224   0% /lib/init/rw
/dev/sdf1             51605436    184136  48799896   1% /your_mount_point

9. to keep it auto mount when system boot

copy the following line in /etc/mtab

/dev/sdf1 /your_mount_point ext4 rw 0 0

to /etc/fstab

for example

proc                   /proc  proc  nodev,noexec,nosuid                      0  0  
LABEL=cloudimg-rootfs  /      ext3  defaults                                 0  0  
/dev/sdb /mnt auto defaults,nobootwait,comment=cloudconfig 0 0
/dev/sdf1 /your_mount_point ext4 rw 0 0


No comments:

Post a Comment