Friday, January 30, 2015

Bash padding with zeroes

example, 5 digit padding (printf formatting)

for i in $(seq -f "%05g" 1 100)
do
  echo $i
done


MadCatz Madcatz FightStick TE in Fedora

[root@fedora-m91p ~]# dmesg |tail
[282938.508349] input: MadCatz Madcatz FightStick TE as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:0738:8838.0004/input/input15
[282938.508593] hid-generic 0003:0738:8838.0004: input,hidraw3: USB HID v1.10 Gamepad [MadCatz Madcatz FightStick TE] on usb-0000:00:1d.0-1.3/input0
[283624.503845] usb 2-1.3: USB disconnect, device number 4
[283650.985736] usb 2-1.3: new full-speed USB device number 5 using ehci-pci
[283651.072699] usb 2-1.3: New USB device found, idVendor=0738, idProduct=8838
[283651.072704] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[283651.072706] usb 2-1.3: Product: Madcatz FightStick TE
[283651.072709] usb 2-1.3: Manufacturer: MadCatz
[283651.075144] input: MadCatz Madcatz FightStick TE as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:0738:8838.0005/input/input16
[283651.075449] hid-generic 0003:0738:8838.0005: input,hidraw3: USB HID v1.10 Gamepad [MadCatz Madcatz FightStick TE] on usb-0000:00:1d.0-1.3/input0

[root@fedora ~]# yum install joystick-support kernel-modules-extra
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * fedora: mirror.metrocast.net
 * rpmfusion-free: mirror.nexcess.net
 * rpmfusion-free-updates: mirror.nexcess.net
 * rpmfusion-nonfree: mirror.nexcess.net
 * rpmfusion-nonfree-updates: mirror.nexcess.net
 * updates: less.cogeco.net
Resolving Dependencies
--> Running transaction check
---> Package joystick-support.noarch 0:1.0.0-13.fc21 will be installed
--> Processing Dependency: kmod(joydev.ko) for package: joystick-support-1.0.0-13.fc21.noarch
--> Processing Dependency: kmod(analog.ko) for package: joystick-support-1.0.0-13.fc21.noarch
--> Running transaction check
---> Package kernel-modules-extra.x86_64 0:3.18.3-201.fc21 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================
 Package                                Arch                     Version                            Repository                 Size
====================================================================================================================================
Installing:
 joystick-support                       noarch                   1.0.0-13.fc21                      fedora                    5.4 k
Installing for dependencies:
 kernel-modules-extra                   x86_64                   3.18.3-201.fc21                    updates                   2.2 M

Transaction Summary
====================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 2.2 M
Installed size: 2.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): joystick-support-1.0.0-13.fc21.noarch.rpm                                                             | 5.4 kB  00:00:00     
(2/2): kernel-modules-extra-3.18.3-201.fc21.x86_64.rpm                                                       | 2.2 MB  00:00:00     
------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                               3.2 MB/s | 2.2 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : kernel-modules-extra-3.18.3-201.fc21.x86_64                                                                      1/2 
  Installing : joystick-support-1.0.0-13.fc21.noarch                                                                            2/2 
  Verifying  : joystick-support-1.0.0-13.fc21.noarch                                                                            1/2 
  Verifying  : kernel-modules-extra-3.18.3-201.fc21.x86_64                                                                      2/2 

Installed:
  joystick-support.noarch 0:1.0.0-13.fc21                                                                                           

Dependency Installed:
  kernel-modules-extra.x86_64 0:3.18.3-201.fc21                                                                                     

Complete!



[root@fedora ~]# ls -l /dev/input/
total 0
drwxr-xr-x  2 root root     160 Jan 30 16:55 by-id
drwxr-xr-x  2 root root     160 Jan 30 16:55 No package kernel-modules-extras available.by-path
crw-rw----  1 root input 13, 64 Jan 27 10:07 event0
crw-rw----  1 root input 13, 65 Jan 27 10:07 event1
crw-rw----  1 root input 13, 74 Jan 27 10:07 event10
crw-rw----  1 root input 13, 75 Jan 27 10:07 event11
crw-rw----+ 1 root input 13, 76 Jan 30 16:55 event12
crw-rw----  1 root input 13, 66 Jan 27 10:07 event2
crw-rw----  1 root input 13, 67 Jan 27 10:07 event3
crw-rw----  1 root input 13, 68 Jan 27 10:07 event4
crw-rw----  1 root input 13, 69 Jan 27 10:07 event5
crw-rw----  1 root input 13, 70 Jan 27 10:07 event6
crw-rw----  1 root input 13, 71 Jan 27 10:07 event7
crw-rw----  1 root input 13, 72 Jan 27 10:07 event8
crw-rw----  1 root input 13, 73 Jan 27 10:07 event9
crw-rw-r--+ 1 root input 13,  0 Jan 30 16:55 js0
crw-rw----  1 root input 13, 63 Jan 27 10:07 mice
crw-rw----  1 root input 13, 32 Jan 27 10:07 mouse0

This installs the kernel module, and you'll then see the /dev/input/js0 for the MadKatz joystick in Fedora

Wednesday, June 29, 2011

GRUB2 resources

GRUB2 Guide from ubuntu forums

Preupgrade using GRUB2

Grub2 Tutorial

How to use Preupgrade - FedoraProject

Upgrade to Fedora 15

After moving /boot to LVM I can run preupgrade.

At the end of preupgrade, it came up with an error because my /boot was in LVM

Traceback (most recent call last):
File "/usr/share/preupgrade/preupgrade-gtk.py", line 259, in on_assistant_apply
self._do_main()
File "/usr/share/preupgrade/preupgrade-gtk.py", line 278, in _do_main
self.main_preupgrade()
File "/usr/share/preupgrade/preupgrade-gtk.py", line 497, in main_preupgrade
extra_args += " ks=%s" % self.pu.generate_kickstart()
File "/usr/lib/python2.7/site-packages/preupgrade/__init__.py", line 601, in generate_kickstart
return dev.bootpath_to_anacondapath(targetfile, UUID=True)
File "/usr/lib/python2.7/site-packages/preupgrade/dev.py", line 91, in bootpath_to_anacondapath
raise PUError, "/boot is on RAID device %s" % bootdev
preupgrade.error.PUError: /boot is on RAID device dm-15

To fix this, I had to add a /etc/grub.d/35_preupgrade file to the grub2 config scripts (and chmod 755 to the file)


#!/bin/sh
exec tail -n +3 $0
#############
# Custom script for F14->F15 preupgrade
#############
menuentry "Fedora 15 Preupgrade" {
insmod lvm
insmod ext2
set root='(vg_rootvg-boot_lv)'
echo Loading Fedora 15 Preupgrade
linux /boot/upgrade/vmlinuz
initrd /boot/upgrade/initrd.img
boot
}

Added that file, ran grub2-mkconfig / grub2-install on my /dev/sdc again. Now grub2-mkconfig adds an entry for the new "Fedora 15 Preupgrade" item in the Grub2 menu.

Reboot and saw the new entry. Selected it and the Fedora 15 preupgrade ran successfully.

New entries were added to the Grub2 menu after the F15 installation. On first boot, it generated a kernel panic "Kernel Panic not syncing vfs" because the boot procedure couldn't find root.

Had to re-run grub2-mkconfig to have it automaticallly add a missing initrd line in the boot procedure

menuentry "GNU/Linux, with Linux 2.6.38.8-32.fc15.i686.PAE" --class gnu-linux --class gnu --class os {
set gfxpayload=keep
insmod lvm
insmod ext2
set root='(vg_rootvg-boot_lv)'
search --no-floppy --fs-uuid --set 856a58e8-4d98-4ef3-a062-7b6982f6d8f9
echo Loading Linux 2.6.38.8-32.fc15.i686.PAE ...
linux /vmlinuz-2.6.38.8-32.fc15.i686.PAE root=UUID=f25ba21c-194e-49cd-a347-fd0540a96c1b ro rdblacklist=nouveau nouveau.modeset=0 quiet rhgb
echo Loading initial ramdisk ...
initrd /initramfs-2.6.38.8-32.fc15.i686.PAE.img
}

Upgrading Grub to Grub2

This started with the Fedora 15 upgrade. Preupgrade needed +120MB in /boot, and I only had a /dev/sdc1 100MB /boot and the rest of the filesystems in LVM. GRUB2 supported /boot in LVM. So I used parts of

GRUB2 Guide from Fedora Forum.org

as a guideline.

1. Installed Grub2. Tested to make sure Grub booted to Grub2 and it was still booting my F14 kernel
2. Used grub2-mkconfig and grub2-install to write the grub2 boot loader to my /dev/sdc so that I can boot directly to GRUB2 in F14. Worked successfully.
3. Created 500MB boot_lv - lvcreate -L 500M -n boot_lv /dev/rootvg
4. Unmount /boot, mount in /mnt/boot. Mount /dev/rootvg/boot_lv to /boot.

cd /boot; find ./ -xdev -print0 | cpio -pa0V /mnt/boot

5. Change fstab to point to new LVM /boot instead of the old UUID static partition /boot. Run grub2-mkconfig / grub2-install again to get updated /boot.
6. Reboot to test.

Friday, June 24, 2011

Rotate video from the command line

Taken from http://www.thelinuxblog.com/rotating-videos-in-linux/ - great info

Command to rotate a video is:

mencoder -ovc lavc -vop rotate=1 -oac copy input.mpg -o output.mpg

The rotate=1 can be replaced with whatever option best suits your needs. Rotating video options are below:

0 Rotate by 90 degrees clockwise and flip (default).
1 Rotate by 90 degrees clockwise.
2 Rotate by 90 degrees counterclockwise.
3 Rotate by 90 degrees counterclockwise and flip.

FFMPEG to truncate video


[root@localhost] ffmpeg -i [inputfile] -vcodec copy -acodec copy  -ss [start] -t [duration] [outputfile]

Seems to work faster than the mencoder method