Line 3: |
Line 3: |
| </noinclude> | | </noinclude> |
| | | |
− | ==Introduction==
| + | This page has been moved to the Fedora Project wiki. The frame below is an active view of [[fedora:LiveOS image|LiveOS image]] on the Fedora wiki. Additional information for [[Sugar on a Stick]] is available below the frame/ |
− | Fedora has developed [[wikipedia:Live CD|Live CD]] [[wikipedia:Live USB|USB]] DVD images for their GNU/Linux operating system. Since the image file systems are stored in the /LiveOS folder of the image, this is the name we'll use to reference their product. | + | {{#widget:Iframe |
| + | |url=https://fedoraproject.org/wiki/LiveOS_image |
| + | |width=893 |
| + | |height=900 |
| + | |border=1 |
| + | }} |
| | | |
− | This page shares some information about the LiveOS design that helps [[Sugar on a Stick]] Learners make better use of their disc resources.
| + | ==Sugar Activity Storage== |
| + | Activity bundles that come pre-installed with the Sugar on a Stick (SoaS) are saved in the /usr/share/sugar/activities folder of the root filesystem. On first boot, the Activity bundles are copied to the /home/liveuser/.sugar/activities folder. When an Activity isrun, all Activity instance data is saved in the Sugar Journal in /home/liveuser/.sugar/datastore/<hashed folder names> |
| | | |
− | ==References==
| + | When additional Activity bundles are downloaded, they are saved in the /home/liveuser/.sugar/activities folder (but not the /usr/share/sugar/activities folder). |
| + | Thus, when SoaS is installed with the --home-size-mb NNN option of livecd-iso-to-disk, storage for the Activities one wants to try and, perhaps later, throw away, is made available without consuming the write-once root filesystem overlay, which can be consumed very quickly (and overlay file space is not directly reusable). |
| | | |
− | * [http://git.fedorahosted.org/git/?p=hosted/livecd;a=blob;f=tools/livecd-iso-to-disk.sh;hb=HEAD livecd-iso-to-disk] (Usage instructions are on the first pages.)
| + | ==Device filesystem== |
− | * [[fedora:FedoraLiveCD|FedoraLiveCD]]
| |
− | * [[fedora:How to create and use a Live CD|How to create and use a Live CD]]
| |
− | * [[fedora:How to create and use Live USB|How to create and use Live USB]]
| |
| | | |
− | ==Storage==
| + | The filesystem of the USB/SD flash storage device before SoaS was loaded is available through the /run/initramfs/live mount point (/mnt/live before Fedora 17 or SoaS Quandong). It would be helpful if the Sugar Journal code were adjusted to recognize this partition structure and offer this space as an attached disk to facilitate file sharing.) |
− | When a Live CD or Live DVD (a LiveOS image on read-only disc media) is booted, temporary storage is prepared for the system in RAM on each boot by [http://git.kernel.org/?p=boot/dracut/dracut.git;a=blob;f=modules.d/90dmsquash-live/dmsquash-live-root.sh;hb=HEAD /sbin/dmsquash-live-root] in initrd0, the initial ram disk filesystem. An in-memory, copy-on-write, system overlay is used (see [[#File Systems|File Systems]] below).
| |
| | | |
− | The Fedora LiveOS system allows for persistent storage in 3 locations:
| + | ==Installation options== |
− | | |
− | # An all-purpose, persistent overlay - a write-once, fixed-size file space that will save updates and changes to the LiveOS image (Activities, operating system changes, anything written in the LiveOS file space).
| |
− | # Persistent home folder - a re-writable, re-sizable (with difficulty), uncompressed, optionally-encryptable, file space for anything that goes in the Learner's /home/ folder (all the Sugar Activities, logs, and good stuff). A persistent home folder is an option that may be selected at the time of installation of the LiveOS image (although with some effort, one could manually create a home.img filesystem in /LiveOS/ and move the /home/ folder to it). This installation option is only available through the script, '[[fedora:livecd-iso-to-disk|livecd-iso-to-disk]]'. The Windows and Fedora 'Live USB Creator' installers do not provide this option at present.
| |
− | # Host device file space - this is the USB stick or SD card file system that is outside of the LiveOS file tree, but which is accessible through the /mnt/live or /run/initramfs/live (Fedora 17) mount point of a booted LiveOS installation. There, one finds the boot configuration files and anything else one had on the device before loading the SoaS image. One may save files here without consuming the other, limited file spaces. (This file space is limited by the device capacity).
| |
− | | |
− | The all-purpose, persistent overlay is needed for operating system changes and updates.
| |
− | | |
− | The file systems are prepared on each boot by the [http://git.fedorahosted.org/git/?p=spin-kickstarts.git;a=blob;f=fedora-live-base.ks;hb=HEAD#l63 /etc/rc.d/init.d/livesys script].
| |
− | | |
− | ===Home filesystem===
| |
− | One may find many advantages to installing Sugar on a Stick, or any LiveOS, with a persistent, home folder (using the --home-size-mb NN --delete-home options), which will hold all the Activities one wants to try and, perhaps later, throw away—all without consuming the write-once overlay, which can be consumed very quickly (and overlay file space is not normally reusable).
| |
− | | |
− | ===Device filesystem===
| |
− | Additionally, keeping some storage space on the device disc outside of the LiveOS system will let you copy, carry, and delete large resource files, such as image.iso files, or anything you might want to use or share. (We should adjust the Journal code to show this root mount to facilitate file sharing.)
| |
− | | |
− | ===Installation options===
| |
| [[Sugar on a Stick]] may be installed on a 1 GB USB device using the following options with '''[[fedora:livecd-iso-to-disk|livecd-iso-to-disk]]''' (on a single, Terminal Activity or console command line, even though the wiki may wrap the following text in accord with your browser window size): | | [[Sugar on a Stick]] may be installed on a 1 GB USB device using the following options with '''[[fedora:livecd-iso-to-disk|livecd-iso-to-disk]]''' (on a single, Terminal Activity or console command line, even though the wiki may wrap the following text in accord with your browser window size): |
| | | |
Line 46: |
Line 33: |
| | | |
| ==File Systems== | | ==File Systems== |
− |
| |
− | The Fedora LiveOS uses the [[wikipedia:Device mapper|Device-mapper]] service of the Linux kernel to manage the file stores on the device. This is the same service that is used by [[wikipedia:Logical Volume Manager (Linux)|Logical Volume Manager]] to provide disc partition services.
| |
− |
| |
− | One limitation, mentioned above, is that the LiveOS persistent overlay is a write-once file space. This is related to its use of ''device mapper'' snapshots to combine a read-only file system image (copied from the compressed SquashFS.img on the read-only LiveCD or installation .iso file) with a [[wikipedia:Copy-on-write|Copy-on-write]] service that tracks only changed blocks of data in the snapshot (overlay) file and then re-referencing file pointers to the updated blocks.<ref>http://people.gnome.org/~markmc/code/merge-dm-snapshot.c</ref><ref>http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=blob;f=drivers/md/dm-snap-persistent.c;hb=HEAD</ref> Any changes to the operating system files are stored as differences from the base. As such, "deletions" of files are saved as additional difference references, and the originals are hidden. With this mechanism, physical storage space is consumed in the write-once file space rather than recovered.
| |
| | | |
| Consumption of the space allocated for persistent storage in the snapshot overlay file may be tracked with the ''device mapper'' {{Code|dmsetup status}} report. '''Sugar Cellar''' is a small, utility script which uses that service to allow for Learner testing and discovery. It will help Learners manage their storage resources and learn ways to economize limited resources. | | Consumption of the space allocated for persistent storage in the snapshot overlay file may be tracked with the ''device mapper'' {{Code|dmsetup status}} report. '''Sugar Cellar''' is a small, utility script which uses that service to allow for Learner testing and discovery. It will help Learners manage their storage resources and learn ways to economize limited resources. |
| | | |
| * ''Sugar Cellar'' is available at http://people.sugarlabs.org/fgrose/SugarCellar and as a component of [[Sugar on a Stick/Sugar Clone]]. | | * ''Sugar Cellar'' is available at http://people.sugarlabs.org/fgrose/SugarCellar and as a component of [[Sugar on a Stick/Sugar Clone]]. |
− |
| |
| | | |
| Several developments in the Sugar on a Stick design may be considered to maximize the endurance of the LiveOS image. | | Several developments in the Sugar on a Stick design may be considered to maximize the endurance of the LiveOS image. |
| | | |
− | ===Avoid persistent overlay consumption=== | + | ==Image customization, recompression, and overlay refreshment== |
− | | |
− | * Use a persistent /home folder (discussed above).
| |
− | *: This is a very effective method to avoid consumption and will also make the Journal files more available for sharing and backup purposes.
| |
− | * Move the root user's home to /home/root in a persistent home.img
| |
− | *: This would avoid some consumption, but would compromise the root user account if there was a boot problem and the /home folder was not mounted.
| |
− | * Mount more folders onto temporary, in-memory filesystems (like /var/cache/yum, /var/tmp, & /tmp are now).
| |
− | ** /var/lib/NetworkManager (holds a timestamps file that is deleted and refreshed quite often, every 5 minutes)
| |
− | ** /var/log/audit (holds the SELinux audit.log that records a great many file accesses.)
| |
− | ** /var/spool/abrt (holds often large, error reports and core dumps). Learners could be advised to act on any abrt reports in the current session or copy the reports to other permanent storage, such as in /home/ or external storage.
| |
− | ** there may be other good candidates...
| |
− | | |
− | ===Image recompression and overlay refreshment===
| |
− | | |
− | The Device-mapper snapshot-merge target allows one to merge changes in a persistent snapshot into the original filesystem (See notes from [[{{TALKPAGENAMEE}}|Andrew Gilmore]]). In a LiveOS image the original filesystem is compressed within a read-only SquashFS image. If one has sufficient free disk space available (for example, 4.3 GiB of free space for Fedora 17 Live Desktop—typically on an attached hard drive—plus about 660 MiB or more, depending on additions of software or root filesystem files, of free space on the LiveOS device filesystem), one can copy (and uncompress) the original filesystem to a working folder, invoke the snapshot-merge Device-mapper target, delete the old SquashFS image, replace it with a recompressed version of the merged LiveOS snapshot, and reset the original snapshot overlay before rebooting the LiveOS device.
| |
− | | |
− | The following Bash script demonstrates the process where {{Code|$1}} is the working folder and {{Code|$2}} is the LiveOS device (such as {{Code|/run/initramfs/livedev}}, for the currently booted LiveOS image):
| |
− | {{Note/warning|Test and practice the following script!|This procedure will delete the LiveOS filesystem before replacing it with a recompressed merged version. Be sure to verify that you will have sufficient space for the replacement before running the full script. (You could comment out the deletion, and squash into a directory on a large working drive to determine the new filesystem size.)}}
| |
− | <nowiki>#!/bin/bash
| |
− | # 2012-08-20 00:27:28
| |
− | | |
− | # Prepare working directory.
| |
− | TMPDIR=$1
| |
− | mkdir $TMPDIR/LiveOS 2>/dev/null
| |
− | | |
− | # Mount SquashFS, copy out the original root filesystem, unmount SquashFS.
| |
− | SRCMNT=$(mktemp -d /media/XXXXXX)
| |
− | mount $2 $SRCMNT
| |
− | SQUASHMNT=$(mktemp -d /media/XXXXXX)
| |
− | mount $SRCMNT/LiveOS/squashfs.img $SQUASHMNT
| |
− | if [[ -x /usr/bin/rsync ]]; then
| |
− | rsync --inplace --8-bit-output --progress $SQUASHMNT/LiveOS/ext3fs.img \
| |
− | $TMPDIR/LiveOS
| |
− | else
| |
− | cp $SQUASHMNT/LiveOS/ext3fs.img $TMPDIR/LiveOS
| |
− | fi
| |
− | umount $SQUASHMNT
| |
− | | |
− | # Prepare temporary devices for Device-mapper snapshot-merge.
| |
− | FSDEV=$(losetup -f --show $TMPDIR/LiveOS/ext3fs.img)
| |
− | OVDEV=$(losetup -f --show $SRCMNT/LiveOS/overlay-*)
| |
− | FS_SIZE=$(blockdev -q --getsz $FSDEV)
| |
− | | |
− | # Invoke snapshot-merge target device.
| |
− | dmsetup create merged <<< "0 $FS_SIZE snapshot-merge $FSDEV $OVDEV P 8"
| |
− | | |
− | # Wait for merge completion.
| |
− | while state=$(dmsetup status merged)
| |
− | state=${state#*snapshot-merge }
| |
− | meta=${state#* }
| |
− | alloc=${state%/*}
| |
− | [[ $alloc != $meta ]]; do
| |
− | printf '|'
| |
− | sleep 0.5
| |
− | printf '\b/'
| |
− | sleep 0.5
| |
− | printf '\b-'
| |
− | sleep 0.5
| |
− | printf '\b\'
| |
− | sleep 0.5
| |
− | done
| |
− | | |
− | # Clean up from merge.
| |
− | dmsetup remove merged
| |
− | losetup -d $OVDEV $FSDEV
| |
− | | |
− | # Replace SquashFS image
| |
− | rm $SRCMNT/LiveOS/squashfs.img
| |
− | mksquashfs $TMPDIR/LiveOS $SRCMNT/LiveOS/squashfs.img -comp xz -keep-as-directory
| |
− | | |
− | # Reset overlay.
| |
− | dd if=/dev/zero of=$OVDEV bs=64k count=1 conv=notrunc,fsync
| |
− | | |
− | # Clean up.
| |
− | sleep 2
| |
− | losetup -d $OVDEV $FSDEV
| |
− | umount $SRCMNT
| |
− | rmdir $SQUASHMNT $SRCMNT</nowiki>
| |
− | | |
| | | |
| [[Sugar on a Stick/Sugar Clone]] provides a method to build a customized LiveOS image installation file through the [[Sugar_on_a_Stick/Sugar_Clone#SoaS-remix | SoaS-remix]] bundle. The SoaS-remix.iso installation file can be used to redistribute the customized image. A new installation from this .iso will have the old image recompressed and a fresh overlay. With the current version, the home.img file must be manually copied to a new installation. One's aging SoaS image can be refreshed by an over-installation (see the instructions on the referenced page). | | [[Sugar on a Stick/Sugar Clone]] provides a method to build a customized LiveOS image installation file through the [[Sugar_on_a_Stick/Sugar_Clone#SoaS-remix | SoaS-remix]] bundle. The SoaS-remix.iso installation file can be used to redistribute the customized image. A new installation from this .iso will have the old image recompressed and a fresh overlay. With the current version, the home.img file must be manually copied to a new installation. One's aging SoaS image can be refreshed by an over-installation (see the instructions on the referenced page). |
Line 143: |
Line 47: |
| | | |
| The remix building of a LiveOS image is also a good way to maintain and distribute system updates. Many software security, enhancement, and bug fixes are distributed through PackageKit (Software Update) or Yum update, which are turned off by default on LiveOS installations like SoaS. After manually running an update, the image can be remixed to incorporate the changes into a new Updated-SoaS.iso file. This process could be migrated to the Sugar BuildBot service to provide the Community with an up-to-date Sugar on a Stick image. | | The remix building of a LiveOS image is also a good way to maintain and distribute system updates. Many software security, enhancement, and bug fixes are distributed through PackageKit (Software Update) or Yum update, which are turned off by default on LiveOS installations like SoaS. After manually running an update, the image can be remixed to incorporate the changes into a new Updated-SoaS.iso file. This process could be migrated to the Sugar BuildBot service to provide the Community with an up-to-date Sugar on a Stick image. |
− |
| |
− | ===Overlay recovery===
| |
− | {{Note/warning|Test and practice the following|This procedure is not thoroughly validated, and may destroy your data.}}
| |
− | If one 'exhausts' the limited storage capacity of a LiveOS overlay, Device-mapper will mark the filesystem as 'Invalid', as shown by the {{Code|dmsetup status}} command executed in Terminal or a console (if you haven't crashed):
| |
− | # dmsetup status
| |
− | live-osimg-min: 0 8388608 snapshot 2464/2464 24
| |
− | live-rw: 0 8388608 snapshot Invalid
| |
− | The invalid bit is 00 at byte 5 of the overlay. You might try to recover the overlay by switching it to 01 with the following command line:
| |
− | # echo $'\x01' | dd of=/path/to/overlay-file bs=1 count=1 seek=4 conv=notrunc
| |
− | where /path/to/overlay may be /mnt/live/LiveOS/overlay-devicename-discUUID or<br>/media/devicename/LiveOS/overlay-devicename-discUUID for an attached device.
| |
− |
| |
− | Follow this by registering the LiveOS image with Device-mapper:
| |
− | # mount /media/devicename/LiveOS/squashfs.img /mnt/some_mountpoint
| |
− | # losetup /dev/loop1 /mnt/some_mountpoint/LiveOS/ext3fs.img -r
| |
− | # losetup /dev/loop2 /media/devicename/LiveOS/overlay-devicename-discUUID
| |
− | # dmsetup create devicename --table "0 8388608 snapshot 7:1 7:2 P 8"
| |
− | * devicename in the last line may be any string.
| |
− | * loop1 and loop2 (and the corresponding 7:1 7:2) may be any free loop devices; just substitute the appropriate numbers.
| |
− | * 8388608 is the size of the ext3fs.img file in 512 byte units. This can be read by the following command:
| |
− | # blockdev -q --getsz /dev/loop1
| |
− | Execute
| |
− | # dmsetup status
| |
− | to check the the virtual filesystem has been configured.
| |
− |
| |
− | Then try to repair any damage with the following command:
| |
− | # e2fsck -f -y /dev/mapper/devicename
| |
− | where devicename is the string you used in the dmsetup create command.
| |
− |
| |
− | Run a second check,
| |
− | # e2fsck -p /dev/mapper/devicename
| |
− | to verify if the filesystem could be repaired.
| |
− | At this point you will want to enlarge the overlay, or backup or rebuild the image.
| |
− |
| |
− | Remove the virtual filesystem registration,
| |
− | # dmsetup remove devicename
| |
− | Determine the size of the overlay file:
| |
− | # blockdev -q --getsz /dev/loop2
| |
− | # losetup -d /dev/loop2
| |
− | # losetup -d /dev/loop1
| |
− | # dd if=/dev/zero of=/path/to/overlay-file seek=overlay_size count=size_increase
| |
− | where overlay_size and size_increase are now 512 byte units.
| |
− |
| |
− | Once you have a working filesystem, you should proceed to merge your overlay into the original filesystem as describe [[#Image recompression and overlay refreshment|above]].
| |
− | ==References==
| |
− | <references />
| |
− | :: See this [http://thread.gmane.org/gmane.linux.kernel.device-mapper.devel/14644 dm-devel thread].
| |