Skip to content

Instantly share code, notes, and snippets.

@egeneralov
Created December 28, 2019 04:52
Show Gist options
  • Select an option

  • Save egeneralov/89f6294f5cdfabffc9c15d9fa9bf14ba to your computer and use it in GitHub Desktop.

Select an option

Save egeneralov/89f6294f5cdfabffc9c15d9fa9bf14ba to your computer and use it in GitHub Desktop.
#!/bin/sh -xe
# backup
cp /usr/share/initramfs-tools/scripts/local{,.orig}
cp /etc/fstab{,.orig}
# prepare
echo 'none / tmpfs defaults 0 0' > /etc/fstab
# echo 'none / tmpfs defaults,noatime,nodiratime,discard 0 0' > /etc/fstab
curl -s https://gist.githubusercontent.com/egeneralov/89f6294f5cdfabffc9c15d9fa9bf14ba/raw/f4cf9c786ef818c333a2e5d0c10401b1706ab933/local.patch | patch -p0 /usr/share/initramfs-tools/scripts/local
# build
mkinitramfs -o /boot/initrd.img-ramboot
# restore
cp /usr/share/initramfs-tools/scripts/local{.orig,}
cp /etc/fstab{.orig,}
183,193c183,187
< # if [ "${FSTYPE}" != "unknown" ]; then
< # mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
< # else
< # mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
< # fi
< mkdir /ramboottmp
< mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} /ramboottmp
< mount -t tmpfs -o size=100% none ${rootmnt}
< cd ${rootmnt}
< cp -rfa /ramboottmp/* ${rootmnt}
< umount /ramboottmp
---
> if [ "${FSTYPE}" != "unknown" ]; then
> mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
> else
> mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
> fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment