restore fstab


Recommended Posts

My comouter borked last night I got into recovery mode and went into fstab using vi

I deleted a line by mistake and wrote the file

Hiw do I regenerate the partitions to how they used to be I dont know the uuid

I kniw they are on /dev/sdbx but not sure which x they are on

If I cant fix it then I can reinstall will just be a pain in the ass

Link to comment
Share on other sites

As long as you know a little bit about your current partition layout this isn't an unrecoverable disaster. If you can boot into recovery mode, that means at least your root (and probably /usr) partitions are being mounted. That's good. Boot into recovery (single user) mode and do the following to repair your fstab:

 

# List the partitions on the disks connected to your computer.
$ parted -l
Model: ATA OCZ-AGILITY4 (scsi)
Disk /dev/sda: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  1075MB  1074MB  primary  ext4            boot
 2      1075MB  10.2GB  9127MB  primary  linux-swap(v1)
 3      10.2GB  69.1GB  58.9GB  primary  ext4
 4      69.1GB  128GB   58.9GB  primary  ext4


Model: ATA ST1000LM024 HN-M (scsi)
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop

Number  Start  End     Size    File system  Flags
 1      0.00B  1000GB  1000GB  btrfs



# If you don't have parted installed (so the previous command failed), run this one instead.
# It won't give you as much information about your partitions, but it uses only essential software.
$ ls -l /dev/sd?*
brw-rw---T 1 root disk 8,  0 Jul 16 19:36 /dev/sda
brw-rw---T 1 root disk 8,  1 Jul 16 18:17 /dev/sda1
brw-rw---T 1 root disk 8,  2 Jul 16 18:17 /dev/sda2
brw-rw---T 1 root disk 8,  3 Jul 16 18:17 /dev/sda3
brw-rw---T 1 root disk 8,  4 Jul 16 18:17 /dev/sda4
brw-rw---T 1 root disk 8, 16 Jul 16 19:36 /dev/sdb

# Now that you know the partitions available on your system, it might also be helpful to know their names.
# If you don't normally name your partitions, this might not be that helpful.
# I recommend that you use Disk Utility, GParted, or the standard filesystem utilities to label any unlabeled partitions once you recover your system.
$ ls -l /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 10 Jul 16 18:17 BOOT -> ../../sda1
lrwxrwxrwx 1 root root 10 Jul 16 18:17 DEBIAN -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 16 18:17 HOME -> ../../sda4

# Next retrieve the UUID of those partitions.
$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Jul 16 18:17 580619db-0f2b-5909-a7f0e7b151e5db471 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 16 18:17 ee1a051b-7da8-b7fb-50778f3e51e5db6dc -> ../../sda1
lrwxrwxrwx 1 root root 10 Jul 16 18:17 b7117853-fa59-2c89-63fec63651e5db8fa -> ../../sda4
lrwxrwxrwx 1 root root 10 Jul 16 18:17 afc81818-b20e-08e1-70fd64bb51e5db9b9 -> ../../sda2
lrwxrwxrwx 1 root root  9 Jul 16 19:36 32756780-977e-a3d1-f601a55451e5dba8d -> ../../sdb

# Finally add the UUID of any missing disks to your fstab.
$ vi /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda3 during installation
UUID=580619db-0f2b-5909-a7f0e7b151e5db471 /               ext4    errors=remount-ro,noatime,nodiratime,discard	0       1
# /boot was on /dev/sda1 during installation
UUID=ee1a051b-7da8-b7fb-50778f3e51e5db6dc /boot           ext4    defaults,noatime,nodiratime,discard        	0       2
# /home was on /dev/sda4 during installation
UUID=b7117853-fa59-2c89-63fec63651e5db8fa /home           ext4    defaults,noatime,nodiratime,discard        	0       2
# swap was on /dev/sda2 during installation
UUID=afc81818-b20e-08e1-70fd64bb51e5db9b9 none            swap    sw              				0       0
# /storm was on /dev/sdb during installation
UUID=32756780-977e-a3d1-f601a55451e5dba8d /storm          btrfs   defaults					0	0
Link to comment
Share on other sites

I fixed it

 

i realised if i do blkid it listed the uuid

 

then working out what i already had in the fstab i only had one in blkid that was not in there so was manaully able to add it

 

PHEW!!!

 

I will keep your instructions though in case i get stuck again :D

Link to comment
Share on other sites

blkid is a very useful utility, which is why it is mentioned in fstab. It print essentially the same information I told you to obtain from /dev/disk/*/*.

Link to comment
Share on other sites

I am stuck again lol

 

this all started when my storage dirve became loose

 

when i plug it back in and turn the computer on it says Grub cant find device

 

and puts me into grub rescue

 

but the UUID it says it cant find i dont recognise

Link to comment
Share on other sites

Is the disk securely connected to your computer again? If so, it's possible that you either have the wrong UUID or the filesystem is corrupt. Have you tried booting into single user mode again and forcing an fsck on the disk? If you cannot boot into the operating system, you can also do this from a live disc. In fact, Debian Live has a Debian Rescue disc just for that purpose. It includes standard utilities you might need to recover your system. However, you could use an Ubuntu or Fedora live disc to accomplish the same thing.

Link to comment
Share on other sites

the disk appears to be fine and the UUId it says it cant find is not in the fstab

 

thats whats confusing me

Link to comment
Share on other sites

I go on holiday on Friday will be taking my laptop with me but wont be using the storage drive

 

so the problem is fine till then

 

and if i cant fix it once i am home i will just reinstall lol

Link to comment
Share on other sites

when you use vi editor to edit any file, it create a backup of original file, you can restore the original file by searching fstab* in /etc directory.

Link to comment
Share on other sites

lol, wish i had known that already lol

 

Thanks though good to know for the future

 

oh and i now know how to work Vi lol

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.