From 59709f139ee8c1d4fbb320deb8785abc90a012c1 Mon Sep 17 00:00:00 2001 From: r00t Date: Wed, 4 Feb 2015 19:56:39 -0500 Subject: [PATCH 1/2] whoops. THIS should get a working overlayfs, fingers crossed --- .../pre-build.d/etc/mkinitcpio.d/linux.preset | 15 ++++++++++++++ .../usr/lib/initcpio/hooks/archiso-custom | 20 ++++++------------- .../pre-build.d/usr/lib/initcpio/hooks/livecd | 6 ++---- 3 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 extra/pre-build.d/etc/mkinitcpio.d/linux.preset diff --git a/extra/pre-build.d/etc/mkinitcpio.d/linux.preset b/extra/pre-build.d/etc/mkinitcpio.d/linux.preset new file mode 100644 index 0000000..41cb2a8 --- /dev/null +++ b/extra/pre-build.d/etc/mkinitcpio.d/linux.preset @@ -0,0 +1,15 @@ +# mkinitcpio preset file for the 'linux' package + +ALL_config="/etc/mkinitcpio.conf" +ALL_kver="/boot/vmlinuz-linux" + +#PRESETS=('default' 'fallback') +PRESETS=('default') + +#default_config="/etc/mkinitcpio.conf" +default_image="/boot/initramfs-linux.img" +#default_options="" + +#fallback_config="/etc/mkinitcpio.conf" +#fallback_image="/boot/initramfs-linux-fallback.img" +#fallback_options="-S autodetect" diff --git a/extra/pre-build.d/usr/lib/initcpio/hooks/archiso-custom b/extra/pre-build.d/usr/lib/initcpio/hooks/archiso-custom index 8620639..673fc26 100644 --- a/extra/pre-build.d/usr/lib/initcpio/hooks/archiso-custom +++ b/extra/pre-build.d/usr/lib/initcpio/hooks/archiso-custom @@ -11,19 +11,13 @@ _mnt_fs() { ro_dev=$(losetup --find --show --read-only "${img}") echo ${ro_dev} >> /run/archiso/used_block_devices ro_dev_size=$(blockdev --getsz ${ro_dev}) - if [[ "${cowfile_size}" == "100" ]]; then - rw_dev_size=${ro_dev_size} - else - # size calculation done in this way to avoid integer overflow when ro_dev_size is > 10.2G - rw_dev_size=$((ro_dev_size/100*cowfile_size)) - fi if [[ "${cow_persistent}" == "P" ]]; then if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then msg ":: Found '/run/archiso/cowspace/${cow_directory}/${img_name}.cow', using as persistent." else msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as persistent." - dd of="/run/archiso/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${rw_dev_size} &> /dev/null + truncate -s "${cowfile_size}" "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" fi else if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then @@ -31,13 +25,13 @@ _mnt_fs() { rm -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" fi msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as non-persistent." - dd of="/run/archiso/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${rw_dev_size} &> /dev/null + truncate -s "${cowfile_size}" "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" fi rw_dev=$(losetup --find --show "/run/archiso/cowspace/${cow_directory}/${img_name}.cow") echo ${rw_dev} >> /run/archiso/used_block_devices - echo "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8" | dmsetup create ${dm_snap_name} + dmsetup create ${dm_snap_name} --table "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8" _mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w" echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/archiso/used_block_devices @@ -108,9 +102,7 @@ run_hook() { [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" if [[ -z "${cowfile_size}" ]]; then - cowfile_size="100" - else - cowfile_size=${cowfile_size/%} + cowfile_size="256M" fi if [[ -n "${cow_label}" ]]; then @@ -175,8 +167,8 @@ archiso_mount_handler() { mkdir -p "/run/archiso/cowspace/${cow_directory}" _mnt_sfs "/run/archiso/bootmnt/${archisobasedir}/${arch}/airootfs.sfs" "/run/archiso/sfs/airootfs" - # _mnt_fs "/run/archiso/sfs/airootfs/airootfs.img" "${newroot}" "/" - mount --bind "run/archiso/sfs/airootfs" "/new_root" + #_mnt_fs "/run/archiso/sfs/airootfs/airootfs.img" "${newroot}" "/" + mount --bind "/run/archiso/sfs/airootfs" "/new_root" if [[ "${copytoram}" == "y" ]]; then umount /run/archiso/bootmnt diff --git a/extra/pre-build.d/usr/lib/initcpio/hooks/livecd b/extra/pre-build.d/usr/lib/initcpio/hooks/livecd index 1b1f6b0..015f8a1 100644 --- a/extra/pre-build.d/usr/lib/initcpio/hooks/livecd +++ b/extra/pre-build.d/usr/lib/initcpio/hooks/livecd @@ -6,10 +6,8 @@ run_cleanuphook () { echo "Now attempting overlay mount..." - mkdir /new_root.hw + mkdir -p /new_root.hw /overlay /overlay-rw mount --move /new_root /new_root.hw - mkdir /dev/shm - mount -t tmpfs none /dev/shm - mount -t overlay overlay -olowerdir=/new_root.hw,upperdir=/new_root,workdir=/dev/shm -o noatime + mount -t overlay overlay -olowerdir=/new_root.hw,upperdir=/overlay,workdir=/overlay-rw,noatime /new_root pkill -9 dropbear #kill SSH (in preparation for the live system starting ssh on port 22 } From 5cbab2dc0c6ce0d4ef4c14868716e763054f7baa Mon Sep 17 00:00:00 2001 From: r00t Date: Wed, 4 Feb 2015 22:54:27 -0500 Subject: [PATCH 2/2] intermediary --- extra/packages.both | 1 + extra/pre-build.d/usr/lib/initcpio/hooks/livecd | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/extra/packages.both b/extra/packages.both index 7bd67d8..c8e4859 100644 --- a/extra/packages.both +++ b/extra/packages.both @@ -115,6 +115,7 @@ hddtemp hdparm hexcurse hexedit +hfsprogs hfsutils htop httping diff --git a/extra/pre-build.d/usr/lib/initcpio/hooks/livecd b/extra/pre-build.d/usr/lib/initcpio/hooks/livecd index 015f8a1..87386b8 100644 --- a/extra/pre-build.d/usr/lib/initcpio/hooks/livecd +++ b/extra/pre-build.d/usr/lib/initcpio/hooks/livecd @@ -6,8 +6,13 @@ run_cleanuphook () { echo "Now attempting overlay mount..." - mkdir -p /new_root.hw /overlay /overlay-rw - mount --move /new_root /new_root.hw - mount -t overlay overlay -olowerdir=/new_root.hw,upperdir=/overlay,workdir=/overlay-rw,noatime /new_root + #mkdir /new_root.hw + mkdir -p /run/archiso/cowspace/upperdir /run/archiso/cowspace/workdir + #mount --move /new_root /new_root.hw + #mkdir /dev/shm + #mount -t tmpfs none /dev/shm + #mount -t overlay overlay -olowerdir=/new_root.hw,upperdir=/new_root,workdir=/dev/shm -o noatime + umount -l /new_root > /dev/null 2>&1 + mount -t overlay -o lowerdir=/run/archiso/sfs/airootfs,upperdir=/run/archiso/cowspace/upperdir,workdir=/run/archiso/cowspace/workdir airootfs /new_root pkill -9 dropbear #kill SSH (in preparation for the live system starting ssh on port 22 }