Merge lp:~fernandezm/ubuntu/utopic/casper/toram-casper into lp:ubuntu/utopic/casper

Proposed by Marcelo Fernandez
Status: Needs review
Proposed branch: lp:~fernandezm/ubuntu/utopic/casper/toram-casper
Merge into: lp:ubuntu/utopic/casper
Diff against target: 85 lines (+50/-3)
2 files modified
debian/changelog (+14/-0)
scripts/casper (+36/-3)
To merge this branch: bzr merge lp:~fernandezm/ubuntu/utopic/casper/toram-casper
Reviewer Review Type Date Requested Status
Luke Yelavich (community) Needs Fixing
Review via email: mp+219078@code.launchpad.net

Description of the change

Adding a new cmdline parameter called 'toram-casper', which allows to copy just one casper directory to RAM when using toram option. This is useful when you have multiple casper directories in your media, supporting different squashfs environments (i.e., to support different hardware in the same ISO).

For example, look at this isolinux.cfg:

LABEL platform1
  kernel /casper_platform1/vmlinuz
  append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper_platform1/initrd.lz live-media-path=/casper_platform1 toram toram-casper=casper_platform1
LABEL platform2
  kernel /casper_platform2/vmlinuz
  append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper_platform2/initrd.lz live-media-path=/casper_platform2 toram toram-casper=casper_platform2

With this patch, casper will copy to the system RAM only the adequate "casper_platform" directory and not everything in the media. This is useful when you have a 4GB DVD ISO with different "casper_platform" directories and you have a 1GB RAM machine.

To post a comment you must log in.
Revision history for this message
Luke Yelavich (themuso) wrote :

Thanks for your work.
I am not currently in a position to test this fix to make sure it still works in all use cases, but code wise it looks ok. I would ask that you add a debian/changelog entry, and explain clearly what this change is, and why it is being made, i.e something similar to what you wrote in the merge proposal message. Your bzr log message could be used, but it is not detailed enough as to the change, and why it is being made.

Thanks again.

review: Needs Fixing
1137. By Marcelo Fernandez

Adding debian/changelog.

Revision history for this message
Marcelo Fernandez (fernandezm) wrote :

Thanks Luke, now I've pushed the debian/changelog entry, I hope it gets merged. :-)

Let me know if there's anything else left to do.

Regards

Unmerged revisions

1137. By Marcelo Fernandez

Adding debian/changelog.

1136. By Marcelo Fernandez

Added toram-casper cmdline option to copy only one casper directory (not everything) from the media to RAM

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-04-09 18:47:09 +0000
3+++ debian/changelog 2014-06-06 16:03:40 +0000
4@@ -1,3 +1,17 @@
5+casper (1.341) utopic; urgency=low
6+
7+ * scripts/casper: Adding a new cmdline parameter called 'toram-casper', which
8+ allows to copy just one casper directory to RAM when using toram option.
9+ This is useful when you have multiple casper directories in your media,
10+ supporting different squashfs environments (i.e., to support different
11+ hardware or different linux distributions in the same ISO).
12+ With this patch, casper will copy to the system RAM only the adequate
13+ "casper_platform" directory and not everything in the media.
14+ A good use case is when you don't have enough memory to load the different
15+ casper_platforms included in a ISO, and you will only use one.
16+
17+ -- Marcelo Fernández <marcelo.fidel.fernandez@gmail.com> Fri, 06 Jun 2014 12:44 -0300
18+
19 casper (1.340) trusty; urgency=medium
20
21 * Remove 23etc_modules which does more harm than good (LP: #1296386)
22
23=== modified file 'scripts/casper'
24--- scripts/casper 2014-03-19 14:22:36 +0000
25+++ scripts/casper 2014-06-06 16:03:40 +0000
26@@ -63,6 +63,9 @@
27 echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" >> /etc/casper.conf ;;
28 toram)
29 export TORAM="Yes" ;;
30+ toram-casper=*)
31+ TORAM_CASPER="${x#toram-casper=}"
32+ export TORAM_CASPER ;;
33 todisk=*)
34 export TODISK="${x#todisk=}" ;;
35 hostname=*)
36@@ -159,6 +162,20 @@
37
38 size=$(fs_size "" ${copyfrom} "used")
39
40+ # If booting with a defined toram-casper variable, deduct from the total
41+ # media size the 'casper_' directories we won't copy to RAM
42+ if [ ! -z "${TORAM_CASPER}" ]; then
43+ for dir in $(ls -A ${copyfrom}/); do
44+ case "$dir" in
45+ casper_*)
46+ if [ "$dir" != "${TORAM_CASPER}" ]; then
47+ size_casper=$(du -ks ${copyfrom}/$dir | cut -f1)
48+ size=$(expr ${size} - ${size_casper})
49+ fi ;;
50+ esac
51+ done
52+ fi
53+
54 if [ "${copytodev}" = "ram" ]; then
55 # copying to ram:
56 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
57@@ -187,9 +204,25 @@
58 mkdir "${copyto}"
59 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
60 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
61- cp -a ${copyfrom}/* ${copyto}
62- if [ -e ${copyfrom}/.disk ]; then
63- cp -a ${copyfrom}/.disk ${copyto}
64+ # If booting without a defined toram-casper variable, use the original copy-all
65+ if [ -z "${TORAM_CASPER}" ]; then
66+ cp -a ${copyfrom}/* ${copyto}
67+ if [ -e ${copyfrom}/.disk ]; then
68+ cp -a ${copyfrom}/.disk ${copyto}
69+ fi
70+ else
71+ # Partial copy to RAM; copy all directories from the media, but for those
72+ # starting with 'casper_', we will copy only the directory matching
73+ # $TORAM_CASPER variable.
74+ for dir in $(ls -A ${copyfrom}/); do
75+ case "$dir" in
76+ casper_*)
77+ if [ "$dir" == "${TORAM_CASPER}" ]; then
78+ cp -a ${copyfrom}/$dir ${copyto}
79+ fi ;;
80+ *) cp -a ${copyfrom}/$dir ${copyto} ;;
81+ esac
82+ done
83 fi
84 umount ${copyfrom}
85 mount -r -o move ${copyto} ${copyfrom}

Subscribers

People subscribed via source and target branches