35

I unmounted a disk (/dev/vdc1) on my server machine (it doesn't have a graphical environment) and then formatted it as an xfs file system. I forgot to mount it again and also didn't add the respective line to my fstab file.

Now, after rebooting the server, I want to mount this partition, but I can't access it. I get this error:

mount: can't find dev/vdc1 in /etc/fstab or /etc/mtab

So how should I edit my fstab file so that the system recognizes the partition again? The partition was mounted on /Data.

Dady
  • 662

3 Answers3

43

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 nano /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 run:

mount /media/Data

Because of the entry auto it should be mounted automatically on next boot.

Before the next boot, don't forget to verify the entries! On any error in the fstab file, the system will not start and you will need to recover it, by reverting the changes. You can verify the entries with:

sudo findmnt --verify
Manuel
  • 1,567
  • 12
  • 19
7

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.

KK Patel
  • 19,083
  • Thank you for the replay, i tried "sudo blkid" i got only UUID for : /dev/vda1 and /dev/vda2, is like there is no /dev/vdc1 disk (on the same time, there is this partition, cause i attached a storage disk to my server mounted on /Data and worked on it, before i do the unmount), sorry for the late replay – Dady Jun 03 '13 at 12:20
  • Not yet, but i'm gonna do it, cause i think my problem has no relation with linux, it's the storage disk's catalogue – Dady Jun 03 '13 at 13:05
  • Can you tell us more about your hardware setup? Doesn't seem to be an standard HDD – Manuel Jun 04 '13 at 05:50
3

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.

mtalexan
  • 272
  • 2
  • 9