LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   editing /etc/fstab (https://www.linuxquestions.org/questions/debian-26/editing-etc-fstab-4175598827/)

Mystified 02-02-2017 01:56 PM

editing /etc/fstab
 
I want to play with lfs. I have a ext4 partition that is empty. I don't want to change fstab until I know exactly what to do. As I've mentioned before I'm just getting back to linux and don't remember how. I know lfs is ambitious but I;d like to jump in and get my feet wet. I've succeeded once before.

# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=f3a3b058-e5a4-49fb-8a04-f7c190e7bec8 / ext4 defaults 0 1
# /home was on /dev/sda3 during installation
UUID=8b050d2d-ddf2-498e-b5a4-be7bc616b1d1 /home ext4 defaults 0 2
# swap was on /dev/sda4 during installation
UUID=54ee6d31-6f6e-413d-b4e5-ab82c322d522 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

Brains 02-03-2017 12:16 AM

You'll need to make a mount point for the partition with command: sudo mkdir /mnt/lfs (I used lfs as a name, change to what you like, the /mnt directory is a good place for mounting partitions.
Run the command sudo fdisk -l to figure out the device name of the partition, then run command: sudo blkid to find the UUID of the partition. Using the "example" blkid command output below, you then add a line in /etc/fstab with same options, dump and pass entries as /, using the new directory created earlier as the mount point, a sample fstab line in second code below.

Example blkid command output
Code:

/dev/sda1: UUID="4097bf06-3fae-4f3f-b024-b4b7621ae0c9" TYPE="ext4" PTTYPE="dos" PARTUUID="eb49b0ef-01"
Example line added to fstab file
Code:

UUID=4097bf06-3fae-4f3f-b024-b4b7621ae0c9  /mnt/lfs  ext4  defaults  0  1
Although I am not sure if the old method is still required, which is to hit the Tab key after each entry rather than a space, or lining it up with other entries, I use the Tab key method, so at the end of the UUID number, hit the Tab key then add the /mnt/lfs, then hit the Tab key again, etc.

hazel 02-03-2017 02:10 AM

You don't have to use UUIDs in fstab just because the existing entries use them. Traditional device names like /dev/sda2 are quite acceptable.

A tip for editing system config files: first create a backup with a ".orig" suffix.
Code:

sudo cp /etc/fstab /etc/fstab.orig
That way, if your edit causes any trouble, you can always copy back your backup file. Also you can see at a glance any time which config files you've modified.

Turbocapitalist 02-03-2017 02:59 AM

Quote:

Originally Posted by hazel (Post 5664343)
A tip for editing system config files: first create a backup with a ".orig" suffix.
Code:

sudo cp /etc/fstab /etc/fstab.orig
That way, if your edit causes any trouble, you can always copy back your backup file. Also you can see at a glance any time which config files you've modified.

A thousand times this! It is so much easier to copy back the last known working version of fstab than it is to try to edit it in place on a borked system. I also like to include the -p option so that the date and time of the original is preserved.

rokytnji 02-03-2017 05:34 AM

May help or not.

http://www.howtogeek.com/howto/38125...-does-it-work/

Mystified 02-03-2017 07:33 AM

This is what I got

UUID=PARTUUID=e55dc00204 /mnt/lfs ext4 defaults 0 1

lfs says it can't find sda2

BW-userx 02-03-2017 08:23 AM

basic rule of thumb that goes across the platform

Code:

source -> detestation

Mystified 02-03-2017 08:41 AM

I' sorry. I don't understand. I'm so rusty.

goumba 02-03-2017 08:48 AM

Quote:

Originally Posted by hazel (Post 5664343)
You don't have to use UUIDs in fstab just because the existing entries use them. Traditional device names like /dev/sda2 are quite acceptable.

A tip for editing system config files: first create a backup with a ".orig" suffix.
Code:

sudo cp /etc/fstab /etc/fstab.orig
That way, if your edit causes any trouble, you can always copy back your backup file. Also you can see at a glance any time which config files you've modified.

Agreed, or if you think you'll be doing it often, for small files it doesn't hurt to keep backups over time, just so that if you need to go back more than one change (or set of changes):

Code:

cp -p /etc/fstab{,.$(date +%H%M-%Y%b%d)}
appends the time and date to the filename. Maybe not necessarily useful for fstab, but other files you'll be changing may be much more useful. Of course you'll want to clean up once in a while, once you're comfortable your changes are good, or you'll fill up etc (or keep the backups in another directory).

Mystified 02-03-2017 09:42 AM

I did my backup. I edited fstab as follows:
/dev/sda2 /mnt/lfs ext4 defaults 0 1

I'm getting
wrong fs type, bad option/ bad superblock, on /dev/sda2

BW-userx 02-03-2017 10:17 AM

Quote:

Originally Posted by Mystified (Post 5664510)
I did my backup. I edited fstab as follows:
/dev/sda2 /mnt/lfs ext4 defaults 0 1

I'm getting
wrong fs type, bad option/ bad superblock, on /dev/sda2

oops that is not nice.

what is on that partition / directory

Code:

blkid
you can look to see what file type it is to be sure it is ext4 .
I'd use gparted to check it for bad blocks create partition table if needed, their are command line options I am sure others know.

Mystified 02-03-2017 10:30 AM

I contacted the company after I received my computer and they said all the partitions are ext4

Brains 02-03-2017 12:42 PM

Quote:

Originally Posted by Mystified (Post 5664449)
This is what I got

UUID=PARTUUID=e55dc00204 /mnt/lfs ext4 defaults 0 1

lfs says it can't find sda2

This is wrong, look at my examples again, do not put "Partuuid....", put the long number (without the quotes). And using /dev/sdxx instead of the UUID for the file system currently disables pre-mount file system integrity check at boot up on my Debian, there's a reason why the default is to use UUID.
EDIT: And if it still complains after you get the right information in place, hit the Tab key instead of the space key after each section.

rokytnji 02-03-2017 12:58 PM

Just on small ssd laptop right now. my desktop machines have a more elaborate fstab made by me.

Code:

harry@harry-Latitude-XT2:~$ cat /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/sdb1 during installation
UUID=99517a34-0f9f-42d4-af4c-82ae817fb057 /              ext4    errors=remount-ro 0      1
# /home was on /dev/sdb2 during installation
UUID=52dc4336-761c-4976-ac02-0851fa022abc /home          ext4    defaults        0      2
harry@harry-Latitude-XT2:~$


Mystified 02-03-2017 01:21 PM

I fixed that.
thanks for the help. The problem I'm having is that when I try to mount lfs using the instructions it still says it can't find /dev/sda2 And there is no long number. I'm using what the output is.


All times are GMT -5. The time now is 05:50 PM.