Problem compiling kernel using fakeroot
Sorry for this newbie question. Not sure if this is related to Crux but I always compiled the kernel using sudo and never had any problems. Recently decided to try fakeroot and always get corrupted xz image at boot. Is the kernel supposed to be always compiled as root in Crux? What am I missing here?
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi, On Wed, 17 Mar 2021, Prophet wrote:
Sorry for this newbie question.
nothing to be sorry for.
Not sure if this is related to Crux but I always compiled the kernel using sudo and never had any problems. Recently decided to try fakeroot and always get corrupted xz image at boot. Is the kernel supposed to be always compiled as root in Crux? What am I missing here?
You should be able to compile the kernel as any user (no need for fakeroot). The installation requires root, though (assuming, /boot is owned by root, as it should be). I'm doing as a regular user: make oldconfig make and then run as root: install -m644 --owner=root $kernelImage /boot/vmlinuz-$version grub-mkconfig -o /boot/grub/grub.cfg Note, that I do not have an initramdisk, but it should work similarily if you have one. What exactly are you trying, that fails? I had problems in the past with left-over files from previous compilations - a `git clean -xdf .` did help, there. HTH, Erich -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE3p92iMrPBP64GmxZCu7JB1Xae1oFAmBSAxQACgkQCu7JB1Xa e1pknRAAj1Opecjfwn2y4AAQATX/Sz/XdqXHdQ+QZgaSt/CDHZ5l9Ob1bU2HrYkv D4Xwo4YrjKDSiq/JFDTU+ML+0CJWKSKjUnyf2FYBbe0f7JKjWY+ktEFAxC0Q8wdF 6ViMak77d40hRYi0SAzWSBITrAAMNO82x5VVAyTmRH2NHXkAoAJRQ6paMuYJoVH6 yQaklEvV1TIEyGHfolGSwBK9WHVE41BmVXjCGIin6WjBouOHEoynDyKrhieo4OSU /8qzVLLW8Seg7sV+GxdN99yTLWB3RXUoEdNM6RngtwMkicgE1bic4HX080dFVGQ3 CyUhI11ULv3vMpWzGIdD7yn1LO6DnPwG2HkWpJg1kQzA54tu1Cttsja0WqtYhUXA jdTzQGWNGMAbUU6p3hrRa85353kgzCvC1asxe2mOk031TQhUo7ZypwhCyMFBcuT5 y9Sb4+p5aWIpzyOdLQFLCPmvIV0visokEC9Y9IwY3L4wUaaGLmGIHJ/MKeCewxvn ILUCIkymWZN5xEdOUOI+M823oZD/FffauYhh0lE9WV+rgpZ6e69hOgear1N4N3xL 69Fgaonp96XA5n+1U1EPGiVb1zRWlWfs10ZtHtZho2RBO8vCk5Q57j36c9bfPnQ+ 4Puhia5D8jkOocb3vk0gesMQczghNi9NvQOQ/Lvb3jf0Nx4v5H8= =PLL4 -----END PGP SIGNATURE-----
Erich Eckner wrote in <a44ccda3-bfd9-32d3-bb91-446a5d93a7@eckner.net>: |On Wed, 17 Mar 2021, Prophet wrote: |> Sorry for this newbie question. | |nothing to be sorry for. | |> Not sure if this is related to Crux but I always compiled the kernel \ |> using |> sudo and never had any problems. Recently decided to try fakeroot \ |> and always |> get corrupted xz image at boot. Is the kernel supposed to be always \ |> compiled |> as root in Crux? What am I missing here? | |You should be able to compile the kernel as any user (no need for |fakeroot). The installation requires root, though (assuming, /boot is |owned by root, as it should be). I'm doing as a regular user: | |make oldconfig |make | |and then run as root: | |install -m644 --owner=root $kernelImage /boot/vmlinuz-$version |grub-mkconfig -o /boot/grub/grub.cfg Yeah -- maybe the wrong (uncompressed) kernel? |Note, that I do not have an initramdisk, but it should work similarily if |you have one. Me neither (yet). I compile the kernel as "ports": hn=$(uname -n) ln=linux-version-as-major-minor objdir=/tmp/linuxobj cp /root/hosts/$hn/linux-$ln.config \ /usr/src/linux-$ln/.$hn-$ln.config || exit 2 chown ports:ports /usr/src/linux-$ln/.$hn-$ln.config || exit 3 [ -x /root/bin/cpupower.sh ] && /root/bin/cpupower.sh hi sudo -u ports sh -c ' ( objdir='$objdir' cd /usr/src/linux-'$ln' || exit 10 if [ -d $objdir ]; then if [ -n "$_cleanup" ]; then ( cd $objdir && make mrproper ) fi else mkdir -p $objdir || exit 1 fi printf -- "-'$hn'\n" > $objdir/localversion-build || exit 3 cp .'$hn-$ln'.config $objdir/.config || exit 2 #sudo -u ports make O=$objdir listnewconfig oldconfig || exit 4 # Documentation/admin-guide/README.rst: "make localmodconfig" #[lsmod>f; LSMOD=f ]make O=$objdir localyesconfig oldconfig || exit 4 nice -n +10 make O=$objdir oldconfig || exit 4 cd $objdir || exit 5 time nice -n +10 make -j`getconf _NPROCESSORS_ONLN` ) 2>&1 ' [ -x /root/bin/cpupower.sh ] && /root/bin/cpupower.sh default followed by (well it is all optional ;) copies as "root": cp $objdir/arch/x86/boot/bzImage $efipart/$hn-$xln-new.efi cp $objdir/System.map $efipart/System.map-$version-$hn ... make modules_install (none, actually) |What exactly are you trying, that fails? I had problems in the past with |left-over files from previous compilations - a `git clean -xdf .` did |help, there. cleanup is then if [ -n "$_cleanup" ]; then rm -rf /tmp/.$hn-fw if [ "${objdir%/*}" = /tmp ]; then rm -rf $objdir else ( cd $objdir make mrproper ) >/dev/null fi fi Anyhow, kernel building is not yet boxed. I use efibootmgr: if [ -n "$_efiactive" ]; then if command -v efibootmgr >/dev/null 2>&1 && { efibootmgr | grep -q $hn-$ln-new; }; then bn=`efibootmgr | grep $hn-$ln-new | sed -Ee 's/^Boot([[:digit:]]+).+$/\1/'` efibootmgr -v -n $bn fi fi Well i install the kernel as -new, and boot it once. When booting succeeds with the right kernel, it is moved automatically: { i=1 while :; do ( set -C : > /root/hosts/$hn/.rc-late-hook-$i ) >/dev/null 2>&1 && break i=$((i + 1)) done printf " v=\`uname -r | cut -d- -f1\` if [ \"\$v\" = \"$version\" ]; then if [ "$efipart" != /boot ];then mount $efipart else mount -o remount,rw "$efipart" fi [ -f $efipart/$hn-$xln-new.efi ] && mv -f $efipart/$hn-$xln-new.efi $efipart/$hn-$xln.efi if [ "$efipart" != /boot ]; then umount $efipart else mount -o remount,ro "$efipart" fi exit 0 else echo >&2 'NOT moving kernel on EFI ('$efipart')!' exit 1 fi " > /root/hosts/$hn/.rc-late-hook-$i } Works pretty nice in practice ever since. Yay! --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
I dont use git. I wget the kernel and signature from kernel.org to my home directory. Then cp the verified and unpacked tar file to /usr/src. In there the usual sudo make -j4 all, sudo make modules install. Copy the System-map and arch/x86/boot/bzImage to /boot. And finally edit and run lilo. This has always worked without any problem but if I try to reproduce those steps but doing the compilation phase with my user (or even fakeroot) in my /home dir, always results in a corrupted xz image error when i boot. I suspected it was ownership issues compiling as regular user but not sure about that anymore. On 3/17/21 2:37 PM, Steffen Nurpmeso wrote:
Erich Eckner wrote in <a44ccda3-bfd9-32d3-bb91-446a5d93a7@eckner.net>: |On Wed, 17 Mar 2021, Prophet wrote: |> Sorry for this newbie question. | |nothing to be sorry for. | |> Not sure if this is related to Crux but I always compiled the kernel \ |> using |> sudo and never had any problems. Recently decided to try fakeroot \ |> and always |> get corrupted xz image at boot. Is the kernel supposed to be always \ |> compiled |> as root in Crux? What am I missing here? | |You should be able to compile the kernel as any user (no need for |fakeroot). The installation requires root, though (assuming, /boot is |owned by root, as it should be). I'm doing as a regular user: | |make oldconfig |make | |and then run as root: | |install -m644 --owner=root $kernelImage /boot/vmlinuz-$version |grub-mkconfig -o /boot/grub/grub.cfg
Yeah -- maybe the wrong (uncompressed) kernel?
|Note, that I do not have an initramdisk, but it should work similarily if |you have one.
Me neither (yet). I compile the kernel as "ports":
hn=$(uname -n) ln=linux-version-as-major-minor objdir=/tmp/linuxobj
cp /root/hosts/$hn/linux-$ln.config \ /usr/src/linux-$ln/.$hn-$ln.config || exit 2 chown ports:ports /usr/src/linux-$ln/.$hn-$ln.config || exit 3
[ -x /root/bin/cpupower.sh ] && /root/bin/cpupower.sh hi sudo -u ports sh -c ' ( objdir='$objdir' cd /usr/src/linux-'$ln' || exit 10 if [ -d $objdir ]; then if [ -n "$_cleanup" ]; then ( cd $objdir && make mrproper ) fi else mkdir -p $objdir || exit 1 fi printf -- "-'$hn'\n" > $objdir/localversion-build || exit 3 cp .'$hn-$ln'.config $objdir/.config || exit 2 #sudo -u ports make O=$objdir listnewconfig oldconfig || exit 4 # Documentation/admin-guide/README.rst: "make localmodconfig" #[lsmod>f; LSMOD=f ]make O=$objdir localyesconfig oldconfig || exit 4 nice -n +10 make O=$objdir oldconfig || exit 4 cd $objdir || exit 5 time nice -n +10 make -j`getconf _NPROCESSORS_ONLN` ) 2>&1 ' [ -x /root/bin/cpupower.sh ] && /root/bin/cpupower.sh default
followed by (well it is all optional ;) copies as "root":
cp $objdir/arch/x86/boot/bzImage $efipart/$hn-$xln-new.efi cp $objdir/System.map $efipart/System.map-$version-$hn ... make modules_install (none, actually)
|What exactly are you trying, that fails? I had problems in the past with |left-over files from previous compilations - a `git clean -xdf .` did |help, there.
cleanup is then
if [ -n "$_cleanup" ]; then rm -rf /tmp/.$hn-fw if [ "${objdir%/*}" = /tmp ]; then rm -rf $objdir else ( cd $objdir make mrproper ) >/dev/null fi fi
Anyhow, kernel building is not yet boxed. I use efibootmgr:
if [ -n "$_efiactive" ]; then if command -v efibootmgr >/dev/null 2>&1 && { efibootmgr | grep -q $hn-$ln-new; }; then bn=`efibootmgr | grep $hn-$ln-new | sed -Ee 's/^Boot([[:digit:]]+).+$/\1/'` efibootmgr -v -n $bn fi fi
Well i install the kernel as -new, and boot it once. When booting succeeds with the right kernel, it is moved automatically:
{ i=1 while :; do ( set -C : > /root/hosts/$hn/.rc-late-hook-$i ) >/dev/null 2>&1 && break i=$((i + 1)) done
printf " v=\`uname -r | cut -d- -f1\` if [ \"\$v\" = \"$version\" ]; then if [ "$efipart" != /boot ];then mount $efipart else mount -o remount,rw "$efipart" fi [ -f $efipart/$hn-$xln-new.efi ] && mv -f $efipart/$hn-$xln-new.efi $efipart/$hn-$xln.efi if [ "$efipart" != /boot ]; then umount $efipart else mount -o remount,ro "$efipart" fi exit 0 else echo >&2 'NOT moving kernel on EFI ('$efipart')!' exit 1 fi " > /root/hosts/$hn/.rc-late-hook-$i }
Works pretty nice in practice ever since. Yay!
--steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt) _______________________________________________ CRUX mailing list CRUX@lists.crux.nu https://lists.crux.nu/mailman/listinfo/crux
participants (3)
-
Erich Eckner
-
Prophet
-
Steffen Nurpmeso