fstab loses changes on snapshot

Forum rules
We don't support installations in VirtualBox, VMWare, qemu or others. We ignore posts about WINE, PlayOnLinux, Steam and Skype. We don't support btrfs, lvm, UEFI, side-by-side installations with GPT or dualboot with anything newer than Windows XP.
Google your problem first. Check the Wiki. Read the existing threads. It's okay to "hijack" an existing thread, yes! If your problem is not yet covered, open a new thread. To get the quickest possible help, mention the exact release codename in your post (uname -a is a good idea, too). Due to the lack of crystal balls, attach the output of lspci -nnk if you encounter hardware problems.
User avatar
nassausky
apt-getter
Posts: 83
Joined: Wed May 06, 2015 1:15 pm

fstab loses changes on snapshot

Unread post by nassausky » Sun Jun 07, 2015 1:47 am

Someone questioned earlier why someone might be trying to snapshot while running live. I have a few reasons which I didn't want to get into yet but I think as I am almost finished writing a set of instructions for creating a live video snapshot, I'd like to ask a question about my possibly last dilemna.

After I run a live snapshot, the fstab file seems to revert back to the following

Code: Select all

aufs / aufs rw 0 0
tmpfs / tmp tmpfs nosuid, nodev 0 0
using the following I can manually mount the smb host

Code: Select all

mount.cifs //mysmbserver/video /media/video -o user=mysmbuser,pass=mysmbpassword
but adding it to /etc/rc.local it doesn't load automatically.

I then found a possible solution to insert the mount point inside fstab which then I tried:

Code: Select all

//myserverip/video /media/mylocalmountpoint cifs username=mysmbusername,password=mypassword,_netdev,uid=1000,gid=1000 0 0
and after I ran the snapshot and booted it, the fstab was reset and it was missing my entry.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: fstab loses changes on snapshot

Unread post by machinebacon » Sun Jun 07, 2015 5:38 am

Usually, for the live session, this is managed by Debian's live-boot scripts:

Code: Select all

user@grill:~$ cat /lib/live/boot/9990-fstab.sh 
#!/bin/sh

#set -e

Fstab ()
{
	# FIXME: stop hardcoding overloading of initramfs-tools functions
	. /scripts/functions
	. /lib/live/boot/9990-initramfs-tools.sh

	if [ -n "${NOFSTAB}" ]
	then
		return
	fi

	log_begin_msg "Configuring fstab"

	if ! grep -qs  "^${UNIONTYPE}" /root/etc/fstab
	then
		echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> /root/etc/fstab
	fi

	if ! grep -qs "^tmpfs /tmp" /root/etc/fstab
	then
		echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> /root/etc/fstab
	fi

	log_end_msg
}
creates a live fstab and the next cares about cifs:

Code: Select all

user@grill:~$ cat /lib/live/boot/9990-mount-cifs.sh 
#!/bin/sh

#set -e

do_cifsmount ()
{
	rc=1

	if [ -x "/sbin/mount.cifs" ]
	then
		if [ -z "${NFSOPTS}" ]
		then
			CIFSOPTS="-o user=root,password="
		else
			CIFSOPTS="-o ${NFSOPTS}"
		fi

		log_begin_msg "Trying mount.cifs ${NFSROOT} ${mountpoint} ${CIFSOPTS}"
		modprobe -q cifs

		if mount.cifs "${NFSROOT}" "${mountpoint}" ${CIFSOPTS}
		then
			rc=0
		fi
	fi

	return ${rc}
}
..gnutella..

User avatar
nassausky
apt-getter
Posts: 83
Joined: Wed May 06, 2015 1:15 pm

Re: fstab loses changes on snapshot

Unread post by nassausky » Sun Jun 07, 2015 3:17 pm

OK thanks,

Without really analyzing the function in the script I figured I would run a quick test and add the following line at the end to have it just add a single line into the fstab which I thought was generated from the 9990-fstab.sh script you referenced.

After adding the following line right before log_end_msg :

Code: Select all

echo "//192.168.1.200/video /media/video cifs ro,_netdev,user=myuser,password=mypassword 0 0" >> /root/etc/fstab
the previous change I made to the fstab function had no effect after I ran a snapshot and booted the new snapshot. I then looked at the fstab to see if the line was appended to /etc/fstab but no luck.

I thought about it again and said if I can't beat em to join em ha. I used the same technique and this time I added the mount line from /etc/fstab to /etc/rc.local as so:

Code: Select all

echo "//192.168.1.200/video /media/video cifs ro,_netdev,user=myuser,password=mypassword 0 0" >> /etc/fstab
after that change I was able to have the local user connect to the drive and creating a reference inside ~/.wmii/wmiirc_local was able to successfully see the remote resource.

Thanks.

Note: I don't want to take days to figure this out but my far throw from center guess is that something might be loading after /lib/live/boot/9990-fstab.sh which seems to again reset the file or the fstab() function inside 9990-fstab.sh isn't being called.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: fstab loses changes on snapshot

Unread post by machinebacon » Mon Jun 08, 2015 1:39 pm

Did you try the "netboot=cifs" kernel parameter? This is added to the ISOLINUX boot screen (for your live ISO, you would edit /usr/lib/bbqsnapshot/isolinux/isolinux.cfg)

Code: Select all

       netboot[=nfs|cifs]
           This  tells  live-boot  to  perform  a network mount. The parameter
           "nfsroot=" (with optional "nfsopts="), should specify where is  the
           location  of  the  root  filesystem.   With  no args, will try cifs
           first, and if it fails nfs.
I'm positive that this enables CIFS (as configured in /lib/live/boot/9990-mount-cifs, so maybe you want to edit the line there and change the username and add _netdev or so)

Just a guess, I have no shares to mount so I cannot test it.
..gnutella..

User avatar
nassausky
apt-getter
Posts: 83
Joined: Wed May 06, 2015 1:15 pm

Re: fstab loses changes on snapshot

Unread post by nassausky » Mon Jun 08, 2015 3:35 pm

Interesting, I got it to work as said earlier by appending the mount information into fstab into rc.local then adding the command sudo mount -a to the ~/.wmii/wmiirc_local file


Wanting to see if I can get it to work another way I tried to figure out what you meant. I even tried googling the 9990-mount-cifs which had really no instructional results and I tried searching for CIFS and mounting it live but that had too many results and nothing really panned out.

I am interpreting from what you wrote that I should change the username and password in /usr/lib/bbqsnapshot/iso/isolinux but I don't see a place in that file to put the remote ip & local path to mount it to. Just for a test I tried replacing

CIFSOPTS="-o user=root,password="

with

CIFSOPTS="//192.168.1.200/video /media/video cifs ro,_netdev,user=myuser,password=mypassword 0 0"

but that didn't work. There was quite a few boot errors and it was timing out searching for resources.

Thanks again but you don't have to create any remote connections and for now I got it working.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: fstab loses changes on snapshot

Unread post by machinebacon » Mon Jun 08, 2015 3:54 pm

What I mean is, that when booting the live ISO, there is a screen right at the beginning to choose from. You can press Tab there and edit the boot line. Usually it contains something like "initrd=/live/initrd.img boot=live ip=frommedia union=aufs vga=current" or similar. There you can append "netboot=cifs" to make the network share mounting active. If this happens, the script 9990-mount-cifs will be run, else it's not read by live-boot.

I am aware you 'could make it work for yourself' by adding mount commands (that probably override secrets management), so I try to help you make it work 'for everyone' by using the existing tools that Debian ships for these cases. You also mentioned in your note that you "don't want to take days to figure this out", so I think we can figure this out in less time, together ;)
Of course it's a mandatory exercise, I won't send you the Russian mafia if you don't tinker with it :)

EXISTING LIVE SESSION:
in the ISOLINUX boot screen, press Tab and append "netboot=cifs", also add the stuff that is written in the manpage:
netboot[=nfs|cifs]
This tells live-boot to perform a network mount. The parameter
"nfsroot=" (with optional "nfsopts="), should specify where is the
location of the root filesystem. With no args, will try cifs
first, and if it fails nfs.
so, something like: netboot=cifs nfsroot=//${server}/${share}/ nfsopts=user=username,pass=pwassword
then boot it and check if live-boot stops while mounting the shares, asking you for the password - I'd be interested to see how this is managed inside of live-boot. I can't imagine 9990-mount-cifs being edited to mount a specific user and having a hard-coded password inside, so there must be some mechanism (which I unfortunately cannot check!)



IF IT WORKS AND YOU CREATE A NEW REMASTER:
0) keep the 9990-mount-cifs (default)
1) edit the /usr/lib/bbqsnapshot/iso/isolinux/isolinux.cfg and add the string above behind every occurrence of "append"
2) create a snapshot (the edit of the previous step is then written onto your new ISO)
3) test it and mark the topic as "solved" ;)

As said, if you are not interested in this, just ignore and do it your way :)
..gnutella..

User avatar
nassausky
apt-getter
Posts: 83
Joined: Wed May 06, 2015 1:15 pm

Re: fstab loses changes on snapshot

Unread post by nassausky » Mon Jun 08, 2015 4:22 pm

Thanks that clears it up a bit but still unsure what it's going to try mounting if I had for example 3 server ip addresses and 4 shares. Where would I put that information?

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: fstab loses changes on snapshot

Unread post by machinebacon » Mon Jun 08, 2015 4:30 pm

Maybe add them behind each other, as in:

netboot=cifs nfsroot=//${server}/${share}/ nfsroot=//${server}/${share}/ nfsroot=//${server}/${share}/

But I admit I give up now, can't do more than googling and shooting into the dark. Sorry for wasting your time.
..gnutella..

Post Reply