hard drive - Adding a disk to an Amazon EC2 instance

06
2014-04
  • YumYumYum

    I am using Amazon EC2 instance where I have low disk space

    [root@ip-10-59-143-73 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/xvde1            5.7G  3.3G  2.3G  60% /
    none                  1.9G     0  1.9G   0% /dev/shm
    

    I added "Elastic Block" > Volumes > 5GB volume and attached to the instance ID.

    I rebooted the instance and got a new disk device in /dev/

    [root@ip-10-59-143-73 ~]# ll /dev/xvd*
    brw-rw---- 1 root disk 202,  65 Jun 12 12:16 /dev/xvde1
    brw-rw---- 1 root disk 202, 144 Jun 12 12:16 /dev/xvdj
    brw-rw---- 1 root disk 202, 146 Jun 12 12:28 /dev/xvdj2 <<<< new one
    
    [root@ip-10-59-143-73 ~]# cat /proc/partitions
    major minor  #blocks  name
    
     202       65    6291456 xvde1  <<<< Old 6GB volume
     202      144  419395584 xvdj
     202      146    5242880 xvdj2  <<<< new one
    
    [root@ip-10-59-143-73 ~]# mount
    /dev/xvde1 on / type ext4 (rw)
    none on /proc type proc (rw)
    none on /sys type sysfs (rw)
    none on /dev/pts type devpts (rw,gid=5,mode=620)
    none on /dev/shm type tmpfs (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    
    [root@ip-10-59-143-73 ~]# cat /etc/fstab
    LABEL=_/   /         ext4    defaults        1 1
    none       /proc     proc    defaults        0 0
    none       /sys      sysfs   defaults        0 0
    none       /dev/pts  devpts  gid=5,mode=620  0 0
    none       /dev/shm  tmpfs   defaults        0 0
    

    xvde1 was old one xvdj2 may be the new one.

    How do I add the new disk to my usable disk space?

    Follow up:

    1) Clear the confusion: - Amazon EC2 does all automatic but adding disk space is not automated, it has to be manually (not like there Elastic IP or VPC like).

    2) Feed

    $ ll /dev/xvd*
    brw-rw---- 1 root disk 202,  65 Jun 12 12:37 /dev/xvde1
    brw-rw---- 1 root disk 202, 144 Jun 12 12:37 /dev/xvdj
    brw-rw---- 1 root disk 202, 146 Jun 12 12:37 /dev/xvdj2
    
    $ mkfs.ext4 /dev/xvdj
    mke2fs 1.41.12 (17-May-2010)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    26214400 inodes, 104848896 blocks
    5242444 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=4294967296
    3200 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
    
    Writing inode tables: done                            
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: <<< hit enter
    done
    
    This filesystem will be automatically checked every 37 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    
    $ cat /etc/fstab # Before
    LABEL=_/   /         ext4    defaults        1 1
    none       /proc     proc    defaults        0 0
    none       /sys      sysfs   defaults        0 0
    none       /dev/pts  devpts  gid=5,mode=620  0 0
    none       /dev/shm  tmpfs   defaults        0 0
    
    $ cat /etc/fstab # After
    LABEL=_/   /         ext4    defaults        1 1
    none       /proc     proc    defaults        0 0
    none       /sys      sysfs   defaults        0 0
    none       /dev/pts  devpts  gid=5,mode=620  0 0
    none       /dev/shm  tmpfs   defaults        0 0
    /dev/xvdj   /volume_one  ext4  noatime  0 0
    
    $ mkdir /volume_one
    $ mount /volume_one
    $ df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/xvde1            5.7G  3.3G  2.3G  60% /
    none                  1.9G     0  1.9G   0% /dev/shm
    /dev/xvdj             394G  199M  374G   1% /volume_one
    
  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    osx - Mounting an Amazon EC2 instance on Mac OS X
  • user26767

    I've got public key authentication working between my Mac OS X and an Amazon EC2 instance so that from the command-line I can just type the following and it works:

    ssh root@[IPAddressOfEC2Instance]
    

    The strange thing is that I can't seem to mount the instance using "Connect to Server" in the Finder.

    I've tried typing the following server addresses into the "Connect to Server" dialog:

    ftps://[IPAddressOfEC2Instance]
    ftps://root@[IPAddressOfEC2Instance]
    

    But all I get is

    You entered an invalid username or password. Please try again.

    The root user on the EC2 instance has a blank password and I'm wondering if it has to do with that. However, I can't change the password for the root user.

    I can use an SFTP client to connect to the machine, I just can't mount it with "Connect to server". It asks for a username and password (for a registered user) and it's root/[blank] which it doesn't accept. The other option is "Guest" which brings up an empty folder in the Finder.


  • Related Answers
  • Eric Boehs

    SFTP is not the same as FTPS. FTPS is FTP using SSL. SFTP is secure file transfer protocol (over SSH). (Mac OS X's FTP/FTPS support in Finder is pretty pathetic anyways.)

    Mac OS X can not natively mount SFTP shares. There is a way to do it using MacFUSE. It's rather difficult to set up and there's not a reliable non-commercial GUI application to manage it. There are a couple packages you have to install and a lot of command line hackery to get shares to mount (don't get me started on auto mounting them). It's really not worth the effort. I have done it a couple times before, but it was hell; I have found a much better solution: ExpanDrive.

    It's a commercial program but it's worth every penny. It uses MacFUSE and allows you to mount SFTP, FTP/FTPS, and Amazon S3 "drives". You can download a free trial which works for 30 days. (Also, it won't expire unless you close it. :))

    In order to get it to work using public key pairs you'll need to add your SSH private key to your Mac OS X keychain:

    ssh-add -K
    

    Then when you create a new drive in ExpanDrive leave the password field blank, but check the "Save" box.

    You should be good to go. The great thing about ExpanDrive is it will auto reconnect the drives if the connection gets dropped (wifi drops, you sleep/wake your mac, you reboot).

  • Josh K

    You may need to enter the username and / or password in the "Connect to Server" box in finder.

    ftps://root@[IPAddressOfEC2Instance]
    

    You can alternatively use a standalone FTP application like FileZilla or Transmit.