Creating and attaching volumes using Horizon


Hi Mattbull,
Please is there any other way to create a filesystem on a volume which that does not erase the data in the volume?


Creating a filesystem on a volume is a “one time” operation - if there’s data in the volume, you’ve already created a filesystem and you shouldn’t need to do it again unless something is seriously wrong.

Please you could explain what you’re trying to achieve? I can point you in the right direction if I have some more information.

1 Like

Many thanks for your response.
I have attached a new 1TB volume on an instance, which has no space on the boot volume (completely full). After mounting, and working in the new volume I am still getting response that there is no space left on disk, and tab completion was not even working for me. I have tried to delete some files form the boot volume but the problem persists even when I am working in my new volume. I was hoping to launch a new VM, detach the new volume from the old instance and attach to new VM but did not want to lose the data in the new volume (I had already generated some data in this new volume). I tried this approach suggested by camillaip

sudo mkfs -t ext4 /dev/sdb
sudo mkdir /efn
sudo mount /dev/sdv /efn

but it still created a filesystem and l have lost the data in my new volume in trying to attach to my new VM. I am sure this is my fault for doing something wrong, but am keen to know how to detach a volume from one instance and attach to another without losing the data (if it is not a completely new volume).

I hope this explanation suffices please? Grateful for your kind assistance.


Hi Ebenn,

Yes - great explanation, thank you!

Consider your volume as a USB hard-drive, and making a filesystem as formatting that hard-drive.

You can plug in and remove your USB hard-drive to/from different computers - this is analogous to attaching and detaching volumes from VMs. When you remove your USB hard-disk (or detach your volume!), the data stay in that volume until you plug it in (attach it) to a new computer (or VM). You don’t want to format (make a new filesystem) on the hard-drive when you plug it into a new computer, else you’ll lose your data!

If you have data in a volume that you would like to attach to a new VM, don’t fdisk or mkfs!

The process to change the VM that the volume is attached to is:

  1. Detach the volume from the old VM
  2. Attach the volume to the new VM
  3. In the new VM: sudo mount /dev/sdX /home/ubuntu/mountpoint
  4. Analyse your data in your new VM

Many thanks for the prompt response.

To prevent the volume from detaching each time I reboot my VM, I am using the following after doing mount /dev/sdX mountpoint:

‘grep /dev/sd /proc/mounts’

to see where the volume is mounted. The output I get is

/dev/sda1 / ext4 ro,relatime,data=ordered 0 0
/dev/sda1 /home/linuxbrew ext4 ro,relatime,data=ordered 0 0
/dev/sdb /home/ubuntu/efn xfs rw,relatime,attr2,inode64,noquota 0 0

Then I did ‘sudo nano /etc/fstab’ into which I added the path to the mountpoint. This fstab file however comes with this information in it already:

/home/ubuntu/efn LABEL=cloudimg-rootfs / ext4 defaults 0 0
/mnt/gvl/apps/linuxbrew /home/linuxbrew none bind 0 0

So that when I add the full information to my new volume, the information in my fstab file is now

/home/ubuntu/efn LABEL=cloudimg-rootfs / ext4 defaults 0 0
/mnt/gvl/apps/linuxbrew /home/linuxbrew none bind 0 0
/dev/sdb /home/ubuntu/efn xfs rw,relatime,attr2,inode64,noquota 0 0

However when I use Ctrl+X to close the file and choose Yes to save, I am getting an error message, [ Error writing /etc/fstab: Read-only file system ]
^G Get Help ^O Write Out ^W Where Is ^K Cut Text ^J Ju

Can you please advise what I am missing in mounting my volume permanently so that it does not unmount each time I reboot?

Many thx,


A read-only filesystem suggests a deeper problem than making a filesystem and editing fstab.

Please could you give me the name of the instance that you’re working on and I’ll look into it in more detail.



Here is it please., name is Ebenn, running at Swansea.



Having looked at your post again - it appears that you’ve broken /etc/fstab. It should always have six, tab-separated columns, and the first line of yours has seven, which is why your root fs has mounted read-only:

1 2 3 4 5 6 7
/home/ubuntu/efn LABEL=cloudimg-rootfs / ext4 defaults 0 0

This should read:

1 2 3 4 5 6 7
LABEL=cloudimg-rootfs / ext4 defaults 0 0

If you want to add another volume to /etc/fstab, then it needs to be added like this (column explanations are in italics, don’t add these to /etc/fstab):

1 2 3 4 5 6
Device Mountpoint Filesystem Options Dump Check
LABEL=cloudimg-rootfs / ext4 defaults 0 0
/mnt/gvl/apps/linuxbrew /home/linuxbrew none bind 0 0
/dev/sdb /home/ubuntu/efn xfs rw,relatime,attr2,inode64,noquota 0 0

Please, please be careful editing /etc/fstab, because if you get it wrong its a pain to fix!

The simplest solution to this is to start a new instance and move the volume across to it, as described above.

If you have vitally important data or software on the root disk of this instance, please let me know and I’ll try my best to retrieve it for you.


Dear @Mattbull,
Many thanks, this is well noted.
I have the data backed up on my local drive, so I’ll start a new instance and move it accross using scp.

Just by the way–is there any issue logging into Cardiff … I have a VM with IP that refuses to let me log in since Monday.
Grateful if you can look into it for me please.

Thx again,


No problem - I’ll have a look at that instance now.

I’m not aware of any problems here and from a brief look at the VM log, it appears that this VM hasn’t returned from a reboot. Were you doing anything with /etc/fstab and /dev/sdb before you rebooted this VM?


I had added a new volume to that instance as well, last week, yes…


Broken /etc/fstab again I’m afraid!

I’ll have a go at fixing this one for you - I’ll let you know when I’m done :slight_smile:


That was easier than I anticipated - fixed now!




Most grateful @Mattbull!! I’ll be more careful this time…

1 Like

Don’t terminate your Swansea machine yet - I’ll try to fix that as well!


Ok pls…:pray::pray:


Ta dah! Done.

I should have more confidence in myself :slight_smile:.

You can check /etc/fstab on that VM for an example of how to automatically mount volumes on boot, then apply it to your VM at Cardiff.

Good luck!


Whew! So grateful Mattbull!
You’re a lifesaver!

1 Like
closed #43
Attached volume is empty and getting default Apache2 Ubuntu Default Page