#!/bin/bash -e chroot_path=/tmp/chroot # Install base and some needed packages mkarchroot -f $chroot_path base mkinitcpio-nfs-utils # This adds cifs and loop modules to the initcpio image cp mount.cifs mount.loop -t $chroot_path/lib/initcpio/install # Add mount hook (http://aur.archlinux.org/packages.php?ID=40372) wget "http://people.oh14.de/andrej/mkinitcpio-mount-hook/mkinitcpio-mount-hook-0.3-stickbuild.tar.xz" -O - | tar -xJ --wildcards -C /tmp mkinitcpio-mount-hook-0.3/initcpio/*/mount cp -r /tmp/mkinitcpio-mount-hook-0.3/initcpio/* -t $chroot_path/lib/initcpio # Remove hard drives support and keep only needed hooks (added: net, mount, mount.cifs, mount.loop) sudo sed -i 's/^HOOKS=".*"/HOOKS="base udev net filesystems mount mount.cifs mount.loop"/' $chroot_path/etc/mkinitcpio.conf # Keep only one initcpio image (we don't need fallback) sed -i "s/^PRESETS=.*/PRESETS=('default')/" $chroot_path/etc/mkinitcpio.d/kernel26.preset # Adapt network configuration for network-based root sed -i 's/^DHCPCD_ARGS="-q"$/DHCPCD_ARGS="-q -p"/' $chroot_path/etc/conf.d/dhcpcd sed -i 's/^interface=$/interface=eth0/' $chroot_path/etc/rc.conf sed -i 's/^NETWORK_PERSIST="no"$/NETWORK_PERSIST="yes"/' $chroot_path/etc/rc.conf # Rebuild initcpio image mkarchroot -r "mkinitcpio -p kernel26" $chroot_path
# vim:set ft=sh: install () { MODULES="cifs hmac md4 md5" BINARIES="" FILES="" SCRIPT="" } help () { cat <<HELPEOF This hook helps to mount cifs. HELPEOF }
# vim:set ft=sh: install () { MODULES="loop" BINARIES="" FILES="" SCRIPT="" } help () { cat <<HELPEOF This hook helps to mount loop images. HELPEOF }
#!/bin/bash -e dd if=/dev/null of=/tmp/arch.img bs=1M seek=1024 mkfs.ext4 -F /tmp/arch.img mkdir /tmp/chroot mount /tmp/arch.img /tmp/chroot
#!/bin/bash -e cp /tmp/chroot/boot/{vmlinuz26,kernel26.img} /tmp umount /tmp/arch.img
# grub
kernel /boot/vmlinuz26 ip=::::::dhcp mounts=cifs,root cifs_dev=//SERVER_IP/share cifs_target=/cifs cifs_type=cifs cifs_opts=username=guest root_dev=/cifs/arch.img root_type=ext4
initrd /boot/kernel26.img
# isolinux/pxelinux
kernel vmlinuz26
append initrd=kernel26.img ip=::::::dhcp mounts=cifs,root cifs_dev=//SERVER_IP/share cifs_target=/cifs cifs_type=cifs cifs_opts=username=guest root_dev=/cifs/arch.img root_type=ext4
Source: https://habr.com/ru/post/122708/
All Articles