215 |
get_blkid_information ${partition} UUID |
get_blkid_information ${partition} UUID |
216 |
} |
} |
217 |
|
|
218 |
# create_initrd {/path/to/initrd kernelversion </path/to/config>} |
is_mounted() |
|
# when nothing given then /boot/initrd-$(uname -r).img $(uname -r) will be used |
|
|
# default config path is /etc/conf.d/mkinitrd |
|
|
create_initrd() |
|
219 |
{ |
{ |
220 |
local initrd |
local item |
221 |
local kernel |
local mount |
222 |
local config |
local method |
223 |
local chroot |
method="$1" |
224 |
#local root |
item="$2" |
225 |
local modules |
|
226 |
# enabled framebuffer modules as default |
[ -e /proc/mounts ] || return 1 |
227 |
local framebuffer=1 |
|
228 |
local uvesafb_config="/etc/modprobe.d/uvesafb.conf" |
case ${method} in |
229 |
|
--location) mount="$(grep "[[:space:]]${item}[[:space:]]" /proc/mounts | cut -d ' ' -f2)" ;; |
230 |
# very basic getops |
--device) mount="$(grep "^${item}[[:space:]]" /proc/mounts | cut -d ' ' -f1)" ;; |
231 |
for i in $* |
--filesystem) mount="$(grep "[[:space:]]${item}[[:space:]]" /proc/mounts | cut -d ' ' -f3)" ;; |
232 |
do |
*) echo "unknown method '${method}'"; return 1 ;; |
233 |
case $1 in |
esac |
234 |
--initrd|-i) shift; initrd="$1" ;; |
[[ ${mount} != ${item} ]] && return 1 |
|
--config|-c) shift; config="$1" ;; |
|
|
--kernelversion|-v) shift; kernel="$1" ;; |
|
|
--nofb) shift; framebuffer=0 |
|
|
esac |
|
|
shift |
|
|
done |
|
|
|
|
|
[[ -z ${initrd} ]] && initrd="/boot/initrd-$(uname -r).img" |
|
|
[[ -z ${kernel} ]] && kernel="$(uname -r)" |
|
|
[[ -z ${config} ]] && config="/etc/conf.d/mkinitrd" |
|
235 |
|
|
236 |
if [[ ! -z ${INSTALL_ROOT} ]] |
return 0 |
237 |
then |
} |
|
config="${INSTALL_ROOT}/${config}" |
|
|
uvesafb_config="${INSTALL_ROOT}/${uvesafb_config}" |
|
|
chroot="chrooted" |
|
|
fi |
|
|
|
|
|
# get various modules needed to boot |
|
|
modules="$(get_driver_modules disk)" |
|
|
modules+=" $(get_driver_modules scsi)" |
|
|
modules+=" $(get_driver_modules cdrom)" |
|
238 |
|
|
239 |
# check for special ide_disk drivers (ata support) |
iface_has_link() |
240 |
if [[ ! -z $(echo ${modules} | grep ide_disk) ]] |
{ |
241 |
then |
local interface="$1" |
242 |
modules+=" $(grep ide_disk /proc/modules | cut -d' ' -f4 | sed '/-/d;s:,:\ :g')" |
local flags |
|
fi |
|
243 |
|
|
244 |
# check for usb-storage and add usb host drivers |
[[ -n ${interface} ]] || return 2 |
245 |
if [[ ! -z $(echo ${modules} | grep usb[_-]storage) ]] |
interface="/sys/class/net/${interface}" |
246 |
then |
[[ -d ${interface} ]] || return 2 |
247 |
# add usb1, usb1.1, usb2 and ubs3 hosts |
flags=$(cat ${interface}/flags) |
248 |
modules+=" uhci-hcd ohci-hcd ehci-hcd xhci-hcd" |
echo $((${flags}|0x41)) > ${interface}/flags # 0x41: IFF_UP|IFF_RUNNING |
249 |
fi |
[[ $(cat ${interface}/carrier) = 1 ]] || return 1 |
250 |
|
} |
251 |
|
|
252 |
# add some generic modules |
hdd_size_below_256mb() |
253 |
modules+=" sg_mod sg loop sr_mod sd_mod ide-cd ide-cd_mod ide-disk" |
{ |
254 |
|
local hdd="$1" |
255 |
|
local size |
256 |
|
local retval |
257 |
|
[[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!" |
258 |
|
|
259 |
# add generic framebuffer modules |
size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
260 |
if [[ ${framebuffer} = 1 ]] |
if [[ ${size} -le 257000000 ]] |
261 |
then |
then |
262 |
modules+=" uvesafb" |
retval="0" |
263 |
|
else |
264 |
# setup modprobe conf too |
retval="1" |
|
[[ ! -d $(dirname ${uvesafb_config}) ]] && install -d $(dirname ${uvesafb_config}) |
|
|
cat > ${uvesafb_config} << EOF |
|
|
# This file sets the parameters for uvesafb module. |
|
|
# The following format should be used: |
|
|
# options uvesafb mode_option=<xres>x<yres>[-<bpp>][@<refresh>] scroll=<ywrap|ypan|redraw> ... |
|
|
# |
|
|
# For more details see: |
|
|
# http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/fb/uvesafb.txt |
|
|
# |
|
|
EOF |
|
|
# fix a issues with virtualbox and 'ywrap' |
|
|
if [[ ! -z $(hwinfo --bios | grep -i virtualbox) ]] |
|
|
then |
|
|
# use redraw on virtualbox |
|
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=redraw" >> ${uvesafb_config} |
|
|
else |
|
|
# default config 1024x768 and 60 HZ |
|
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" >> ${uvesafb_config} |
|
|
fi |
|
265 |
fi |
fi |
266 |
|
|
267 |
# remove all duplicate modules |
return "${retval}" |
|
modules="$(remove_duplicates ${modules})" |
|
|
|
|
|
# hotfix for usb-storage |
|
|
modules="${modules/usb_storage/usb-storage}" |
|
|
|
|
|
# create the config and an initrd |
|
|
echo "# autogenerated config file" > ${config} |
|
|
echo "MODULES=\"${modules}\"" >> ${config} |
|
|
echo "IMAGE_TYPE=\"initramfs\"" >> ${config} |
|
|
|
|
|
${chroot} mkinitrd -f ${initrd} ${kernel} |
|
268 |
} |
} |
269 |
|
|
270 |
chrooted() |
chrooted() |
271 |
{ |
{ |
272 |
local cmd="$@" |
local cmd="$@" |
273 |
|
|
274 |
mount -t sysfs sysfs ${INSTALL_ROOT}/sys |
is_mounted --location ${INSTALLROOT}/sys || mount -t sysfs sysfs ${INSTALLROOT}/sys |
275 |
mount -t proc proc ${INSTALL_ROOT}/proc |
is_mounted --location ${INSTALLROOT}/proc || mount -t proc proc ${INSTALLROOT}/proc |
276 |
mount -o bind /dev ${INSTALL_ROOT}/dev |
is_mounted --location ${INSTALLROOT}/dev || mount -o bind /dev ${INSTALLROOT}/dev |
277 |
|
|
278 |
chroot ${INSTALL_ROOT} ${cmd} |
chroot ${INSTALLROOT} ${cmd} |
279 |
|
|
280 |
umount ${INSTALL_ROOT}/dev |
is_mounted --location ${INSTALLROOT}/dev && umount ${INSTALLROOT}/dev |
281 |
umount ${INSTALL_ROOT}/proc |
is_mounted --location ${INSTALLROOT}/proc && umount ${INSTALLROOT}/proc |
282 |
umount ${INSTALL_ROOT}/sys |
is_mounted --location ${INSTALLROOT}/sys && umount ${INSTALLROOT}/sys |
283 |
} |
} |