Blog
Projects
Docs, Tips & tricks
Freebsd tips
GNU/Linux tips
November 2024 | ||||||
M | T | W | T | F | S | S |
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 |
How to send audio output to line in and mix it with real mic in | Thu, 2 Apr 20 |
Simple guide using Debian Linux to send audio that is coming out from speakers directly to line in / mic in, and additionaly mix this audio with the audio coming from a physical microphone. The ideal setup to be used with some web conference solutions. As root add some tools if not already installed: # apt-get install pulseaudio pavucontrolSetup pulseaudio virtual audio interface as user: $ pactl load-module module-null-sink sink_name=inputs $ pactl load-module module-loopback sink=inputs $ pactl load-module module-loopback sink=inputs(yes, 2 times) Then open pavucontrol: $ pavucontrolIn "Recording" tab, select "Virtual Streams" from the bottom "Show" selection. You find listed the 2 loopback devices. The first loopback has to be associated with the monitor of audio output. The second loopback has to be associated with the microphone input. Then go to "Input Devices" tab, select "Monitors" from the bottom "Show" selection. You will find two monitors: the monitor of output and of null sink. Both has to be un-muted if muted. If necessary, set as fallback device the "Monitor of Null Output", that is the one that is getting both output audio and mic. |
Fix grub rescue after Windows 10 update | Sun, 29 Mar 20 |
The setup is: dual boot with Debian and Windows 10. Booting is managed by Grub. Problem: after Windows 10 update, Grub is not correctly working anymore and you get a screen with: error: unkwnown filesystem. Entering rescue mode... grub rescue>Be calm, nothing is lost. It is Windows that modified the partitions index and grub setting in the bootsector is pointing to a wrong partition for grub data. To restore, from the rescue mode command line you can look at the current settings with: grub rescue> set cmdpath=(hd0) prefix=(hd0,msdos2)/boot/grub root=hd0,msdos2In my example the settings stored point to msdos2 partition. To list the available partitions, use command: grub rescue> ls (hd0) (hd0,msdos1) (hd0,msdos2) (hd0,msdos3) (hd0,msdos4)Then try to manually load grub settings from another partition and boot; for example let's try msdos3 instead of the settings for msdos2: grub rescue> set root=(hd0,msdos3) grub rescue> set prefix=(hd0,msdos3)/boot/grub grub rescue> insmod normal grub rescue> normalIf it works, you will get the normal grub screen, and can start Debian again. If it doesn't work, the command insmod normal will fail telling it cannot find the module. Then start again the two set commands with another partition number until you find the correct one. When you are in your Debian system, you have to correct the grub settings saved in the bootsector. So in a terminal use the following two commands: $ sudo update-grub [...] $ sudo grub-install /dev/sda [...]That's it! |
Samba 3 share with authentication with a Windows Active Directory Service on Debian 6 | Tue, 22 Jan 13 |
Foreword: hosts in question are: IP 192.168.0.250 (DNS: windowsdomain.network.local, NETBIOS: WINDOWSDOMAIN.NETWORK.LOCAL ) IP 192.168.0.251 (DNS: linuxshare.network.local, NETBIOS: LINUXSHARE.NETWORK.LOCAL ) All following commands are done as root on 192.168.0.251 Debian. Starts installing required packages. apt-get install samba krb5-user libpam-krb5 winbindEDIT /etc/hosts 192.168.0.250 windowsdomain.network.local windowsdomainEDIT /etc/krb5.conf [libdefaults] default_realm = NETWORK.LOCAL kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true [realms] NETWORK.LOCAL = { kdc = windowsdomain.network.local admin_server = windowsdomain.network.local default_domain = NETWORK.LOCAL } [domain_realm] .windowsdomain.network.local = NETWORK.LOCAL windowsdomain.network.local = NETWORK.LOCALVerify that you can logon correctly with user Administrator on the Active Directory: # kinit Administrator@NETWORK.LOCAL # klistNote: Clock skew limits are configurable in the Kerberos protocols. The default setting is five minutes. EDIT /etc/samba/smb.conf [global] workgroup = NETWORK realm = NETWORK.LOCAL security = ADS syslog = 0 log file = /var/log/samba/log.%m max log size = 1000 idmap uid = 10000-20000 idmap gid = 10000-20000 winbind enum users = yes winbind enum groups = yes template homedir = /home/%D/%U template shell = /bin/bash client use spnego = yes client ntlmv2 auth = yes encrypt passwords = yes winbind use default domain = yes restrict anonymous = 2 valid users = @"Domain Users" winbind refresh tickets = yes [share] comment = file server path = /share read only = No hosts allow = 192.168.0.0/255.255.255.0 case sensitive = No preserve case = Yes available = yes browseable = yes create mask = 0664 directory mask = 0775Restart daemons: /etc/init.d/winbind stop /etc/init.d/samba restart /etc/init.d/winbind startVerify that you can join the Active Directory, using Administrator and password "adminpass" net ads join -U Administrator%adminpassEDIT /etc/nsswitch.conf passwd: compat winbind group: compat winbind shadow: compat winbind hosts: files dns wins networks: files dns protocols: db files services: db files ethers: db files rpc: db files netgroup: nisRestart daemons: /etc/init.d/winbind stop /etc/init.d/samba restart /etc/init.d/winbind startVerify that since here things works with: net ads info wbinfo -u getent passwd getent groupADD in /etc/pam.d/common-auth auth sufficient pam_winbind.soADD in /etc/pam.d/common-session session required pam_mkhomedir.soYou can check the login of a user of the domain with: # loginFinally some cosmetics, set permissions of the share: chmod 775 /share chgrp "Domain Users" /shareReferences: http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/domain-member.html https://help.ubuntu.com/community/ActiveDirectoryWinbindHowto http://wiki.samba.org/index.php/Samba_&_Active_Directory https://help.ubuntu.com/10.04/serverguide/samba-ad-integration.html |
Mount a single partition from a complete disk image | Fri, 28 Sep 12 |
Suppose you've done an image dump of a complete disk (i.e. /dev/sdb) with a command like this:
root@n2:~# dd if=/dev/sdb of=/tmp/mydump.dd bs=16kNow you want to mount a partition included in the disk image. First know how was made the disk with fdisk: root@n2:~# fdisk -ul /tmp/mydump.dd You must set cylinders. You can do this from the extra functions menu. Disk /tmp/mydump.dd: 0 MB, 0 bytes 64 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /tmp/mydump.dd1 * 63 3330431 1665184+ 6 FAT16OK, you see there's one partition and it starts at cilinder 63. So calculate at which byte of the image disk the partition begins: root@n2:~# echo 63*512 | bc 32256And finally mount the partition from the image dump, skipping the bytes to ignore: root@n2:~# mount -o ro,loop,offset=32256 -t vfat /tmp/mydump.dd /mntSimple. |
Debian Lenny on NSLU2 | Tue, 11 Jan 11 |
Sone issue with this guide, please do not follow it!
Required material:
Credits for this guide goes to cedric of mou.ch. There is also a famous automatic procedure reported here, but for me it doesn't works as after the installation it reboots and always restarts the debian-installer; also I prefer knowing what I am doing. Firstly install the utility upslug2 on a GNU/Linux computer to remotely set up the NSLU2: $ sudo apt-get install upslug2Download a flash image, it's a minimal Debian that will be used as a starting place for the final installation. You can take this one from the guide mentioned above. Start the NSLU2 in the flash mode. To do so, power down the NSLU2 and remove USB drivers. Then, you have to keep the reset button while powering on the NSLU2; after something like 10 seconds, the Status LED change color from green to red, and you have to release the reset button. The status LED starts blinking. (note: on my NSLU2, the LED was not clearly visible, so I powered on the board whitout the casing). Connect together through the switch the NSLU2 and the GNU/Linux computer. Now launch as root on the GNU/Linux computer: $ sudo upslug2You should see the MAC address of the NSLU2 to flash. If not, repeat the reset procedure. Load the minimal Debian image (caution to not detach power and network cables): $ sudo upslug2 -i debianslug-3.10-beta.binLED blinks while flashing. When done, you should see an output that ends with "Rebooting... done"; the NSLU2 reboots and the minimal Debian boots. It is ready when you hear a "beep" tone and the LED is solid green. The gain access to the system use SSH. The IP address is the one you set up on the Linksys firmware, or the default 192.168.1.77. The user and password also are the one you previously set, or are the default "root" and "opeNSLUg". $ ssh root@192.168.1.77On the NSLU2, set up with turnup new parameters or confirm the old ones. I set a new static IP address 192.168.0.123. # turnup initAfter restart with those new parameters the NSLU2: # rebootWhen the device is ready (LED stops blinkin), login again to the NSLU2: $ ssh root@192.168.0.123Plug in your USB drive in the port you want where you will install Debian. Begin to set up the drive, choosing at least of 256MB of swap for your system. Set the first partition as bootable. Take care on mounted partition as the installer has auto-mount feature enabled. # fdisk /dev/sdaIt appears something like: Disk /dev/sda: 2048 MB Device Boot Start End Blocks Id System /dev/sda1 * 1 ?? ?? 83 Linux /dev/sda2 ?? 250 ?? 82 Linux swapThen: # mkfs.ext3 /dev/sda1 # mkswap /dev/sda2Set the NSLU2 telling him with turnup that you want to boot your USB partition: # umount /dev/sda1 # turnup disk -i /dev/sda1 -t ext3Set up the installation and start it (it'll takes some times and download files from internet): # mount /dev/sda1 /mnt/ # swapon /dev/sda2 # mkdir /mnt/work # cd /mnt/work # wget http://ftp.fr.debian.org/debian/pool/main/d/debootstrap/debootstrap-udeb_1.0.26_all.udeb # ar -x debootstrap-udeb_1.0.26_all.udeb # tar zxvf data.tar.gz # export DEBOOTSTRAP_DIR=`pwd`/usr/share/debootstrap # ./usr/sbin/debootstrap --arch arm lenny /mnt/ http://ftp.fr.debian.org/debianMount proc, copy some files and configure some vital information: # mount -t proc proc /mnt/proc # cp -a /lib/modules/* /mnt/lib/modules # cp /etc/resolv.conf /mnt/etc/resolv.conf # cp /etc/hosts /mnt/etc/hosts # cp /etc/hostname /mnt/etc/hostname # cp /etc/network/interfaces /mnt/etc/network/interfaces # echo "ixp400_eth dev_max_count=1" >> /mnt/etc/modulesSet up the disk information: # vi /mnt/etc/fstab proc /proc proc defaults 0 0 /dev/sda1 / ext3 defaults 1 1 /dev/sda2 swap swap defaults 0 0Set up a headless system # vi /mnt/etc/inittabcommenting the following lines: #1:2345:respawn:/sbin/getty 38400 tty1 #2:23:respawn:/sbin/getty 38400 tty2 #3:23:respawn:/sbin/getty 38400 tty3 #4:23:respawn:/sbin/getty 38400 tty4 #5:23:respawn:/sbin/getty 38400 tty5 #6:23:respawn:/sbin/getty 38400 tty6and adding at the end the line: S0:2345:respawn:/sbin/getty 115200 ttyS0Chroot to target system and continue the setup: # chroot /mnt# passwd root Update packages informations and set the time: # apt-get update # apt-get -y install ntpdate # ntpdate ntp.ubuntu.com # tzconfigSet automatically the time: # echo "ntpdate -s ntp.ubuntu.com" > /etc/cron.daily/ntpdate # chmod 755 /etc/cron.daily/ntpdateInstall some fundamentals: # apt-get -y install nslu2-utils tune2fs openssh-serverDisable the check of the filesystem at boot: # tune2fs -c 0 -i 0 /dev/sda1Verify that in the SSH configuration you can login as root: # vi /etc/ssh/sshd_config Look at the line: PermitRootLogin yesExit and reboot: # exit # rebootIf all is done right it should restart on the USB drive and available with SSH when the LED stops blinking: @ ssh root@192.168.0.123Continue installing with apt-get the services you need as a normal Debian Lenny. Enjoy! |
startx at boot without login manager | Wed, 29 Jul 09 |
I wanted a computer with Debian without keyboard to automatically load a graphical interface. The solution I was looking for had to be the lightest possible, without frills nor using a login manager like GDM and SLIM.
You cannot start Xorg (or XFree86) from a script automatically loaded at boot; that's because you need a complete shell ambient to execute startx or xinit. A simple solution could be to start a shell over a tty terminal without asking for the login, an then start in the profile file of the shell the graphical command. Be careful of this configuration, because it starts automatically a (possible buggy) shell at boot In Debian, in the file /etc/inittab comment out the line 1:2345:respawn:/sbin/getty 38400 tty1with the following line, replacing USER as necessary: 1:2345:respawn:/bin/login -f USER tty < /dev/tty1 > /dev/tty1 2>&1Now at boot the computer automatically logon the user USER. Usually in Debian you are using bash. So add the command to start Xorg, startx near the end of the file /home/USER/.bash_profileA final note: to execute a graphical program in your automatically started Xorg, add the line exec COMMAND in the file /home/USER/.xinitrc. |
Ubuntu + Thunderbird + Lightning | Sat, 10 Jan 09 |
Siccome siamo nel 2009, era ora aggiornassi la mia postazione Ubuntu 7.10 alla 8.10 (e pensare che FreeBSD l'aggiorno almeno una volta al mese). Questa volta e` andata discretamente bene. L'unico problema riscontrato e` stato con Thunderbird caricando l'estensione per il calendario Lightning, ma anche Sunbird. In effetti dopo l'update, il mio Thunderbird 2.0.0.18 con Thunderbird 0.9 non caricava piu` la schermata dei calendari, ne` era possibile aggiungere nuovi eventi o caricare calendari CalDAV remoti. La soluzione sta nell'installare una libreria mancante poiche` erroneamente considerata obsoleta: libstdc++5Per l'installazione e` possibile utilizzare synaptic, oppure il comando # sudo apt-get install libstdc++5 |
Nei meandri dei NAS: recupero estremo di RAID5 | Mon, 6 Oct 08 |
Premessa: in azienda teniamo i dati cartografici su uno dei tanti NAS in commercio, che rendono accessibili da SMB/CIFS, NFS, FTP il filesystem, su cui gira chissa` quale GNU/Linux nascosto all'utente e configurabile da una scarna interfaccia web.
Sopra avevamo 3 dischi da 500GB SATA-2 (la marca e modello sono volutamente omessi...) in RAID5, per un totale di 930GB spazio disponibile, in teoria sicuri. Si` perche` sempre in teoria, se un disco si rompe, lo si sostituisce con un altro e siamo salvi. A neanche un anno dall'acquisto dei dischi, il numero 2 si rompe (la definizione migliore e` "fa` sklang-sklang"). Poco male, ne ordino uno nuovo, tempo 3 giorni arriva. Se non fosse che il giorno dopo il numero 3 viene escluso dal RAID, senza un motivo apparente, dall'interfaccia web non c'e` alcuna spiegazione. Tanto per capire cosa c'e` che non va`, collego il numero 3 su un PC con sopra System Rescue CD, e scopro subito dal boot che il disco ha circa 120 settori danneggiati. Bene. Aspetto il disco nuovo, che non tarda ad arrivare. Provo a ricostruire il RAID sul NAS, niente da fare, sempre con zero spiegazioni sul perche`. Provo a sostituire l'elettronica del disco che "fa` sklang" con quella di un altro, il risultato non cambia. A questo punto mi ritrovo con un RAID5 di 3 unita` di cui una e` persa, e l'altra ha settori danneggiati. Sul PC di prima, che ormai era li` aperto sul tavolo da due giorni, collego il disco numero 1 buono, il disco numero 3 con settori danneggiati ed il disco nuovo. Verifico che il RAID e` stato fatto dal NAS con mdadm. Provo a ricostruire il RAID a mano ignorando i vari avvisi. Peccato che mdadm ternima la ricostruzione quando incontra il primo settore danneggiato, segnalandomi giosamente che il RAID e` perso per sempre poiche` incontra errori di I/O. Maledizione pero` anche se qualche file e` corrotto (sulla fine sono solo 120 settori su 1048576000!), voglio recuperare gran parte dei dati!! Allora mi viene in mente la cosa piu` pazza di questa settimana: fare una copia con errori del disco 3 con settori danneggiati su un altro disco nuovo, e ricostruire il raid con questo, il disco 1 salvo e il disco nuovo di prima (con un totale di 5 dischi uguali di cui 2 rotti). Ecco la procedura: A) Collego al PC il disco 3 con settori danneggiati e un disco nuovo, e avvio system rescue cd B) Faccio una copia con ddrescue scrivendo al posto dei settori danneggiati di origine degli zeri sul disco destinazione: # dd_rescue -A /dev/sda /dev/sdb(nota: il processo per i miei 500GB con i settori danneggiati ci ha messo circa 6 ore) Ottengo un disco immagine del 3 con errori C) Spengo il sistema. Collego il disco 1 che si era salvato, il disco immagine 3 con errori, e l'altro nuovo disco vuoto. Avvio system rescue cd. D) Ricostruisco il RAID5 ora che non si puo` piu` lamentare degli errori di I/O. Esamino i dischi con fdisk e scopro che il RAID e` sulla seconda partizione dei dischi: # echo p | fdisk /dev/sdainfatti leggo il tipo "linux raid autodetect" sulla partizione 2. Recupero la stringa ARRAY che mi serve nel file di configurazione: # mdadm -v --examine --scan >> /etc/mdadm.confcontrollo il file di configurazione /etc/mdadm.conf e verifico che sia sensato, aggiungo ai device anche il nuovo disco vuoto /dev/sdc ottenendo una riga del tipo: ARRAY /dev/md0 level=raid5 num-devices=3 UUID=XXXX-.....-XXXX devices=/dev/sda2,/dev/sdb2,/dev/sdclancio la ricostruzione: # mdadm --assemble --run --force --update=resync /dev/md0 /dev/sda2 /dev/sdb2 /dev/sdce infine verifico lo stato di avanzamento del processo: # cat /proc/mdstatE) Quando ha concluso (in /proc/mdstat leggo "[UUU]"), scopro che sopra il RAID non c'e` un filesystem, e quindi ipotizzo ci siano dei volumi logici con LVM. Faccio uno scan del volumi fisici presenti: # pvscantrovo in effetti un volume di nome "vg0" (e` indicato dopo "VG "), e provo ad attivarlo: # vgchange --ay vg0F) Funziona, ora mi trovo in /dev/vg0/ diversi volumi logici. Trovo quello che piu` mi interessa, il piu` grande, analizzando la dimensione con fdisk: # ls /dev/vg0/ # echo p | fdisk /dev/vg0/lv1E` lui, tipo ext3, faccio un check del filesystem: # fsck -t ext3 -y /dev/vg0/lv1Ci mette alcune ore (e` pur sempre un'unita` da quasi 1TB), correggendo molti campi sballati degli inode. G) Monto il filesystem: # mount -t ext3 -r /dev/vg0/lv1 /mnt/customOk, ho recuperato i 300GB di dati su /mnt/custom, magari qualche file e` corrotto, ma e` *moooolto* meglio di niente. I dati sono stati copiati da rete su un nuovo NAS di qualita` forse superiore, con 3 dischi da 1TB in mirroring (RAID1) con spare (cambiando marca chiaramente). Morale della storia: Qualsiasi RAID e` inutile, senza spare. (Any RAID, without spare, is useless) |
Fedora over Ubuntu | Sun, 27 Jan 08 |
Want to install Fedora 7 or 8 in a virtual machine on Ubuntu Gutsy? You have tried VMWare and cannot install it? Fedora freeze in loading and/or cannot find virtual disk? Well, this is my today problem! It seems that those version of Fedora don't like too much the buslogic virtual SCSI controller used by qemu and vmware. So, whenever you are using an IDE virtual disk, it still find the virtual controller. To solve this problem in VMWare, edit the .vmx file of your virtual machine and add scsi0.virtualdev = "lsilogic"to use the lsilogic virtual controller, or if you wish to not use SCSI at all add scsi0:0.present = "FALSE"to disable any virtual SCSI controller. |
All contents, where applicable and except otherwise specified, are present under GPLv2 or GFDL licenses.
E. Richiardone (e AT richiardone DOT eu)
page viewed 8588 times and generated in 0.003054 s