Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Instance not connecting through ssh after doing swap partition using cloud-init

Hi All,

  1. I am trying to add a swap of 4GB within root disk of 20 GB via cloud-init in Ubuntu 14.04. The instance is getting created in openstack, however I am not able to ssh to it.

    Following is the cloud-init configuration I am using in perl:

    #cloud-config
    user: '.$username.'
    ssh_pwauth: True
    chpasswd:
    list: |
     root:'.$rootPW.'
     '.$username.':'.$userPW.'
    expire: False
    resize_rootfs: true
    disk_setup:
    /dev/sda:
      table_type: mbr
      layout: [75, [25, 82]]
      overwrite: True
    fs_setup:
        - device: /dev/sda1
          filesystem: ext4
        - device: /dev/sda2
          filesystem: swap
    mounts:
         - ["/dev/sda1", "/mnt"]
         - ["/dev/sda2", "none", "swap", "sw", "0", "0"]"
    
  2. There is a bootcmd which includes sed & mount commands in cloud-init configurations for ubuntu 14.04 as below:

    bootcmd:

    • sed -i '/rootfs/s/defaults\t/defaults,discard\t/' /etc/fstab
    • mount -o remount /

      The sed command is being used here to make the swap partition permanent.

  3. As the above sed command was giving compilation errors in my perl script, I tried following options:

    i) Escaping single quotes to make the syntax right as below:

    sed -i \'/rootfs/s/defaults\t/defaults,discard\t/\' /etc/fstab
    

    ii) Tried with double quotes however I am not sure the sed command executed.

    sed -i "/rootfs/s/defaults\t/defaults,discard\t/\" /etc/fstab
    

    iii) Directly providing mkswap and swapon options under bootcmd as below:

    bootcmd:
    - mkswap /dev/xvdb
    - swapon /dev/xvdb
    

The ssh login issue still persists.

Any suggestions or help is appreciated.

Thanks,

Prashant

Instance not connecting through ssh after doing swap partition using cloud-init

Hi All,

  1. I am trying to add a swap of 4GB within root disk of 20 GB via cloud-init in Ubuntu 14.04. The instance is getting created in openstack, however I am not able to ssh to it.

    Following is the cloud-init configuration I am using in perl:

    #cloud-config
    user: '.$username.'
    ssh_pwauth: True
    chpasswd:
    list: |
     root:'.$rootPW.'
     '.$username.':'.$userPW.'
    expire: False
    resize_rootfs: true
    disk_setup:
    /dev/sda:
      table_type: mbr
      layout: [75, [25, 82]]
      overwrite: True
    fs_setup:
        - device: /dev/sda1
          filesystem: ext4
        - device: /dev/sda2
          filesystem: swap
    mounts:
         - ["/dev/sda1", "/mnt"]
         - ["/dev/sda2", "none", "swap", "sw", "0", "0"]"
    
  2. There is a bootcmd which includes sed & mount commands in cloud-init configurations for ubuntu 14.04 as below:

    bootcmd:

    • sed -i '/rootfs/s/defaults\t/defaults,discard\t/' /etc/fstab
    • mount -o remount /

      The sed command is being used here to make the swap partition permanent.

  3. As the above sed command was giving compilation errors in my perl script, I tried following options:

    i) Escaping single quotes to make the syntax right as below:

    sed -i \'/rootfs/s/defaults\t/defaults,discard\t/\' /etc/fstab
    

    ii) Tried with double quotes however I am not sure the sed command executed.

    sed -i "/rootfs/s/defaults\t/defaults,discard\t/\" /etc/fstab
    

    iii) Directly providing mkswap and swapon options under bootcmd as below:

    bootcmd:
    - mkswap /dev/xvdb
    - swapon /dev/xvdb
    

The ssh login issue still persists.

Any suggestions or help is appreciated.

Thanks,

Prashant

-Edit-

I checked the cloudinit script using online YAML validator and removed the extra spaces. Now I am able to create the instance and connect to it through ssh. However, the root disk is not partitioned as required. I could see below entries in /etc/fstab:

LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 0
/dev/sda1       /mnt    auto    defaults,nobootwait,comment=cloudconfig 0       2
/dev/sda2       none    swap    sw,comment=cloudconfig  0       0

To view all devices marked as swap in the /etc/fstab I used the swapon --all option as below:

swapon --all
swapon: /dev/sda2: stat failed: No such file or directory

Am I missing any configurations?

Regards,

Instance Root disk not connecting through ssh after doing swap partition using getting partitioned via cloud-init

Hi All,

  1. I am trying to add a swap of 4GB within root disk of 20 GB via cloud-init in Ubuntu 14.04. The instance is getting created in openstack, however I am not able to ssh to it.

    Following is the cloud-init configuration I am using in perl:

    #cloud-config
    user: '.$username.'
    ssh_pwauth: True
    chpasswd:
    list: |
     root:'.$rootPW.'
     '.$username.':'.$userPW.'
    expire: False
    resize_rootfs: true
    disk_setup:
    /dev/sda:
      table_type: mbr
      layout: [75, [25, 82]]
      overwrite: True
    fs_setup:
        - device: /dev/sda1
          filesystem: ext4
        - device: /dev/sda2
          filesystem: swap
    mounts:
         - ["/dev/sda1", "/mnt"]
         - ["/dev/sda2", "none", "swap", "sw", "0", "0"]"
    bootcmd:
         - sed -i \'/rootfs/s/defaults\t/defaults,discard\t/\' /etc/fstab
         - mount -o remount /
    
  2. There is a bootcmd which includes sed & mount commands in cloud-init configurations for ubuntu 14.04 as below:

    bootcmd:

    • sed -i '/rootfs/s/defaults\t/defaults,discard\t/' /etc/fstab
    • mount -o remount /

      The sed command is being used here to make the swap partition permanent.

  3. As the above sed command was giving compilation errors in my perl script, I tried following options:

    i) Escaping single quotes to make the syntax right as below:

    sed -i \'/rootfs/s/defaults\t/defaults,discard\t/\' /etc/fstab
    

    ii) Tried with double quotes however I am not sure the sed command executed.

    sed -i "/rootfs/s/defaults\t/defaults,discard\t/\" /etc/fstab
    

    iii) Directly providing mkswap and swapon options under bootcmd as below:

    bootcmd:
    - mkswap /dev/xvdb
    - swapon /dev/xvdb
    

The ssh login issue still persists.

Any suggestions or help is appreciated.

Thanks,

Prashant

-Edit-

I checked the cloudinit script using online YAML validator and removed the extra spaces. Now I am able to create the instance and connect to it through ssh. However, the root disk is not partitioned as required. I could see below entries in /etc/fstab:

LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 0
/dev/sda1       /mnt    auto    defaults,nobootwait,comment=cloudconfig 0       2
/dev/sda2       none    swap    sw,comment=cloudconfig  0       0

To view all devices marked as swap in the /etc/fstab I used the swapon --all option as below:

swapon --all
swapon: /dev/sda2: stat failed: No such file or directory

Am I missing any configurations?

Regards,

Root disk Instance not getting partitioned via connecting through ssh after doing swap partition using cloud-init

Hi All,

  1. I am trying to add a swap of 4GB within root disk of 20 GB via cloud-init in Ubuntu 14.04. The instance is getting created in openstack, however I am not able to ssh to it.

    Following is the cloud-init configuration I am using in perl:

    #cloud-config
    user: '.$username.'
    ssh_pwauth: True
    chpasswd:
    list: |
     root:'.$rootPW.'
     '.$username.':'.$userPW.'
    expire: False
    resize_rootfs: true
    disk_setup:
    /dev/sda:
      table_type: mbr
      layout: [75, [25, 82]]
      overwrite: True
    fs_setup:
        - device: /dev/sda1
          filesystem: ext4
        - device: /dev/sda2
          filesystem: swap
    mounts:
         - ["/dev/sda1", "/mnt"]
         - ["/dev/sda2", "none", "swap", "sw", "0", "0"]"
    bootcmd:
         - sed -i \'/rootfs/s/defaults\t/defaults,discard\t/\' /etc/fstab
         - mount -o remount /
    
  2. There is a bootcmd which includes sed & mount commands in cloud-init configurations for ubuntu 14.04 as below:

    bootcmd:

    • sed -i '/rootfs/s/defaults\t/defaults,discard\t/' /etc/fstab
    • mount -o remount /

      The sed command is being used here to make the swap partition permanent.

  3. As the above sed command was giving compilation errors in my perl script, I tried following options:

    i) Escaping single quotes to make the syntax right as below:

    sed -i \'/rootfs/s/defaults\t/defaults,discard\t/\' /etc/fstab
    

    ii) Tried with double quotes however I am not sure the sed command executed.

    sed -i "/rootfs/s/defaults\t/defaults,discard\t/\" /etc/fstab
    

    iii) Directly providing mkswap and swapon options under bootcmd as below:

    bootcmd:
    - mkswap /dev/xvdb
    - swapon /dev/xvdb
    

The ssh login issue still persists.

Any suggestions or help is appreciated.

Thanks,

Prashant

-Edit-

I checked the cloudinit script using online YAML validator and removed the extra spaces. Now I am able to create the instance and connect to it through ssh. However, the root disk is not partitioned as required. I could see below entries in /etc/fstab:

LABEL=cloudimg-rootfs   /        ext4   defaults,discard        0 0
/dev/sda1       /mnt    auto    defaults,nobootwait,comment=cloudconfig 0       2
/dev/sda2       none    swap    sw,comment=cloudconfig  0       0

To view all devices marked as swap in the /etc/fstab I used the swapon --all option as below:

swapon --all
swapon: /dev/sda2: stat failed: No such file or directory

Am I missing any configurations?

Regards,