Tuesday, February 22, 2022

Recent Questions - Unix & Linux Stack Exchange

Recent Questions - Unix & Linux Stack Exchange


How to get PID of autostarting process?

Posted: 22 Feb 2022 04:34 AM PST

I wrote a small python script that logs data from USB stream. I used crontab (@reboot python /path/to/my/file.py &) to schedule running this script on startup of my Raspberry Pi. The script works fine and logs data. However, I can't list this process using jobs or ps (or sudo ps) cmds. When I run this script by hand adequate process is listed by mentioned cmds.

How can I acquire PID of this autostarting script?

rename attachments using mailx command without uuencode

Posted: 22 Feb 2022 03:57 AM PST

earlier I was using system("(echo \"demo attachment\"; uuencode demo.txt rename.txt )| mailx -r ${mail_from} -s \"${subject}\" ${emailids}"); this to send attachments which will rename the file to rename.txt from demo.txt. now I am using mailx -a command to send attachments . system("echo \"demo attachment\" | mailx -s \"${subject}\" -a demo.txt -r ${mail_from} ${emailids}"); . Is there any way to rename my attachment using mailx -a switch?

Serial device (/dev/serial/) not showing up on Android

Posted: 22 Feb 2022 03:47 AM PST

Trying to connect a serial device (3d printer) through the USB port in order to communicate with it (klipper firmware) on an Android device (LOS 18.1/Android 11, 3.18 kernel). But I can't find it in /dev/serial/, it only shows up as /dev/ttyUSB0 and /dev/bus/usb/001/00[^1] and I can't communicate with it through those. I've compiled the kernel with the ch341.c driver. 'lsusb -v' from a chrooted Debian through Linux deploy gives the following output, the device in question is called 'QinHeng Electronics CH340...':

Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub  Device Descriptor:    bLength                18    bDescriptorType         1    bcdUSB               3.00    bDeviceClass            9 Hub    bDeviceSubClass         0    bDeviceProtocol         3    bMaxPacketSize0         9    idVendor           0x1d6b Linux Foundation    idProduct          0x0003 3.0 root hub    bcdDevice            3.18    iManufacturer           3 Linux 3.18.140-Swan-gcb3e40e597b0-dirty xhci-hcd    iProduct                2 xHCI Host Controller    iSerial                 1 xhci-hcd.0.auto    bNumConfigurations      1    Configuration Descriptor:      bLength                 9      bDescriptorType         2      wTotalLength       0x001f      bNumInterfaces          1      bConfigurationValue     1      iConfiguration          0      bmAttributes         0xe0        Self Powered        Remote Wakeup      MaxPower                0mA      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        0        bAlternateSetting       0        bNumEndpoints           1        bInterfaceClass         9 Hub        bInterfaceSubClass      0        bInterfaceProtocol      0 Full speed (or root) hub        iInterface              0        Endpoint Descriptor:          bLength                 7          bDescriptorType         5          bEndpointAddress     0x81  EP 1 IN          bmAttributes            3            Transfer Type            Interrupt            Synch Type               None            Usage Type               Data          wMaxPacketSize     0x0004  1x 4 bytes          bInterval              12          bMaxBurst               0  Hub Descriptor:    bLength              12    bDescriptorType      42    nNbrPorts             1    wHubCharacteristic 0x000a      No power switching (usb 1.0)      Per-port overcurrent protection    bPwrOn2PwrGood       10 * 2 milli seconds    bHubContrCurrent      0 milli Ampere    bHubDecLat          0.0 micro seconds    wHubDelay             0 nano seconds    DeviceRemovable    0x00   Hub Port Status:     Port 1: 0000.02a0 5Gbps power Rx.Detect  Binary Object Store Descriptor:    bLength                 5    bDescriptorType        15    wTotalLength       0x000f    bNumDeviceCaps          1    SuperSpeed USB Device Capability:      bLength                10      bDescriptorType        16      bDevCapabilityType      3      bmAttributes         0x02        Latency Tolerance Messages (LTM) Supported      wSpeedsSupported   0x0008        Device can operate at SuperSpeed (5Gbps)      bFunctionalitySupport   3        Lowest fully-functional device speed is SuperSpeed (5Gbps)      bU1DevExitLat           0 micro seconds      bU2DevExitLat           0 micro seconds  can't get debug descriptor: Resource temporarily unavailable  Device Status:     0x0001    Self Powered    Bus 001 Device 003: ID 1a86:7523 QinHeng Electronics CH340 serial converter  Device Descriptor:    bLength                18    bDescriptorType         1    bcdUSB               1.10    bDeviceClass          255 Vendor Specific Class    bDeviceSubClass         0    bDeviceProtocol         0    bMaxPacketSize0         8    idVendor           0x1a86 QinHeng Electronics    idProduct          0x7523 CH340 serial converter    bcdDevice            2.64    iManufacturer           0    iProduct                2 USB Serial    iSerial                 0    bNumConfigurations      1    Configuration Descriptor:      bLength                 9      bDescriptorType         2      wTotalLength       0x0027      bNumInterfaces          1      bConfigurationValue     1      iConfiguration          0      bmAttributes         0x80        (Bus Powered)      MaxPower               98mA      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        0        bAlternateSetting       0        bNumEndpoints           3        bInterfaceClass       255 Vendor Specific Class        bInterfaceSubClass      1        bInterfaceProtocol      2        iInterface              0        Endpoint Descriptor:          bLength                 7          bDescriptorType         5          bEndpointAddress     0x82  EP 2 IN          bmAttributes            2            Transfer Type            Bulk            Synch Type               None            Usage Type               Data          wMaxPacketSize     0x0020  1x 32 bytes          bInterval               0        Endpoint Descriptor:          bLength                 7          bDescriptorType         5          bEndpointAddress     0x02  EP 2 OUT          bmAttributes            2            Transfer Type            Bulk            Synch Type               None            Usage Type               Data          wMaxPacketSize     0x0020  1x 32 bytes          bInterval               0        Endpoint Descriptor:          bLength                 7          bDescriptorType         5          bEndpointAddress     0x81  EP 1 IN          bmAttributes            3            Transfer Type            Interrupt            Synch Type               None            Usage Type               Data          wMaxPacketSize     0x0008  1x 8 bytes          bInterval               1  can't get debug descriptor: Resource temporarily unavailable  Device Status:     0x0000    (Bus Powered)    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  Device Descriptor:    bLength                18    bDescriptorType         1    bcdUSB               2.00    bDeviceClass            9 Hub    bDeviceSubClass         0    bDeviceProtocol         1 Single TT    bMaxPacketSize0        64    idVendor           0x1d6b Linux Foundation    idProduct          0x0002 2.0 root hub    bcdDevice            3.18    iManufacturer           3 Linux 3.18.140-Swan-gcb3e40e597b0-dirty xhci-hcd    iProduct                2 xHCI Host Controller    iSerial                 1 xhci-hcd.0.auto    bNumConfigurations      1    Configuration Descriptor:      bLength                 9      bDescriptorType         2      wTotalLength       0x0019      bNumInterfaces          1      bConfigurationValue     1      iConfiguration          0      bmAttributes         0xe0        Self Powered        Remote Wakeup      MaxPower                0mA      Interface Descriptor:        bLength                 9        bDescriptorType         4        bInterfaceNumber        0        bAlternateSetting       0        bNumEndpoints           1        bInterfaceClass         9 Hub        bInterfaceSubClass      0        bInterfaceProtocol      0 Full speed (or root) hub        iInterface              0        Endpoint Descriptor:          bLength                 7          bDescriptorType         5          bEndpointAddress     0x81  EP 1 IN          bmAttributes            3            Transfer Type            Interrupt            Synch Type               None            Usage Type               Data          wMaxPacketSize     0x0004  1x 4 bytes          bInterval              12  Hub Descriptor:    bLength               9    bDescriptorType      41    nNbrPorts             1    wHubCharacteristic 0x000a      No power switching (usb 1.0)      Per-port overcurrent protection      TT think time 8 FS bits    bPwrOn2PwrGood       10 * 2 milli seconds    bHubContrCurrent      0 milli Ampere    DeviceRemovable    0x00    PortPwrCtrlMask    0xff   Hub Port Status:     Port 1: 0000.0103 power enable connect  can't get device qualifier: Resource temporarily unavailable  can't get debug descriptor: Resource temporarily unavailable  Device Status:     0x0001    Self Powered  

How can I communicate with the serial device? Are there any other kernel modules I should compile? Does newer Android handle serial devices in a different way than Linux does? I've seen other people run this firmware on Android in chrooted Linux like here, here, here. So it is possible, I just must be missing something. I'm happy to post other debugging information/logs.

bash count files and directory, summary size and EXCLUDE folders that are fuse|sshfs

Posted: 22 Feb 2022 03:55 AM PST

I need help for a bash script that counts files and folders in a specified directory on a Linux system (Debian), but I want to exclude a specified folder.

I have a main directory named workdir with different script files and folders. Inside workdir, I have a directory named mysshfs. I use fuse/sshfs to mount an external folder in the mysshfs folder.

Now I start some commands to get information about file/directory count and file/directory size, but I want to exclude the directoy mysshfs.

My bash commands that work:

  1. get the full size of workdir | no fuse/sshfs in use

    $ du -hs workdir  
  2. get the full size of workdir, excluding mysshfs | fuse/sshfs in use

    $ du -hs --exclude=mysshf workdir  
  3. count files in workdir | no fuse/sshfs in use

    $ find workdir -type f | wc -l  
  4. count folders in workdir | no fuse/sshfs in use

    $ find workdir -type d | wc -l  
  5. count files in workdir, excluding mysshfs | no fuse/sshfs in use

    $ find workdir -type f -not -path "*mysshfs*" | wc -l  
  6. count folders in workdir, excluding mysshfs | no fuse/sshfs in use

    $ find workdir -type d -not -path "*mysshfs*" | wc -l  

When I use commands 5 & 6 and the remote directory is mounted under the mysshfs directory, the commands hang.

The commands eventually work and show the correct output, but it looks like the commands are still looking inside the excluded directory even though they shouldn't be, so it takes a long time to display the result.

Where is my error or did I forget something in my commands 5 & 6? Or can I use other commands for my results?

I need to count files and directories using 2 separate commands and exclude a specified folder that is mounted over fuse/sshfs to get a fast result.

Capture PID of a background process while its output is redirected to a file [duplicate]

Posted: 22 Feb 2022 03:21 AM PST

Let's say I have the following command:

some_command &> output.log &  

How can I capture the PID of some_command so I can then kill it later? Something like this:

some_command &> output.log &  someCommandPID=?  sleep 10  kill -9 $someCommandPID  

Reading /dev/ttyS4 from a BeagleBone running Debian 10 not what is written

Posted: 22 Feb 2022 03:20 AM PST

I am pulling my hears trying to make ttyS4 up and running on a Beaglebone black.

I have set up UART4 in my /boot/uEnv.txt (see it at the bottom of my question).

On the Beaglebone I have the comms cape and the RS-485 A/B are wired to the battery BMS device. The comms are 9600 bauds 8N1.

To sniff the content I do:

(stty -F /dev/ttyS4 9600 cs8 -cstopb -parenb; cat -v /dev/ttyS4) | od -t x1

And what I notice in the logs is that it is no the expected stream of bytes: I should have something starting with A5 01 90 08 XXXX for 13 bytes.

What might have made the bytes different? What should I do to troubleshoot this?

0000000 4d 2d 27 5e 41 21 5e 48 5e 42 58 5e 40 5e 40 5e  0000020 40 5e 40 5e 40 5e 40 4d 2d 51 5e 40 4d 2d 27 5e  0000040 41 21 5e 48 5e 42 58 5e 40 5e 40 5e 40 5e 40 5e  0000060 40 5e 40 4d 2d 51 5e 40 5e 40 4d 2d 27 5e 41 21  0000100 5e 48 5e 42 58 5e 40 5e 40 5e 40 5e 40 5e 40 5e  0000120 40 4d 2d 51 5e 40 4d 2d 27 5e 41 21 5e 48 5e 42  0000140 58 5e 40 5e 40 5e 40 5e 40 5e 40 5e 40 4d 2d 51  

My uEnv.txt:

cat /boot/uEnv.txt  #Docs: http://elinux.org/Beagleboard:U-boot_partitioning_layout_2.0    uname_r=4.14.108-ti-r131  #uuid=  #dtb=    ###U-Boot Overlays###  ###Documentation: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian#U-Boot_Overlays  ###Master Enable  enable_uboot_overlays=1  ###  ###Overide capes with eeprom  #uboot_overlay_addr0=/lib/firmware/BB-UART1-00A0.dtbo  #uboot_overlay_addr1=/lib/firmware/BB-UART2-00A0.dtbo  #uboot_overlay_addr2=/lib/firmware/BB-UART4-00A0.dtbo  #uboot_overlay_addr3=/lib/firmware/BB-UART5-00A0.dtbo  ###  ###Custom Cape  #dtb_overlay=/lib/firmware/<file8>.dtbo  ###  ###Disable auto loading of virtual capes (emmc/video/wireless/adc)  #disable_uboot_overlay_emmc=1  disable_uboot_overlay_video=1  disable_uboot_overlay_audio=1  disable_uboot_overlay_wireless=1  disable_uboot_overlay_adc=1  ###  ###PRUSS OPTIONS  ###pru_rproc (4.14.x-ti kernel)  uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo  ###pru_rproc (4.19.x-ti kernel)  #uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo  ###pru_uio (4.14.x-ti, 4.19.x-ti & mainline/bone kernel)  #uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo  ###  ###Cape Universal Enable  enable_uboot_cape_universal=1  ###  ###Debug: disable uboot autoload of Cape  #disable_uboot_overlay_addr0=1  #disable_uboot_overlay_addr1=1  #disable_uboot_overlay_addr2=1  #disable_uboot_overlay_addr3=1  ###  ###U-Boot fdt tweaks... (60000 = 384KB)  #uboot_fdt_buffer=0x60000  ###U-Boot Overlays###    cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet    #In the event of edid real failures, uncomment this next line:  #cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 quiet video=HDMI-A-1:1024x768@60e    ##enable Generic eMMC Flasher:  ##make sure, these tools are installed: dosfstools rsync  #cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh  

Is it possible to copy a files name into another file which is located at a different directory in 2 arguments?

Posted: 22 Feb 2022 04:44 AM PST

In advance: If there is a similar question somewhere, I'm sorry for repeating it and please can you share a link of it.

So I know with ls I can print a files name in a different file but how do we do the same thing if the destination file is in a different directory and only using 2 arguments?

I have directories at ~/ with names A and B. And my 2 filenames at A are named 1,2 format is irrelevant but for sake of simplicity lets say they are .txt and B has 1 file with the name Total.txt.

Edit: Can I copy the name of the files from A directory to a file(meaning when I open the file in B it will shot the names of the copied filenames from A) in B directory with as fewer arguments as possible in one line?

Estrange \n at the end of the file name when checking my md5 files

Posted: 22 Feb 2022 04:10 AM PST

For a reason a do not understand when checking my md5 files, it fails because the name of the file have a \n at the end but the file name doesn't have this character. These are old files I have on my computer. If I do the same operation with md5 generated more recently, I don't get that error. Example:

ls  R1_001.fastq.gz  R1_001.fastq.gz.md5    md5sum -c R1_001.fastq.gz.md5  md5sum: R1_001.fastq.gz\n: No such file or directory  R1_001.fastq.gz\n: FAILED open or read  md5sum: WARNING: 1 listed file could not be read    

Can you see the \n. However, the same operation with another more recently created md5 file doesn't return this error and checking is ok.

I have check if there is a new line character at the end of this file with find . -name \*$'\n'\* and there is NOT any file with a \n in its file name. So, what is going on?

I have also tried ls -Q and ls -b but I can't see the \n in any file.

I have also change the file name twice, first R1_001.fastq.gz to R1_001.fastq.ggz and then R1_001.fastq.ggz to R1_001.fastq.gz. And the same error with the same error I got

cat -A R1_001.fastq.gz.md5  5bfa62079341df049fb4c5eb9d0c6fcc R1_001.fastq.gz\n  

How can I shrink a BtrFS filesystem being a LV in OpenSUSE 15.3?

Posted: 22 Feb 2022 03:03 AM PST

I have a sys Volume Group (VG) like this:

 lvs    LV   VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert    boot sys -wi-ao---- 664.00m                                                        root sys -wi-ao----  70.01g                                                      

Unfortunately the /boot Logical Volume (LV) is too small when using snapshots, so I wanted to shrink root a bit, and then extend boot.

The mount related look like this:

/dev/mapper/sys-root on / type btrfs (rw,relatime,ssd,space_cache,subvolid=264,subvol=/@/.snapshots/1/snapshot)  /dev/mapper/sys-root on /.snapshots type btrfs (rw,relatime,ssd,space_cache,subvolid=263,subvol=/@/.snapshots)  /dev/mapper/sys-boot on /boot type btrfs (rw,relatime,ssd,space_cache,subvolid=5,subvol=/)  /dev/mapper/sys-root on /srv type btrfs (rw,relatime,ssd,space_cache,subvolid=260,subvol=/@/srv)  /dev/mapper/sys-root on /usr/local type btrfs (rw,relatime,ssd,space_cache,subvolid=258,subvol=/@/usr/local)  /dev/mapper/sys-root on /var type btrfs (rw,relatime,ssd,space_cache,subvolid=257,subvol=/@/var)  /dev/mapper/sys-root on /opt type btrfs (rw,relatime,ssd,space_cache,subvolid=262,subvol=/@/opt)  /dev/mapper/sys-root on /root type btrfs (rw,relatime,ssd,space_cache,subvolid=261,subvol=/@/root)  /dev/mapper/sys-root on /tmp type btrfs (rw,relatime,ssd,space_cache,subvolid=259,subvol=/@/tmp)  

Now when I use yast2 disk and select either the LV or the BtrFS volume, no "Resize" is being offered.

Can I use Yast to resize the LVs and filesystems as intended?

`atq` lists a job even if it was executed yesterday

Posted: 22 Feb 2022 03:36 AM PST

I created an at job that executes a script with the -f flag. The script restarts tomcat. The job was scheduled to be executed at Feb 21 18:00:00 2022 which was yesterday. I just confirmed tomcat was restarted at that time. However when I execute atq today, I get:

3   Mon Feb 21 18:00:00 2022 = alexander  

My understanding is that atq only lists pending jobs. Why is my job from yesterday being listed?

Update:

I just reviewed my script and it contains tail which never exits at the end. That is probably causing the job to take forever to quit. I found the output at /var/spool/at/spool/a0000301a27604. But the file was last modified at 2022-02-21 23:40:33.534191768. I just found out that's where the last output to tail arrived at. How do I get the process number of the still running task?

What is "=" sign in bash?

Posted: 22 Feb 2022 02:53 AM PST

I wanted to know what this "=" sign means in Bash. I can't find it in references. All I know is it is used to assign value to variables. Am I missing something can anyone point me to the docs?

Code

Combine multiple lsof options

Posted: 22 Feb 2022 02:45 AM PST

Is there any way to combine the -i and -p options of lsof in a logical conjunction? It seems to me that the default behavior is to show files which satisfy one or the other condition, which I think is a bit odd.

pom.xml, **/pom.xml, **/**/pom.xml, then **/**/**/pom.xml... What shortcut to target a file we know its name, whatever its depth in directories?

Posted: 22 Feb 2022 02:44 AM PST

To apply some changes to all my pom.xml files, I'm running these commands:

git checkout --theirs **/**/**/**/pom.xml  git checkout --theirs **/**/**/pom.xml  git checkout --theirs **/**/pom.xml  git checkout --theirs **/pom.xml  git checkout --theirs pom.xml  

But I can't find the replacement that would target all the pom.xml files, at any level of directories depth they would be.

How can do what I did in a single command?

Bitbake Congatec Yocto - hangs in step: parsing recipes. git ls-remote http://<user>:<key>@host/project hangs

Posted: 22 Feb 2022 04:37 AM PST

Everything worked before. But at one point everything got stuck at the step of parsing recipes. How can i fix it?

./clear_mntconti_cpp.sh   source /opt/yocto/.yocto_build.rocko/poky/oe-init-build-env /opt/yocto/.yocto_build.rocko/build && \  bitbake -r /opt/yocto/.yocto_build.rocko/build/conf/bblayers_before.conf -c cleansstate -f  mntconti-tracker && \  bitbake -r /opt/yocto/.yocto_build.rocko/build/conf/bblayers_before.conf -c clean -f mntconti-tracker && \  bitbake -r /opt/yocto/.yocto_build.rocko/build/conf/bblayers_before.conf -c cleanall -f  mntconti-tracker     ### Shell environment set up for builds. ###    You can now run 'bitbake <target>'    Common targets are:      core-image-minimal      core-image-sato      meta-toolchain      meta-ide-support    You can also run generated qemu images with a command like 'runqemu qemux86'  Parsing recipes:   0% |#                                                                                                                                                                     | ETA:  0:01:12  

Update: I find that this command

git ls-remote http://<user>:<key>@host/project   

are hangs, and i have no idea why...

Alpine Linux becomes unreachable after a certain period of inactivity

Posted: 22 Feb 2022 04:38 AM PST

I have installed Alpine Linux as OS for a mini server. I have correctly configured the server to be reached via ssh (openSSL) and my programs run on docker containers. I use a wired connection.

The problem is that after a certain period of inactivity (no requests to the server), it seems as if the server disconnects from the internet. I can no longer connect it via ssh, and it also disappears from the list of connected devices.

I have been looking for methods to disable sleep/hibernation of the OS and network card but found nothing.

When I move the touchpad it becomes reachable again.

I hope you can help me and thank you in advance.

PS I use Alpine Linux because the hardware is old and I need to use as little ram as possible.

UPDATE - SYSLOG:

tail -f /var/log/messages      Feb 20 01:00:00 cron.info crond[2158]: <user> pid 6301 cmd run-parts /etc/periodic/hourly    Feb 20 01:15:00 cron.info crond[2158]: <user> pid 6303 cmd run-parts /etc/periodic/15min    Feb 20 01:30:00 cron.info crond[2158]: <user> pid 6304 cmd run-parts /etc/periodic/15min    Feb 20 01:45:00 cron.info crond[2158]: <user> pid 6306 cmd run-parts /etc/periodic/15min    Feb 20 02:00:00 cron.info crond[2158]: <user> pid 6308 cmd run-parts /etc/periodic/15min    Feb 20 02:00:00 cron.info crond[2158]: <user> pid 6309 cmd run-parts /etc/periodic/hourly    Feb 20 02:00:00 cron.info crond[2158]: <user> pid 6310 cmd run-parts /etc/periodic/daily    Feb 20 02:15:00 cron.info crond[2158]: <user> pid 6312 cmd run-parts /etc/periodic/15min    Feb 20 02:30:00 cron.info crond[2158]: <user> pid 6314 cmd run-parts /etc/periodic/15min    Feb 20 02:39:39 auth.info sshd[6316]: Accepted publickey for <user> from <ip> port <port> ssh2: RSA   

virt-manager Windows guest access Linux host folder

Posted: 22 Feb 2022 02:46 AM PST

I have the following configuration:

  • Linux host: MX Linux 21 (based on Debian 11)
  • Windows guest: Windows 8.1
  • virt-manager: 3.2.0

I've created a shared folder in Linux labeled L_data.

Windows has built in Samba, and according to this post, I just need to find out which IP address the Linux host has (by using ifconfig) and map a drive to this ip. When I issued the ifconfig command, it showed 4 interfaces: eth0, eth1, lo, virbr0.

From the Windows guest, I could ping the IP of the host, but when I tried to map the drive, it won't see the host. What I'm missing?

Questions:

  1. which of those 4 interfaces am I supposed to use? I used the IP of eth0 (only eth1 has no IP)
  2. my IP is dynamic, if it changes, how to make sure the Windows guest can still see the host folder?

PS: I'm not that knowledgeable about Linux.

How to replicate bios_grub partition?

Posted: 22 Feb 2022 02:50 AM PST

I have a 60GB AWS volume which I want to shrink to 30GB. The plan is to manually recreate the same partition table (with the only difference being the main partition size), and then use partclone to clone the filesystem(s).

At first glance, the source disk looks pretty simple:

lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL /dev/xvdf  NAME    SIZE TYPE FSTYPE LABEL  xvdf     60G disk          └─xvdf1  60G part xfs    /  

However, parted shows this "bios_grub" partition which, although sits first, is numbered 128:

Model: Xen Virtual Block Device (xvd)  Disk /dev/xvdf: 125829120s  Sector size (logical/physical): 512B/512B  Partition Table: gpt  Disk Flags:     Number  Start  End         Size        File system  Name                 Flags  128     2048s  4095s       2048s                    BIOS Boot Partition  bios_grub   1      4096s  125829086s  125824991s  xfs          Linux    
  1. Why is lsblk not showing the the "bios_grub" partition?
  2. Why is it numbered 128 despite sitting first?
  3. How to recreate/clone it on a new disk?

Find "latest" path, filename, date, and time at every level of a folder subtree with Bash

Posted: 22 Feb 2022 03:45 AM PST

Using Bash, I want to find for any specified directory and its subtree the filename, creation_date and creation_time for the file last created in that directory. For example, the output would be:

/home/dir    filename0  creation_date0 creation_time0  /home/dir/subdir1    filename1  creation_date1  creation_time1  /home/dir/subdir2    filename2  creation_date2  creation_time2  

Where should a shell script for a custom systemd service be installed?

Posted: 22 Feb 2022 03:54 AM PST

I have recently created my first custom systemd service to run a script early in my machine's boot sequence. The custom .service file is being copied to /etc/systemd/system, which I understand to be the correct location for custom services which are not deployed via packages or part of the operating system distribution.

It's a oneshot type service, which invokes a shell script to dynamically set the hostname, prior to the networking stack and dhcpcd being started. Here's the service definition:

[Unit]  Description=Set hostname on startup, based on hardware serial number  Wants=local-fs.target  After=local-fs.target  Before=systemd-hostnamed.service    [Service]  Type=oneshot  ExecStart=/SOMEPATH/hostname-from-serialnumber.sh    [Install]  WantedBy=systemd-hostnamed.service  

I'm not sure what the best location for the shell script is, so I've put a placeholder SOMEPATH in the code block above. What is the correct location for this shell script, and why?

Ctrl + . shortcut in Fedora 35 (how to find app-defined shortcuts)

Posted: 22 Feb 2022 04:37 AM PST

I am running Fedora 35. When I press Ctrl + . in any text field in pretty much any application, it types a lowercase letter "e" that is underlined, which I can typed text afterwards, and when I press Enter, the underline and the "e" disappear from the text field, leaving the subsequent text behind. I combed through the keyboard shortcuts and could not find any reference to this Ctrl + . behavior, and thought it was something that an application was doing. What is this key binding? How can I search all application-defined key bindings to see where this is coming from?

I have copied a whole partitioned disk into a partition of another disk. How can I access the data?

Posted: 22 Feb 2022 04:35 AM PST

A hard drive with multiple partitions gets dd'ed onto a partition of a second hard drive (partition big enough to fully contain the first hard drive). Is it possible to access the data on the second drive - and if, how?

Edit: For clarification - I guess a better term for the problem would be "nested partition(s)": enter image description here Which also led me to this answer: Is there a way to allow nested partition tables? - my use case would be similar to the last paragraph, and probably a solution would be to use device mapper. But it seems there is no "easier" way to access the data.

Ubuntu 20.04 will not boot on Dell Inspiron 3891

Posted: 22 Feb 2022 04:38 AM PST

I have failed at installing Ubuntu. I don't know where I went wrong. I'm not very experienced in Linux and I'm sure I've made a simple mistake. Here's the situation.

When I power up the computer, I see the Dell logo and then nothing. The screen is clearly backlit, but it is black. Nothing further happens.

When I power up the computer and hold down Shift, I get the same result.

When I power up the computer and tap F12, I can get to the BIOS (version 1.0.14). I can choose my boot order. I can point towards the drive with Ubuntu on it. I even have a selection called Ubuntu. It doesn't matter which of these I choose, the result is the same.

There are no other operating systems installed on this computer. The OS I did attempt to install was Ubuntu 20.04 LTS. It was working a few days ago, but then I tried to update the firmware to 1.0.14. It said it was successful, but then I ran into this problem.

If I put in the boot flash drive and choose it as a boot option, I will get apparent success. The installation GUI shows up. It says it works. I get the message that Installation is complete and that I should reboot. When it tells me to take the boot drive out, I do so.

The machine is a Dell Inspiron 3891 Intel Core i5-11400. Brand new, straight out of the box. I have made no changes to the insides of this machine.

I tried installing Ubuntu to the 256 GB SSD. I tried installing to the 1TB HDD. Same result.

About two days into this troubleshooting process, I lost my temper and starting reformatting everything. In retrospect, maybe this was not the best move.

I tried booting off the boot flash drive and running boot-repair.

If I power the machine while tapping Esc, I do get GNU GRUB version 2.04. However, nothing seems to work from here. I found instructions that said I should type C at this point, but I got error: can't find command 'C'.

I've run the Dell SupportAssist On-Board Diagnostics. It says all tests passed successfully.

Yesterday I found an Ubuntu website that displays all the "Ubuntu certified hardware". It lists the Dell Inspiron Core i7 and the Core i9, but it does not list the Core i5-11400. I would give up at this point, but I did see it work at least once. My initial attempt worked great. I only ran into trouble when I tried to update the firmware. I KNOW this system can run this OS.

I tried downgrading the BIOS to 1.0.13. This did not help. I tried downgrading to BIOS 1.0.12 and I got an error that this downgrade was not supported. I verified in the BIOS setup that BIOS downgrade is allowed, but it won't allow this. I don't know what BIOS was active when I first bought the machine, I didn't think to look.

I originally burned the flash drive with ubuntu-20.04.2.0-desktop-amd64.iso with balenaEtcher using the default settings. I then tried the same ISO but using Rufus 3.13.1730, and burning the image as a dd. Its interesting that I get a little farther witih this. I can install the OS and then it will boot to the text screen that lets me choose Ubuntu, but then it dies immediately afterwards. It dies in the same fashion - backlight is on and slightly flickering, otherwise featureless black screen.

Last night I noticed that Ubuntu now has 20.04.3. I tried downloading that ISO and burning it to my flash drive as a dd using my Rufus software. This flash drive won't even allow me to install. I can get into the BIOS and choose the flash drive as the boot medium, but when it tries to boot from the flash drive I get the same freeze. Dell logo nice and clear, then freeze on a backlit black screen. I did verify the checksum for this iso.

There's no urgency to this question. I am taking a Linux class, but this problem has nothing to do with that class. I'm doing this for the learning experience. Well, that's not exactly true. I started this project for the learning experience. Now I'm refusing to give up out of sheer stubbornness.

I'm lost. I don't know where to go from here. Can anyone offer advice please?

Updated to add: I tried removing the CMOS battery to set the nvram back to factory defaults. I don't think it worked. When I powered the machine back on. I did get an error that the time was not set. However, the BIOS still had SATA set to AHCI and SecureBoot was still off. I am positive that when I first got this machine, SATA was set to RAID and SecureBoot was on.

Repair broken symlinks to new location

Posted: 22 Feb 2022 04:47 AM PST

I moved from an old webserver to a new one. Now some symlinks not working, because we changed the folder structur. I want to know if there is a easy way to repair these links? I found the links with this command:

find -L . -type l -ls  

The links looks like this:

./example/vondercode/releases/example.com/2.0/www/img/uploads -> /home/example/vondercode/uploads  ./example2/www/img/uploads -> /home/example2/vondercode/uploads  

Now the links must look like this:

./example/vondercode/releases/example.com/2.0/www/img/uploads -> /var/www/html/example/vondercode/uploads  ./example2/www/img/uploads -> /var/www/html/example2/vondercode/uploads  

So easy to say, all /home should be replaced by /var/www/html Is this possible?

mpc: access denied when adding mp3 file in a folder under music_directory

Posted: 22 Feb 2022 04:01 AM PST

mpc rescan mpc update give same result.

mpd.conf, mpd service running under user.

music_directory       "~/.cache/music"  playlist_directory    "~/.config/mpd/playlists"  db_file               "~/.config/mpd/database"    input {          plugin "curl"  }    audio_output {         type   "pulse"         name   "Local Music Player Daemon"         server   "127.0.0.1"  }  

I can mpc add file under ~/.cache/music, but I can't mpc add file under a folder of ~/.cache/music, e.g: ~/.cache/music/my music folder, it gives error:

error adding /home/user/.cache/music/my music folder/20. whatever.mp3: Access denied

mpc search title "20. whatever" gives an empty result.

Add something to crontab programmatically (over ssh)

Posted: 22 Feb 2022 04:22 AM PST

I have a deployment script, it must add something to a user crontab (trigger a script that clean logs every XXX days), however this must only be done during the first deployment, or when it needs to be updated.

(I can run xxx.py deploy env or xxx.py update env)

so I have to do this:

Check if my cronJob already exist  Put my cronJob if it does not already exist  or  update my cronjob if one of the parameter of the command is different  

I don't see how to add/check/remove something to the crontab without using crontab -e or editing the crontab file (download it, rewrite it, re-upload it)

PS : this is a user specific cronjob, "webadmin" is going to do it and he should not use sudo to do it.

How to build an ISO of customized linux OS in a way that I can use the ISO to install on other systems?

Posted: 22 Feb 2022 03:00 AM PST

I have installed minimal version of centos6.7 on usb stick, copied/installed some applications/packages and customized accordingly.

Now I want to build an ISO of my customized OS and want to install on other systems using ISO.

Is that possible?

Thanks in Advance.

How to keep a history of backups?

Posted: 22 Feb 2022 03:17 AM PST

My intention is to create a "snapshot" of a certain hard drive on a server every day. How can I automatically make sure that the snapshot of today, three days ago, five days ago, 10 days ago (and so on) are being kept and cyclically replaced? I found a tool: duplicity, but I didn't find any way to achieve this using it. Should I go for a bash shell script? Is there any example I can take inspiration from?

The system is running Debian.

Is troff/groff relevant anymore?

Posted: 22 Feb 2022 03:48 AM PST

I've heard that troff/groff have largely been replaced by TeX. Is this true?

The only thing that I know actually used troff nowadays is manpages. Is this also true? If not, what are some other uses?

btrfs on openSUSE not releasing disk space

Posted: 22 Feb 2022 04:35 AM PST

I have an openSUSE 12.1 install on my main desktop running with btrfs filesystem for root (/boot is ext4). I started having issues today with KDE informing me that disk space is almost all gone and eventually it decided it was gone and crashed my desktop.

I used Alt+F1 to switch to a terminal screen and although I was sure I was no where near the 1TB limit of my hard disk I moved some 150/200GB of music and video files onto an external drive and rebooted. Didn't help, same problem, same crash.

Once more I switched to a terminal screen and used du to confirm that I had indeed only used about half of my total diskspace but df (including the btrfs-progs version) insists I have used 100% of available diskspace and so my desktop crashes each and every time I log in.

Using the btrfs defrag utility doesn't help either. As such I am at a bit of a loss as to where to go next.

No comments:

Post a Comment