Adding an entry to fstab

I 've unmounted a disk /dev/vdc1 on my machine, after I format it into xfs file system, I didn't mount it again, either didn't add the adequate line to fstab file.

Now when i want to mount this partition, but I can't access to it: mount: can't find dev/vdc1 in /etc/fstab or /etc/mtab. So how should I put in fstab file so the system recognizes it again ? the partition was mounted on /Data

2

3 Answers

So here we create an fstab entry for the partition:

  1. You need to create the folder for the partition and get the device id.
    Open a terminal. The folder can be created via

    sudo mkdir /media/Data
    In addition I would make the user the owner and give him the right to read/write:
    sudo chown [user]:[group] /media/Data
    sudo chmod +rw /media/Data
  2. Now the fstab entry:

    • Install libblkid1 to see device specific information: sudo apt-get install libblkid1
    • Enter sudo blkid and look for the stick. The output could be:
      /dev/sda2: UUID="32a4b76f-246e-486e-8495-31b8a781fb4c" TYPE="swap"
      /dev/sda1: UUID="31f39d50-16fa-4248-b396-0cba7cd6eff2" TYPE="ext4"
    • Then we create the fstab entry: sudo gedit /etc/fstab and append the line
      UUID=31f39d50-16fa-4248-b396-0cba7cd6eff2 /media/Data auto rw,user,auto 0 0
      (and afterwards give a empty new line to avoid warnings).

To mount the partition, open a terminal and type

mount /media/Data
Because of the entry auto it should be mounted automatically on next boot. 2

First you need to find out UUID of your disk by following command

sudo blkid

Note your disk UUID.

Now open fstab file with gedit

sudo gedit /etc/fstab

Replace your old disk UUID with your noted UUID.
Save file and reboot your system. You will be able to mount disk.

4

While Manuel seems to have answered the asked question quite fully, the question you seem to have meant to ask was: "After I unmounted a disk /dev/vdc1 from /Data and formatted it to XFS, I can't remount it. How do I remount it at /Data?"

You seem to be misunderstanding (reasonably) the error message help text that results, which is what's caused confusion about your question.

You unmounted the device, /dev/vdc1, from /Data, formatted the device to XFS, then tried to remount it and it's saying there's no such device. Since you didn't give details on the exact command(s) you ran to "format the device to XFS", I'm going to assume what you did was:

sudo mkfs.xfs -f /dev/vdc1

If you forgot the -f, or didn't answer yes to a prompt to overwrite the existing file system, the mkfs command failed.

After doing this, you should just be able to run the command

sudo mount -t xfs /dev/vdc1 /Data

Looking at the error that was generated, it appears you entered "dev/vdc1" rather than "/dev/vdc1", and/or reversed the arguments to the mount command.

If it's still giving you an error for some reason, confirm that /dev/vdc1 actually exists. You can check /var/log/syslog or run dmesg to see what the system did after you created the new file system to determine if it decided to change the device associated with the partition for some reason, or what explicit error occurred when you ran the mount command that failed.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like