Welcome to the Linux Foundation Forum!

wastemem script

Copying and pasting the wastemem script is taking more time than I'd like.

running this:

gcc -o lab_wastemem lab_wastemem.c

results in

c1: fatal error: lab_wastemem.c: No such file or directory

Thanks for assistance.

Comments

  • Hi Michael,

    You are most likely trying to compile lab_wastemem.c in the wrong directory. Try to find the absolute path of the file, that may help you:

    gcc -o lab_wastemem /home/youruser/Downloads/LFS207/SOLUTIONS/s_17/lab_wastemem.c

    Reagrds,
    Vlad

  • coop
    coop Posts: 917

    Thanks @vipopescu. In fact as you scroll down to the solution you will also see s_17/lab_waste.sh. Which will do the compile for you although it is so simple it adds little. Make sure you understand the "RESOURCES" and "SOLUTIONS" tar balls that are mentioned in the introduction. You will need to use them again when you get to the virtualization labs for example. You definitely were not meant to cut and paste the source for the lab. Very error-prone.

  • Thanks guys! I figured out my mistake. You're right @vipopescu, I was simply in the wrong directory!

  • problem see SOLUTIONS/s_16/lab_wastemem.ch
    problem see SOLUTIONS/s_16/lab_waste.sh

    above given lab link was is not valid link could please share valid script .sh ?

  • luisviveropena
    luisviveropena Posts: 1,333

    Hi @sriramvassuthev,

    I just downloaded the "solutions" file and extracted it. Once you have extracted the .tar.xz file, you will find the files here:

    LFS207/SOLUTIONS/s_16/

    Perhaps you missed the LFS207 directory.

    Regards,
    Luis.

  • Yes Correct I missed the that file Yeah i got in from this below link.

    https://prep.lf.training/?course=LFS207

    Regards,
    Sriramvassuthev

  • luisviveropena
    luisviveropena Posts: 1,333

    Hi Sriramvassuthev,

    I'm glad that the issue is solved.

    Regards,
    Luis.

  • Hello Luisviveropena,

    Yes. It Resolve.

    When I saw the Script. where lab_waste.sh is integrated with lab_wastemem.ch.

    When I Learning this Chapter -21. Filesystem Features: Attributes, Creating, Checking, Usage, Mounting -> Mounting Filesystems (Lesson).

    Each filesystem is mounted under a specific directory, as in the following command:

    $ mount -t ext /dev/sdb4 /home

    • Mounts an ext4 filesystem
    • Usually not necessary to specify the type with the -t option
    • The filesystem is located on a specific partition of a hard drive (/dev/sdb4)
    • The filesystem is mounted at the position /home in the current directory tree
    • Any files residing in the original /home directory are hidden until the partition is unmounted

    In this , instead of ext have to user ext4 in the command.

    Thanks & Regards,
    Sriram Vassuthev.S

  • Hi @sriramvassuthev, I'm glad that the original issue was solved :)

    Regarding the second thing:

    Usually not necessary to specify the type with the -t option

    Yep, that's right, the OS will try to auto detect it. But also it's not wrong, and in some cases it can be useful, if the OS don't recognize the filesystem type. From the man page for 'mount':

    If no -t option is given, or if the auto type is specified, mount will try to guess the desired type. Mount uses the blkid or volume_id library for guessing the filesystem type; if that does not turn up anything that looks familiar, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems. All of the filesystem types listed there will be tried, except for those that are labeled "nodev" (e.g., devpts, proc and nfs). If /etc/filesystems ends in a line with a single * only, mount will read /proc/filesystems afterwards.

    Regards,
    Luis.

  • Hi @Luis,

    I am clear.

    By Blank, i am asking below question.

    is there filesystem type easily to adopt with different machine and different OS can easily understand mount into system and do process as per user request or Machine request?

    Like Common to all OS. Instruction will be different for each OS.

    is there any tool to backup only Meta Data Information of System ?

    Regards,
    Sriram Vassuthev.S

  • Hi @sriramvassuthev,

    is there filesystem type easily to adopt with different machine and different OS
    can easily understand mount into system and do process as per user request or Machine request?

    Can you elaborate on this, please? Do you want to access a filesystem through the network from more than one device?

    Please open a new thread for this question, as it's different from the original one, which is already solved.

    Regards,
    Luis.

  • Yes Ok. I will Open it new thread.

  • Hello - when trying to download lab_wastemem.c in the link at the bottom of the lab notes (solution 16.2) I get the error "Error: jwt expired".

  • Hi @badpotato,

    It refers to the files you need to download from the Course Resources website. So you need to get a compressed file for the Solutions, uncompress it and you will find the files.

    The information about this in on Chapter 1 Course Information / Course Support and Other Resources.

    Regards,
    Luis.

  • mbake4
    mbake4 Posts: 4

    Hello all,

    I am getting some trouble when I attempt to perform the following command:

    gcc -o lab_wastemem /home/myusername/LFS207/SOLUTIONS/s_16/lab_wastemem.c

    I get the error: fatal error linux/kernel.h: No such file or directory.

    I have tried multiple solutions to try and add the file to my os, including sudo apt install build-essential, sudo apt install linux-headers-$(name -r), and sudo apt install --reinstall lib-6-dev. When performing the locate utility to fine kernel.h files, I found multiple results under the usr/src/linux-headers-6.14.0-33 and usr/src/linux-headers-6.14.0-37 directories, so it appears I do have the file, so I am wondering why the error is still being produced here. Can someone assist with this?

  • luisviveropena
    luisviveropena Posts: 1,333

    Hi @mbake4,

    Yes, that error indicates that the kernel headers are not present in the system.

    1.- What OS and version are you working with? In my case I'm running Ubuntu 24.04.4 LTS.
    2.- Provide kernel version:

    uname -r

    My OS:

    6.8.0-110-generic

    3.- What kernel headers packages do you have on your system?

    dpkg -l | grep linux-
    ii binutils-x86-64-linux-gnu 2.42-4ubuntu2.10 amd64 GNU binary utilities, for x86-64-linux-gnu target
    ii cpp-13-x86-64-linux-gnu 13.3.0-6ubuntu2~24.04.1 amd64 GNU C preprocessor for x86_64-linux-gnu
    ii cpp-x86-64-linux-gnu 4:13.2.0-7ubuntu1 amd64 GNU C preprocessor (cpp) for the amd64 architecture
    ii gcc-13-x86-64-linux-gnu 13.3.0-6ubuntu2~24.04.1 amd64 GNU C compiler for the x86_64-linux-gnu architecture
    ii gcc-x86-64-linux-gnu 4:13.2.0-7ubuntu1 amd64 GNU C compiler for the amd64 architecture
    ii linux-base 4.5ubuntu9+24.04.2 all Linux image base package
    ii linux-image-6.8.0-107-generic 6.8.0-107.107 amd64 Signed kernel image generic
    ii linux-image-6.8.0-110-generic 6.8.0-110.110 amd64 Signed kernel image generic
    ii linux-image-virtual 6.8.0-110.110 amd64 Virtual Linux kernel image
    ii linux-libc-dev:amd64 6.8.0-110.110 amd64 Linux Kernel Headers for development
    ii linux-modules-6.8.0-107-generic 6.8.0-107.107 amd64 Linux kernel extra modules for version 6.8.0 on 64 bit x86 SMP
    ii linux-modules-6.8.0-110-generic 6.8.0-110.110 amd64 Linux kernel extra modules for version 6.8.0 on 64 bit x86 SMP
    ii linux-tools-6.8.0-107 6.8.0-107.107 amd64 Linux kernel version specific tools for version 6.8.0-107
    ii linux-tools-6.8.0-107-generic 6.8.0-107.107 amd64 Linux kernel version specific tools for version 6.8.0-107
    ii linux-tools-common 6.8.0-110.110 all Linux kernel version specific tools for version 6.8.0

    In my case I have linux-libc-dev version 6.8.0-110.110 , which matches the running kernel.

    4.- Then running the compiler:

    luis@ubuntuserver1:~/LFS207/Lab16.2$ ls -l
    total 8
    -rwxr-xr-x 1 luis luis 506 Apr 21 15:17 lab_waste.sh
    -rw-r--r-- 1 luis luis 1751 Apr 21 15:17 lab_wastemem.c

    luis@ubuntuserver1:~/LFS207/Lab16.2$ gcc -o lab_wastemem lab_wastemem.c
    luis@ubuntuserver1:~/LFS207/Lab16.2$ ls -l
    total 28
    -rwxr-xr-x 1 luis luis 506 Apr 21 15:17 lab_waste.sh
    -rwxrwxr-x 1 luis luis 16472 Apr 21 15:32 lab_wastemem
    -rw-r--r-- 1 luis luis 1751 Apr 21 15:17 lab_wastemem.c

    Regards,
    Luis.

  • mbake4
    mbake4 Posts: 4
    edited April 21

    Thank you @luisviveropena!

    I am running Ubuntu version 25.04 via a VirtualBox VM
    I am using kernel version 6.14.0 (generic)

    When reviewing the kernel headers packages, I did find that I have:

    meredith-baker@MereUbuntu:~$ dpkg -l | grep linux-

    ii linux-libc-dev:arm64 6.14.0-37.37 arm64 Linux Kernel Headers for development

    So it should appear to match in this case, right?

    When listing the compiler components (ls -l), I receive the following results:

    meredith-baker@MereUbuntu:~/LFS207/SOLUTIONS/s_16$ ls -l
    total 12
    drwxr-xr-x 2 meredith-baker meredith-baker 4096 Jun 14 2024 EXAMPLES
    -rw-r--r-- 1 meredith-baker meredith-baker 1751 Jun 14 2024 lab_wastemem.c
    -rwxr-xr-x 1 meredith-baker meredith-baker 506 Jun 14 2024 lab_waste.sh

    yet, I am still getting an error when trying to run the compiler at this point:

    meredith-baker@MereUbuntu:~$ gcc -o lab_wastemem /home/meredith-baker/LFS207/SOLUTIONS/s_16/lab_wastemem.c
    In file included from /home/meredith-baker/LFS207/SOLUTIONS/s_16/lab_wastemem.c:20:
    /usr/include/aarch64-linux-gnu/sys/sysinfo.h:24:10: fatal error: linux/kernel.h: No such file or directory
    24 | #include <linux/kernel.h>
    | ^~~~

  • luisviveropena
    luisviveropena Posts: 1,333

    Hi @mbake4,

    1.- You need to compare the version of package linux-libc-dev against/with the kernel version that you system is running. I.e., what's the output for:

    uname -r

    2.- Are you working with ARM Architecture?

    Regards,
    Luis.

  • mbake4
    mbake4 Posts: 4

    Thank you @luisviveropena!

    Apologies here. I did put it above but I didn't confirm the outputs received.

    My kernel release (uname -r) is
    6.14.0-37-generic

    The architecture type (uname -m) is
    aarch64

    Which to my knowledge is the technical term for ARM64 correct?

    If so, would the header package I have match what I need to run the compiler successfully?

    meredith-baker@MereUbuntu:~$ dpkg -l | grep linux-
    ii linux-libc-dev:arm64 6.14.0-37.37 arm64 Linux Kernel Headers for development

  • luisviveropena
    luisviveropena Posts: 1,333

    Hi @mbake4,

    I wanted to do a test case on the distro and version you are using, and I found that Ubuntu 25.04 already reached it's end of life cycle, so it's not supported anymore by Ubuntu.

    I recommend using Ubuntu 24.04.4 LTS, which is available for ARM. So I can do tests on Ubuntu 24.04.4 for AMD64, which will be the same in terms of versioning for packages.

    Regards,
    Luis.

  • mbake4
    mbake4 Posts: 4

    Thank you @luisviveropena!

    It was able to work when switching to Ubuntu 24.04.4 LTS. Thank you for your help!

  • luisviveropena
    luisviveropena Posts: 1,333

    Hi @mbake4,

    It's a pleasure! I'm glad that the issue is solved.

    Regards,
    Luis.

Categories

Upcoming Training