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
=== modified file 'debian/changelog'
--- debian/changelog 2014-04-09 18:47:09 +0000
+++ debian/changelog 2014-06-06 16:03:40 +0000
@@ -1,3 +1,17 @@
1casper (1.341) utopic; urgency=low
2
3 * scripts/casper: Adding a new cmdline parameter called 'toram-casper', which
4 allows to copy just one casper directory to RAM when using toram option.
5 This is useful when you have multiple casper directories in your media,
6 supporting different squashfs environments (i.e., to support different
7 hardware or different linux distributions in the same ISO).
8 With this patch, casper will copy to the system RAM only the adequate
9 "casper_platform" directory and not everything in the media.
10 A good use case is when you don't have enough memory to load the different
11 casper_platforms included in a ISO, and you will only use one.
12
13 -- Marcelo Fernández <marcelo.fidel.fernandez@gmail.com> Fri, 06 Jun 2014 12:44 -0300
14
1casper (1.340) trusty; urgency=medium15casper (1.340) trusty; urgency=medium
216
3 * Remove 23etc_modules which does more harm than good (LP: #1296386)17 * Remove 23etc_modules which does more harm than good (LP: #1296386)
418
=== modified file 'scripts/casper'
--- scripts/casper 2014-03-19 14:22:36 +0000
+++ scripts/casper 2014-06-06 16:03:40 +0000
@@ -63,6 +63,9 @@
63 echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" >> /etc/casper.conf ;;63 echo "export LIVE_MEDIA_PATH=\"$LIVE_MEDIA_PATH\"" >> /etc/casper.conf ;;
64 toram)64 toram)
65 export TORAM="Yes" ;;65 export TORAM="Yes" ;;
66 toram-casper=*)
67 TORAM_CASPER="${x#toram-casper=}"
68 export TORAM_CASPER ;;
66 todisk=*)69 todisk=*)
67 export TODISK="${x#todisk=}" ;;70 export TODISK="${x#todisk=}" ;;
68 hostname=*)71 hostname=*)
@@ -159,6 +162,20 @@
159162
160 size=$(fs_size "" ${copyfrom} "used")163 size=$(fs_size "" ${copyfrom} "used")
161164
165 # If booting with a defined toram-casper variable, deduct from the total
166 # media size the 'casper_' directories we won't copy to RAM
167 if [ ! -z "${TORAM_CASPER}" ]; then
168 for dir in $(ls -A ${copyfrom}/); do
169 case "$dir" in
170 casper_*)
171 if [ "$dir" != "${TORAM_CASPER}" ]; then
172 size_casper=$(du -ks ${copyfrom}/$dir | cut -f1)
173 size=$(expr ${size} - ${size_casper})
174 fi ;;
175 esac
176 done
177 fi
178
162 if [ "${copytodev}" = "ram" ]; then179 if [ "${copytodev}" = "ram" ]; then
163 # copying to ram:180 # copying to ram:
164 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)181 freespace=$(awk '/^MemFree:/{f=$2} /^Cached:/{c=$2} END{print f+c}' /proc/meminfo)
@@ -187,9 +204,25 @@
187 mkdir "${copyto}"204 mkdir "${copyto}"
188 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"205 echo "mount -t ${fstype} ${mount_options} ${dev} ${copyto}"
189 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"206 mount -t "${fstype}" ${mount_options} "${dev}" "${copyto}"
190 cp -a ${copyfrom}/* ${copyto}207 # If booting without a defined toram-casper variable, use the original copy-all
191 if [ -e ${copyfrom}/.disk ]; then208 if [ -z "${TORAM_CASPER}" ]; then
192 cp -a ${copyfrom}/.disk ${copyto}209 cp -a ${copyfrom}/* ${copyto}
210 if [ -e ${copyfrom}/.disk ]; then
211 cp -a ${copyfrom}/.disk ${copyto}
212 fi
213 else
214 # Partial copy to RAM; copy all directories from the media, but for those
215 # starting with 'casper_', we will copy only the directory matching
216 # $TORAM_CASPER variable.
217 for dir in $(ls -A ${copyfrom}/); do
218 case "$dir" in
219 casper_*)
220 if [ "$dir" == "${TORAM_CASPER}" ]; then
221 cp -a ${copyfrom}/$dir ${copyto}
222 fi ;;
223 *) cp -a ${copyfrom}/$dir ${copyto} ;;
224 esac
225 done
193 fi226 fi
194 umount ${copyfrom}227 umount ${copyfrom}
195 mount -r -o move ${copyto} ${copyfrom}228 mount -r -o move ${copyto} ${copyfrom}

Subscribers

People subscribed via source and target branches