Welcome
Welcome to refracta

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today!

Activating swap for a live session

Refracta Development, Scripts, etc.

Activating swap for a live session

Postby dzz » Mon Dec 12, 2011 2:32 pm

There was a recent irc discussion concerning swap activation for a live session, with mixed results

Using the latest "daily build" from usb with nothing modified (don't have a cd to test this just now) this is what happens here:

If "swapon" is added to cmdline, an existing swap partition is automatically detected, configured and used. <free> shows available memory, ram and swap individually. If swapon is set it should also show in /etc/fstab.

It is also possible to add swap after boot, (su)<swapon /dev/sdax>

"swapon" is actually a live-boot option although <man live-boot> doesn't say so. Without it, swap does not autoactivate. The relevent files are:

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

which are built into the initrd

A swap partition on usb may be more difficult, possibly needing additions in /usr/share/initramfs-tools/scripts/live-premount/modules (also built into initrd) http://lists.debian.org/debian-live/201 ... 00064.html

No idea about swapfiles

Useful to know, if you don't run a high-spec machine. You might need <swapoff -a> before disk partitioning.
dzz
 
Posts: 629
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: Activating swap for a live session

Postby fsmithred » Mon Dec 12, 2011 6:15 pm

I got the same results as you. A usb flash drive that was imaged with the iso (isohybrid) will use existing swap partitions if you add the swapon option. Booting from CD will do the same. Adding a swap partition to the usb stick is indeed a problem. In gparted, the entire stick shows up as unallocated, and if you right-click and select information, the warning says "Invalid partition table - recursive partition on /dev/sdb." That's the case when the stick is plugged into a running system and when the stick is booted.

When the stick is plugged into a running system, 'fdisk -l' and cfdisk show no partition table.

With the stick booted, 'fdisk -l' shows Hidden HPFS/NTFS. In fact, it shows it twice - once for /dev/sdb (3926 MB), which contains /dev/sdb1, and once for /dev/sdb1 (700MB), which contains /dev/sdbp1.

With the stick booted, cfdisk shows the hidden partition and the free space, and it allows me to add more partitions. I added a small swap partition and another linux partition. Stick still boots, but when I try 'mkswap /dev/sdb2/ I get "Device or resource busy." If I plug the stick into a running system, 'fdisk -l' requires that I tell it to ignore the invalid partition table. I actually have to tell it twice before it shows me the partitions. If I run the mkswap command on it, it appears to work. If I then boot the stick with the swapon option, it still only uses the swap partition on the internal drive, according to 'free -m' and 'cat /proc/swaps'.

It looks like the only way to use a swap partition on the flash drive is if you use the usb image that I haven't uploaded yet. On my debian-live builds in the past, I did have a swap partition on the usb stick, but those were made with a usb-hdd image rather than isohybrid.

BTW, 'man live-boot' does show the swapon option, but if you searched for it with 'man live-boot | grep swapon' you might have gotten the same error I got. The other way to search man pages is to hit the forward-slash key while you're inside the man page, and then type the search term you want. I do find it that way. It's right *before* 'persistent'.

One more thing: with the stick booted, I tried to make a filesystem on sdb3. Error message said that the partition didn't exist. After unplugging and plugging the stick a few times, it showed up as sdc instead of sdb, and I could successfully create and mount an ext3 partition. Oh, that's going to be useless. After reboot, I could not mount /dev/sdb3 (the ext3 partition). Error is that it's already mounted or /mnt (the mountpoint) is busy. 'df -h' shows /dev/sdb (not /dev/sdb1) mounted on /live/image.
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Re: Activating swap for a live session

Postby onyxperidot » Sun Sep 01, 2013 4:58 pm

I ran into the "recursive partition" problem too. I fixed the iso image with isohybrid:

"isohybrid --type 0x83 --offset 1 -h 255 -s 63 refracta-snapshot.iso"

Perhaps this could be incorporated into the refractasnapshot script.
onyxperidot
 
Posts: 1
Joined: Sun Sep 01, 2013 4:50 pm

Re: Activating swap for a live session

Postby fsmithred » Sun Sep 01, 2013 9:42 pm

onyxperidot wrote:I ran into the "recursive partition" problem too. I fixed the iso image with isohybrid:

"isohybrid --type 0x83 --offset 1 -h 255 -s 63 refracta-snapshot.iso"

Perhaps this could be incorporated into the refractasnapshot script.


What does that do? I tried it, and when I plug the stick into a running system, it comes up on the desktop as CDROM, but I can't open it. Gparted says it's unknown, but it will let me make partitions on the unused portion of the stick. The extra partition also shows up as CDROM on the desktop, but I can open it, and I can write to it. It mounts at /media/CDROM. Man, that's weird.

I can boot the converted iso in vbox, but with 'swapon' in the boot line, it does not use the swap on the virtual hard drive that's attached. Using 'swapon' after boot does work. I haven't tried booting the usb stick.

As far as I'm concerned, the only use for isohybrid is a quick and easy way to get the iso onto a usb stick for the purpose of installing to hard drive. If you're not planning to do that, you should turn off the isohybrid option in /etc/refractasnapshot.conf when you make a snapshot. If you want a usable live system on a usb stick, use refracta2usb. Then you can make additional partitions, and if you plug the stick into a running system, you can make changes in the root of the usb stick.
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm

Re: Activating swap for a live session

Postby dzz » Tue Feb 04, 2014 1:10 pm

I only just noticed, automatic live swap configuration has changed since just before Wheezy was released.

The parameter is now "swap" not "swapon" (the manpage is wrong) In practice it doesn't actually work! The correct entry gets written to fstab.d/swap .. however current versions of libmount do not read fstab.d

The relevant live script: /lib/live/boot/3020-swapon

Tested here (same results) with official refracta, custom sid builds and current official Debian-Live XFCE

BTW no problems using refracta2usb with debian-live-7.0.0-i386-xfce-desktop.iso.
dzz
 
Posts: 629
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: Activating swap for a live session

Postby dzz » Sun Feb 09, 2014 10:08 am

dzz
 
Posts: 629
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: Activating swap for a live session

Postby dzz » Wed Feb 12, 2014 2:26 am

Can nobody else verify this bug? I need to use http://paste.debian.net/81592/ to get swap to automount.
dzz
 
Posts: 629
Joined: Wed Apr 27, 2011 11:53 am
Location: Devon, England

Re: Activating swap for a live session

Postby fsmithred » Thu Feb 13, 2014 6:49 pm

Yes, I got the same thing. Neither "swapon" nor "swap" causes swap to be used. I tried hacking the script to treat wheezy like squeeze, but it didn't work. Haven't tried your fix yet. When I get a chance, I'll post to the bug report. (Maybe between painting the kitchen and shoveling another foot of snow.)
User avatar
fsmithred
 
Posts: 1987
Joined: Wed Mar 09, 2011 9:13 pm


Return to Discuss

Who is online

Users browsing this forum: No registered users and 0 guests

suspicion-preferred