5

I'm trying to add lines to my /etc/fstab file. but the lines I add get cleared on reboot because I am using a persistent live USB stick.

I don't want a lecture. I just want to know which file writes the /etc/fstab file at restart and I want to alter that file so that I can auto mount the disk I want.

So this is not really a question but more like a request.

I am requesting the location of the file/files that are responsible for writing to or resetting /etc/fstab on restart.

N.N.
  • 18,639
  • I was able to add the line "gksu mount /dev/sda2 /media/Windows" to my startup apps program and it seems to work fine but I still wish I could get fstab working. – Joshua Robison Aug 11 '11 at 19:26
  • Are you sure it is reset, and not just ignored? I would think it would just be ignored, because the new version saved in the persistence file is not used until after the original fstab is processed. – psusi Aug 11 '11 at 19:30
  • Maybe you will have to make a customized live-usb. See this: http://forums.debian.net/viewtopic.php?f=17&t=59876 – desgua Aug 12 '11 at 00:11
  • @psusi, nope, not ignored because when I reboot I reopen fstab and the line I entered is gone. – Joshua Robison Aug 12 '11 at 11:07
  • this is amazing that a simple file that resets the fstab can't be found O_o it has to be just a simple shell script somewhere. – Joshua Robison Aug 13 '11 at 13:03
  • or a simple .conf file or something. – Joshua Robison Aug 19 '11 at 16:44
  • I would imagine that /etc/fstab is likely not the file that is processed in a live environment because those are generally decompressed from filesystems-in-a-file. Try poking around within the mounted filesystem-file. – Huckle Mar 14 '12 at 23:45
  • Rather than using a "persistant live USB" stick, why not simply install Ubuntu to the stick. All your changes will then persist. – Elder Geek Jan 27 '16 at 14:27
  • Yeah, it could work, but I guess I'd need to use 2 usb sticks for that :D – Antti Haapala Jan 27 '16 at 20:45
  • @AnttiHaapala Fortunately they are inexpensive. – Elder Geek Jan 30 '16 at 19:23

3 Answers3

4

For my LiveUSB install with Ubuntu 11.10 (which has a casper-rw persistence loopback file), the file that worked for me to have drives mounted automatically is:

/usr/share/initramfs-tools/scripts/casper-bottom/12fstab

I added lines into that script which worked to add new drive mounts upon boot-up. The odd thing is that my /etc/fstab file does NOT reflect the drive mounts. This would seem to suggest that the /etc/fstab file is just a dummy file or something to the LiveCD setups. Not sure, but changes added to the 12fstab file DO persist.

con-f-use
  • 19,061
  • This seems to be outdated. Well at least it didn't work for me. I added a line to /etc/fstab of my live system and tested it with sudo mount -a. It worked. Then I added the same line at the appropriate place in /usr/share/initramfs-tools/scripts/casper-bottom/12fstab and rebooted. No effect. Might be that the mount point was bad or something - need to test that. – con-f-use Aug 28 '12 at 12:02
  • fstab confirmed still being overwritten after changing 12fstab and running update-initramfs -u. used rc.local and it worked. But now I have the issue of not being able to change my root mount properties to account for my horribly slow usb flash drive performance. – parity3 Apr 24 '20 at 22:40
1

Add your mount commands in /etc/rc.local

...
mount -t ntfs-3g -L Inter /media/Inter -o uid=1000,gid=999,umask=002
exit
chanio
  • 11
0

Rather than use a live media with persistence, I always simply install directly to the flash drive. This way any changes I make are kept. Whether the changes are to the data stored there or the system configuration or applications I have installed is irrelevant with this approach. If you still need the live media for installation purposes you can put a copy of the ISO on the stick and boot it as needed as outlined here.

Elder Geek
  • 36,813