38

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
  • 712

4 Answers4

46

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,597
9

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,753
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
1

I know this question was asked a long time ago (nearly 11 years ago, damn) but the top reply doesn't work anymore. I use Ubuntu 22.04.04 LTS. You can still try it though, but the disk will not be found when you try to mount it with the command:

mount /media/Data

Here is how I managed to resolve the problem: First, open a terminal with root privileges. Make sure the folder you want to mount your disk is created:

mkdir /media/Data

You'll need to download the libblkid1 package to get the disk's UUID

sudo apt-get install libblkid1

Get the UUID of the wanted disk:

sudo blkid

The output should look approximately like this:

    /dev/sdb4: UUID="1f5d1c67-9921-49df-a896-410526aa4df9" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="332c0dc1-905e-494d-9623-bac6dd6a2d36"
/dev/sdb2: UUID="1cf063e8-d147-4503-8b0b-d37506ff8b32" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="56514cdf-2863-4f9c-8b4d-2f813199b7b9"
/dev/sdb3: UUID="866b649e-58a0-4e63-b18e-dae9166486be" TYPE="swap" PARTUUID="cd3f6167-e0d7-431b-b9ff-14056cbf909a"

Copy the UUID of the wanted disk. Then, edit the fstab file:

sudo nano /etc/fstab

Now, you'll need to append a line to this file. Look at the other lines and write a new one with the same syntax (UUID will change ofc):

/dev/disk/by-uuid/1f5d1c67-9921-49df-a896-410526aa4df9 /media/Data ext4 defaults,auto 0 2

There are more options you can put on the line. Now reboot the system and you should see that your folder /media/Data has now the storage capacity of your disk. It's mounted automatically at boot.

If there are any Linux professionals here, reply to this message to give advice or correct something if I made an error. Thank y'all!