Edit fstab on unmounted device

I tried to add swapfile to the root file system on AWS EC2 instance. Did I made a mistake during the edit of fstab?

sudo dd if=/dev/zero of=/swapfile bs=1G count=4
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s

I have edited /etc/fstab

vi /etc/fstab
/swapfile swap swap defaults 0 0

Swap worked fine but after reboot, a system doesn’t work. I have decided to attach device to another instance and remove a line in fstab, but it can’t be mounted on another instance.

mount: wrong fs type, bad option, bad superblock on /dev/xvdf,
       missing codepage or helper program, or other error

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

How can I edit fstab and remove a line with swap data on unmounted device?

lsblk -f output

NAME    FSTYPE LABEL           UUID                             MOUNTPOINT
`-xvda1 ext4   cloudimg-rootfs 7b2XXX-16d3-XXXX-b32e-1857XXXXXXXX /


It looks like you were able to pull that console output using a CLI command.

Unfortunately unless you are running your root filesystem device with Elastic Block Storage as an EBS-backed volume, there is no way to recover your root filesystem (which you will have to mount to actually modify /etc/fstab). If this is an instance-store volume, I don’t believe there is a way to recover it.

Sorry for the bad news…

Source : Link , Question Author : Goran , Answer Author : frontsidebus

Leave a Comment