Author Topic: (SOLVED) Changes in fstab not persistant for LiveUSB  (Read 1591 times)

Offline unist

  • Full Member
  • ***
  • Posts: 158
(SOLVED) Changes in fstab not persistant for LiveUSB
« on: October 20, 2012, 03:56:17 PM »
For a LiveUSB PCLOS LXDE 2012 I tried to edit "fstab" in order to activate a sawp partition that I have in the second HDD.

The original "fstab" file for the LiveUSB is:

/dev/root / rootfs defaults 0 0
none /proc proc defaults 0 0
none /dev/pts devpts defaults 0 0

For the edited "fstab" I used the file from my main install PCLOS KDE 2012 in a second HDD:

# Entry for /dev/sdb1 :
UUID=e16abe2f-bc1b-4ad3-b96a-55af35463483 / ext4 defaults 1 1
none /proc proc defaults 0 0
# Entry for /dev/sdb5 :
UUID=09c72ba9-ba1b-4487-9aa9-13174246afff swap swap defaults 0 0
none /dev/pts devpts defaults 0 0

I copied this file for the "fstab" in the LiveUSB PCLOS LXDE 2012, and saved changes.

At boot, for the LiveUSB PCLOS LXDE 2012 entry, I found that the its "fstab" returned to:

/dev/root / rootfs defaults 0 0
none /proc proc defaults 0 0
none /dev/pts devpts defaults 0 0

I notice that in "menu.lst" I have the option "fstab=rw,noauto", as you can see:

timeout 10
color black/cyan yellow/cyan
gfxmenu (hd3,1)/boot/gfxmenu
default 0


title  LXDE with Persistence
kernel (hd3,1)/LXDE1/vmlinuz livecd=/LXDE1 fromusb root=UUID=50e9131d-4b6e-4f95-b873-33608559fd87 changes_dev=UUID=50e9131d-4b6e-4f95-b873-33608559fd87 acpi=on fstab=rw,noauto vga=791 quiet splash=silent vmalloc=256M
initrd (hd3,1)/LXDE1/initrd.gz

title   LXDE
kernel (hd3,1)/LXDE1/vmlinuz livecd=/LXDE1 fromusb root=UUID=50e9131d-4b6e-4f95-b873-33608559fd87 acpi=on vga=791 quiet splash=silent vmalloc=256M
initrd (hd3,1)/LXDE1/initrd.gz
  
title   LXDE with Copy to RAM
kernel (hd3,1)/LXDE1/vmlinuz livecd=/LXDE1 fromusb copy2ram root=UUID=50e9131d-4b6e-4f95-b873-33608559fd87 acpi=on vga=791 quiet splash=silent vmalloc=256M
initrd (hd3,1)/LXDE1/initrd.gz
 
title   Memory Test
kernel (hd3,1)/boot/memtest-4.20

I already reviewed the two related threads in this Forum:

http://www.pclinuxos.com/forum/index.php/topic,85594.0.html

http://www.pclinuxos.com/forum/index.php/topic,81077.0.html

From both threads I have the impression that it is not possible to make changes to "fstab" for LiveUSB, or at least it has not been worked out so far.

Given the above:
  • Is it possible to edit "fstab" for LiveUSB?
  • In case it were possible, will it be not so complex or risky to implement for a Linux user with limited experience?
  • Is there an alternate way to activate automatically at boot a swap partition for a LiveUSB?

Thank you.
« Last Edit: October 21, 2012, 11:48:24 AM by unist »
Registered Linux user #547260

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: Changes in fstab not persistant for LiveUSB
« Reply #1 on: October 20, 2012, 04:01:44 PM »
I would research the possibility of running a script automatically at end of boot to do so.

I never tried it so do not know how easy/possible it would be.


MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline unist

  • Full Member
  • ***
  • Posts: 158
Re: Changes in fstab not persistant for LiveUSB
« Reply #2 on: October 20, 2012, 04:27:09 PM »
I would research the possibility of running a script automatically at end of boot to do so.

I never tried it so do not know how easy/possible it would be.


Thank you for your idea. I will wait to see if someone has developed it.
Registered Linux user #547260

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: Changes in fstab not persistant for LiveUSB
« Reply #3 on: October 20, 2012, 04:33:19 PM »
WHat I had in mind when I wrote that, was something along the lines of ....

having a backup of the fstab file you want to be in use which has the extra Swap mount point included.

then copy that backup to be the new fstab and then do  swapon -a to make the swap available.

as all other entries in the fstab would be exactly the same I imagine it should work.

It is a matter of finding the correct location to place a script which has the commands ........


.....  or so I see it ......  but as said never tried ......  ;)

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline unist

  • Full Member
  • ***
  • Posts: 158
Re: Changes in fstab not persistant for LiveUSB
« Reply #4 on: October 20, 2012, 06:04:48 PM »

then copy that backup to be the new fstab and then do  swapon -a to make the swap available.


How can I create the script to do "swapon -a" to make the swap available?

I am willing do "my homework" with your orientation and some google research.  ;)
Registered Linux user #547260

Offline sparerep

  • Jr. Member
  • **
  • Posts: 26
Re: Changes in fstab not persistant for LiveUSB
« Reply #5 on: October 21, 2012, 01:17:27 AM »
There are two things I did to get a swap on my LiveUSB: I think only one is really needed. And, I'll note that this will assign the swap before the LiveUSB is created, so it is permanent for that stick. If the swap is not present when the stick is booted, I don't think it will create a problem. And, the swap will be present both with and without persistence.

I installed Xfce in a VirtualBox, updated it, added software, and remastered, creating an iso for the live USB creation.

Also, swap's UUID needs to be in-hand before starting.

So, one change I made and I am pretty sure this works, but does not make a fstab entry.

In the system from which the Live USB's iso will be created, edit:
/etc/rc.d/rc.local

add:

swapon UUID=your-UUID-from-PCC

Save that, remaster to get the iso, create the Live USB.

Additionally, swap can be added to the fstab.

In the system from which the Live USB's iso will be created, edit:
/etc/rc.d/rc.sysinit

find:
#Write fstab for LiveCD - it was line 385 for me.

Add the swap before EOF - this was line 390:
UUID=your-UUID-from-PCC swap swap defaults 0 0

I also added noatime to the following, which was line 387:
was:
/dev/root / rootfs defaults 0 0
became:
/dev/root / rootfs defaults,noatime 0 0

Save that, remaster to get the iso, create the Live USB.
 
When you boot the USB stick, you can show the swap using one of these.

In a terminal:
 free
will show swap:
 Swap:  4096536      0   4096536

In a terminal, running:
 top
will show swap and usage:
 Swap: 4096536k total,   0k used, 4096536k free, 1560452k cached

In a terminal:
 cat /proc/meminfo
the swap will be shown midway down the list:
 SwapTotal:       4096536 kB
 
I made one more change before creating the LiveUSB: I changed the boot to default to persistence.
 
I did the LiveUSB creation on my main system, and that's where this change was made.
Edited /usr/share/live-usb-creator/lusc_0.9.7.sh
Changed line 570 from 'default 0' to 'default 1' to make 'PERSIST' default

When doing changes like this I backup the file to be changed, make the change, and when the job is completed, I restore the backup so I don't confuse myself later.

Actually, I made one more change. Since I had the system setup for the correct keyboard English (US), I stopped it from pausing at that dialog.

In the system from which the Live USB's iso will be created, edit:
/etc/rc.d/rc.sysinit

In the "#Write Finish install for LiveCD" section, around line 390
Change
KEYBOARD=yes
to
KEYBOARD=no


Tom

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: Changes in fstab not persistant for LiveUSB
« Reply #6 on: October 21, 2012, 03:24:37 AM »
sparerep,
                  thanks for the info posted.
Those changes - and possibly others - would help make a remaster as the user desires.

Trying to get the same result with an official ISO is another matter it seems  ;)

Any thoughts on that?

 
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline unist

  • Full Member
  • ***
  • Posts: 158
Re: Changes in fstab not persistant for LiveUSB
« Reply #7 on: October 21, 2012, 11:47:45 AM »
sparerep: thank you for your detailed post. I will study it and need to learn some basic pre - requisites, like how to remaster to get the iso. But that is my own case. It is clear that you solved the issue, and I will mark it as such.
« Last Edit: October 21, 2012, 11:49:32 AM by unist »
Registered Linux user #547260

Offline sparerep

  • Jr. Member
  • **
  • Posts: 26
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #8 on: October 21, 2012, 03:39:07 PM »
Well, unist, Just17 made me think.

If the question is how to make a remaster, or LiveCD, or LiveUSB look for a swap partition and use it if present, how about this.

Add in an appropriate place, maybe /etc/rc.d/rc.local:

SWAPP=`fdisk -l $VAR1 | grep swap | cut -d\  -f 1`
swapon $SWAPP

Note: "cut -d\  -f 1" has two spaces between \ and -f.

This works on a remaster/LiveCd, and there's no reason to think it won't work on a LiveUSB.

Tom

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #9 on: October 21, 2012, 04:00:23 PM »
Well, unist, Just17 made me think.

If the question is how to make a remaster, or LiveCD, or LiveUSB look for a swap partition and use it if present, how about this.

Add in an appropriate place, maybe /etc/rc.d/rc.local:

SWAPP=`fdisk -l $VAR1 | grep swap | cut -d\  -f 1`
swapon $SWAPP

Note: "cut -d\  -f 1" has two spaces between \ and -f.

This works on a remaster/LiveCd, and there's no reason to think it won't work on a LiveUSB.

Tom


If added to an existing LiveUSB using Persistence will it work? ......  wondering if you have tried it like that ...

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline sparerep

  • Jr. Member
  • **
  • Posts: 26
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #10 on: October 21, 2012, 04:58:37 PM »
I have not completely tested it as an addition to an existing LveUSB, but believe it will work as long as you boot with persistence.

My LiveUSB has swap in fstab, and that can not be changed. I can edit it out (with persistence) and it appears to save, but on reboot, it is still there. (Which is about where this discussion started.)

However, I can edit /etc/rc.d/rc.local, add the two lines, and it does save. On the next boot with persistence, it works, and I can tell that because all swap (on-LiveUSB stick + on-hard drive) is added.

But, a no-persistence boot only adds the fstab swap. So, for both boot conditions, the rc.local edit must be before LiveUSB is created.

I say I haven't completely tested because I want to start with a no-swap-in-fstab to complete the test. But, I still say if you use persistence, you can add to an existing LiveUSB.

My LiveUSB is tied-up for about another week, but I am looking for a USB that I can use for a new creation.

Tom

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #11 on: October 21, 2012, 05:39:49 PM »
Quote
However, I can edit /etc/rc.d/rc.local, add the two lines, and it does save. On the next boot with persistence, it works, and I can tell that because all swap (on-LiveUSB stick + on-hard drive) is added.

Thank you.

That I believe answers my question.

IMO, that same scheme can be used as a solution for the problem posed in this thread.

Thank you for posting the solution and results of tests  ;)

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline unist

  • Full Member
  • ***
  • Posts: 158
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #12 on: October 23, 2012, 09:23:29 PM »
Well, unist, Just17 made me think.

If the question is how to make a remaster, or LiveCD, or LiveUSB look for a swap partition and use it if present, how about this.

Add in an appropriate place, maybe /etc/rc.d/rc.local:

SWAPP=`fdisk -l $VAR1 | grep swap | cut -d\  -f 1`
swapon $SWAPP

Note: "cut -d\  -f 1" has two spaces between \ and -f.

This works on a remaster/LiveCd, and there's no reason to think it won't work on a LiveUSB.

Tom


This is to inform that I created " /etc/rc.d/rc.local" in " /media/LinuxUSB/changes/LXDE1/etc/rc.d" with the two lines:

SWAPP=`fdisk -l $VAR1 | grep swap | cut -d\  -f 1`
swapon $SWAPP

I also modified "fstab" in " /media/LinuxUSB/changes/LXDE1/etc" in this way:

# Entry for /dev/sdb1 :
UUID=e16abe2f-bc1b-4ad3-b96a-55af35463483 / ext4 defaults 1 1
none /proc proc defaults 0 0
# Entry for /dev/sdb5 :
UUID=09c72ba9-ba1b-4487-9aa9-13174246afff swap swap defaults 0 0
none /dev/pts devpts defaults 0 0
none /dev/shm tmpfs defaults 0 0

But at boot with the LiveUSB with Persistence, the swap partition was not activated and the "fstab" returned to:

/dev/root / rootfs defaults 0 0
none /proc proc defaults 0 0
none /dev/pts devpts defaults 0 0
Registered Linux user #547260

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10628
  • MLUs Forever!
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #13 on: October 24, 2012, 02:39:57 AM »
Quote
But at boot with the LiveUSB with Persistence, the swap partition was not activated and the "fstab" returned to:

/dev/root / rootfs defaults 0 0
none /proc proc defaults 0 0
none /dev/pts devpts defaults 0 0

What you did would have no effect on the fstab .....  it gets written at each boot.

What should have happened is that a Swap partition that is present in your system should have been mounted.

After booting with the change in place issue the following command in a terminal

swapon -s

It should return details of swap partitions available, something like this .....

Code: [Select]
[user@XPS ~]$ swapon -s
Filename                                Type            Size    Used    Priority
/dev/sdb3                               partition       8191996 0       -1
[user@XPS ~]$
MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline sparerep

  • Jr. Member
  • **
  • Posts: 26
Re: (SOLVED) Changes in fstab not persistant for LiveUSB
« Reply #14 on: October 24, 2012, 05:24:21 PM »
unist, Where is your swap partition? If it's on a USB drive, the drive must be attached during boot.

During initial tests, swap was on the LiveUSB stick, and that swap plus the on-internal-hard-drive swap were recognized and activated.

If I move swap to a second USB stick (I'll call it swapUSB), with both sticks connected the computer won't find the USB boot device. So, I turn on the computer with only the LiveUSB attached, and when the grub boot menu appears, I plug swapUSB in and select the system to boot.

Then,
swapon -s
Filename   Type       Size     Used  Priority
/dev/sda2  partition  453436   0     -1
/dev/sdc5  partition  1179324  0     -2

In this case, sda2 is swapUSB and sdc5 is on the computer's hard drive.

Here's the way I created rc.local on the LiveUSB: it's similar to the way you did it with a twist.

- Put the stick in my main computer
- In Thunar, mounted the drive
- Started mc as root (any file manager can be used as long as you are root.)
- Navigated to /media/disk/changes/Xfce0/etc/rc.d
- Copied rc.local from my running system - it's the same as used on the LiveUSB.
- As root, edited /media/disk/changes/Xfce0/etc/rc.d/rc.local.
- Added the lines for swap and saved.
- Booted on my test computer.


Tom