Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot2docker: no bash available, /etc/fstab not writable #27

Open
rsenden opened this issue Sep 2, 2014 · 2 comments
Open

boot2docker: no bash available, /etc/fstab not writable #27

rsenden opened this issue Sep 2, 2014 · 2 comments

Comments

@rsenden
Copy link

rsenden commented Sep 2, 2014

I'm trying to set up some persistent storage with the dduportal/boot2docker vagrant box, but mounting the volume fails. The /tmp/disk_operations_boot2docker-data.sh script fails to execute, as bash is not available in boot2docker. Also, /etc/fstab is not writable (as boot2docker runs from an iso).

Changing the disk_operations script to use /bin/sh fails with the following errors:
sh: LABEL="boot2docker-data": unknown operand
mke2fs 1.42.7 (21-Jan-2013)
mkfs.ext4: No such device or address while trying to determine filesystem size
mkdir: can't create directory '/data': Permission denied
/tmp/disk_operations_boot2docker-data.sh: line 16: can't create /etc/fstab: Permission denied
mount: can't find /data in /etc/fstab

Any suggestions on how to make this work with boot2docker?

@rsenden
Copy link
Author

rsenden commented Sep 8, 2014

I have now updated my copy of manage_storage.rb as follows. This uses /bin/sh instead of /bin/bash, fdisk instead sfdisk, and an approach similar to boot2docker to create the filesystem if it does not yet exist. I removed all the lvm stuff for now, as this is not supported on boot2docker. I also do not check the format flag; I format unconditionally if the filesystem does not yet exist.

        disk_operations_template = ERB.new <<-EOF
#!/bin/sh
# fdisk the disk if it's not a block device already:
PERSISTENT_DATA=`blkid -o device -l -t LABEL=#{mnt_name}`
if [ ! -n "$PERSISTENT_DATA" ]; then
    echo "Unformatted persistent data disk found; creating partition" >> /tmp/disk_operation_log.txt 2>&1
    (echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk #{disk_dev} >> /tmp/disk_operation_log.txt 2>&1
    echo "Running modprobe" >> /tmp/disk_operation_log.txt 2>&1
    modprobe >> /tmp/disk_operation_log.txt 2>&1
    echo "Creating filesystem" >> /tmp/disk_operation_log.txt 2>&1
    mkfs.#{fs_type} #{disk_dev}1 -L #{mnt_name} >> /tmp/disk_operation_log.txt 2>&1
fi
<% if mount == true %>
echo "Creating mount point" >> /tmp/disk_operation_log.txt 2>&1
[ -d #{mnt_point} ] || mkdir -p #{mnt_point} >> /tmp/disk_operation_log.txt 2>&1
#echo "Updating fstab" >> /tmp/disk_operation_log.txt 2>&1
#[ "`grep -i #{disk_dev}1 /etc/fstab`" ] || echo #{disk_dev}1 #{mnt_point} #{fs_type} #{mnt_options.join(',')} 0 0 >> /etc/fstab
echo "Mounting #{mnt_point}" >> /tmp/disk_operation_log.txt 2>&1
echo "mount -t #{fs_type} -o #{mnt_options.join(',')} #{disk_dev}1 #{mnt_point}" >> /tmp/disk_operation_log.txt 2>&1
[ "`mount | grep #{mnt_point}`" ] || mount -t #{fs_type} -o #{mnt_options.join(',')} #{disk_dev}1 #{mnt_point} >> /tmp/disk_operation_log.txt 2>&1
echo "#{mnt_point} mounting returned:  $?" >> /tmp/disk_operation_log.txt 2>&1
<% end %>
exit $?
        EOF

@mritalian
Copy link

Is there any intention to merge above change (or rather an updated version of that) into the codebase? Are so few people using boot2docker that this doesn't matter? I don't know Ruby or I'd work on this myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants