Netflix / aminator

A tool for creating EBS AMIs. This tool currently works for CentOS/RedHat Linux images and is intended to run on an EC2 instance.
Apache License 2.0
950 stars 170 forks source link

can't aminate latest HVM based amazon linux: mount: /dev/xvdf1 is write-protected, mounting read-only #205

Closed tjbaker closed 10 years ago

tjbaker commented 10 years ago

Attempting to use the latest HVM Amazon Linux AMI (ami-76817c1e) which supports the new t2 instance type fails with "stderr: mount: /dev/xvdf1 is write-protected, mounting read-only"

Here is the full debug output:

Successfully resolved amzn-ami-hvm-2014.03.2.x86_64-ebs(ami-76817c1e)
Searching for an available block device
checking if device /dev/xvdf1 is available
Checking for stale attachment. dev: /dev/xvdf1, prefix: xvd
Checking for currently attached block devices. prefix: xvd
Getting prefix for device /dev/sda1
Device prefix for /dev/sda1 is sd
Getting prefix for device /dev/sda1
Device prefix for /dev/sda1 is sd
/dev/xvdf1 not stale, using
Device /dev/xvdf1 looks good, attempting to lock.
device locked. fh = <open file '/var/aminator/lock/xvdf1', mode 'a' at 0x24f3420>, dev = /dev/xvdf1
Block device /dev/xvdf1 allocated
Timed out waiting for vol-11dcc25d to get to available(creating)
Timed out waiting for vol-11dcc25d to get to available(creating)
Volume reached state available
Volume vol-11dcc25d created
Attaching volume vol-11dcc25d to i-4d512661:/dev/sdf1(/dev/xvdf1)
/dev/xvdf1 does not exist yet.
/dev/xvdf1 does not exist yet.
Volume vol-11dcc25d attached to i-4d512661:/dev/xvdf1
command: mount   /dev/xvdf1 /var/aminator/volumes/xvdf1
stdout: 
     stderr: mount: /dev/xvdf1 is write-protected, mounting read-only
     mount: wrong fs type, bad option, bad superblock on /dev/xvdf1,
            missing codepage or helper program, or other error

            In some cases useful info is found in syslog - try
            dmesg | tail or so.

status code: 32
Unable to mount /dev/xvdf1 at /var/aminator/volumes/xvdf1: mount: /dev/xvdf1 is write-protected, mounting read-only
     mount: wrong fs type, bad option, bad superblock on /dev/xvdf1,
            missing codepage or helper program, or other error

            In some cases useful info is found in syslog - try
            dmesg | tail or so.

     Traceback (most recent call last):
       File "/usr/bin/aminate", line 10, in <module>
         sys.exit(run())
     Traceback (most recent call last):
       File "/usr/bin/aminate", line 10, in <module>
         sys.exit(run())
       File "/usr/lib/python2.6/site-packages/aminator/cli.py", line 55, in run
         sys.exit(Aminator(debug=args.debug, envname=args.env).aminate())
       File "/usr/lib/python2.6/site-packages/aminator/cli.py", line 55, in run
         sys.exit(Aminator(debug=args.debug, envname=args.env).aminate())
       File "/usr/lib/python2.6/site-packages/aminator/core.py", line 67, in aminate
         error = env.provision()
       File "/usr/lib/python2.6/site-packages/aminator/core.py", line 67, in aminate
         error = env.provision()
       File "/usr/lib/python2.6/site-packages/aminator/environment.py", line 52, in provision
         with self.volume(self.cloud, self.blockdevice) as volume:
       File "/usr/lib/python2.6/site-packages/aminator/environment.py", line 52, in provision
         with self.volume(self.cloud, self.blockdevice) as volume:
       File "/usr/lib/python2.6/site-packages/aminator/plugins/volume/linux.py", line 82, in __enter__
         self._mount()
       File "/usr/lib/python2.6/site-packages/aminator/plugins/volume/linux.py", line 82, in __enter__
         self._mount()
       File "/usr/lib/python2.6/site-packages/aminator/plugins/volume/linux.py", line 64, in _mount
         raise VolumeException(msg)
       File "/usr/lib/python2.6/site-packages/aminator/plugins/volume/linux.py", line 64, in _mount
         raise VolumeException(msg)
     aminator.exceptions.VolumeException: Unable to mount /dev/xvdf1 at /var/aminator/volumes/xvdf1: mount: /dev/xvdf1 is write-protected, mounting read-only
     mount: wrong fs type, bad option, bad superblock on /dev/xvdf1,
            missing codepage or helper program, or other error

     aminator.exceptions.VolumeException: Unable to mount /dev/xvdf1 at /var/aminator/volumes/xvdf1: mount: /dev/xvdf1 is write-protected, mounting read-only
     mount: wrong fs type, bad option, bad superblock on /dev/xvdf1,
            missing codepage or helper program, or other error

            In some cases useful info is found in syslog - try
            dmesg | tail or so.

            In some cases useful info is found in syslog - try
            dmesg | tail or so.
mtripoli commented 10 years ago

Can you provide the full command line that you executed? Also, what AMI/instance-type did you run aminate on?

tjbaker commented 10 years ago

The instance I ran aminator on was a PV based one. Is chroot jail supported across PV - HVM? We've been successful in our build pipeline with PV - PV for some time. The desire to try out t2 instances has prompted the move to HVM so I wonder if this would work HVM - HVM.

The command to aminator via maven isn't exotic:

<exec executable="sudo">
    <arg value="/usr/bin/aminate"/>
    <arg line="${debug.aminate}"/>
    <arg value="-B"/>
    <arg value="ami-76817c1e"/>
    <arg value="-n"/>
    <arg value="myname"/>
    <arg value="myrpm.noarch.rpm"/>
</exec>
mtripoli commented 10 years ago

The problem is that the AMI you selected for a base is partitioned. I ran into the same issue using this AMI. Here is the partition layout.

# parted /dev/xvdj1 print

Model: Unknown (unknown)
Disk /dev/xvdj1: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name                 Flags
128     1049kB  2097kB  1049kB               BIOS Boot Partition
 1      2097kB  8590MB  8588MB  ext3         Linux

Information: Don't forget to update /etc/fstab, if necessary.

Issue #129 contains a nice discussion describing the issues around why aminator does not support partitioned AMIs. If you want HVM, try using a non-partitioned AMI with the --vm-type hvm option.