Skip to content

Tips

Here’s a page to store away some of those stupid little commands, tips, and tidbits that you already know, but just need some reminders on sometimes. These don’t quite fit into How-Tos because they’re too short, so I started a new section to hold these. These will be reminders to myself mostly, but hopefully someone else finds them useful.

Adding Swap to Raid1

Already have swap set on your hard drives because you were stupid and didn’t raid1 them with your other partitions during installation time? (Yes, I’m talking to myself on this sentence) Well, no problem. All you need to do is turn off your swap, create a new raid device, make the raid device swap, and reset the partition ID on the drives. All without a reboot. I’ll be assuming two IDE drives with swap on /dev/hda2 and /dev/hdc2.

[root@desktop ~]# swapoff /dev/hda2; swapoff /dev/hdc2
[root@desktop ~]# mdadm –create /dev/md2 –level=1 –raid-devices=2 /dev/hd[ac]2
[root@desktop ~]# cat /proc/mdstat (To see your new md2 device)
[root@desktop ~]# watch -n 1 “cat /proc/mdstat” (To see the array rebuild itself)
[root@desktop ~]# mkswap /dev/md2 (Set the device to swap)
[root@desktop ~]# vim /etc/fstab
# Add this line so swap starts on boot
/dev/md2     swap     swap     defaults     00
[root@desktop ~]# sfdisk –change-id /dev/hda 2 fd (Changes the ID of the partition)
[root@desktop ~]# sfdisk –change-id /dev/hdc 2 fd
[root@desktop ~]# swapon /dev/md2
[root@desktop ~]# free -m (Check to make sure it’s on)

Alternating Row Colors in OpenOffice Calc

How to alternate row colors in an OpenOffice spreadsheet.

  1. First, create two different styles titled, even and odd. Hit F11 to bring up the styles and formatting.
  2. Right click and create a new style. Name it even, and select the background color tab. Choose your color. (Gray)
  3. Right click and createa new style. Name it odd, and select the background color tab. Choose your color. (White)
  4. Next, select the entire sheet (Edit → Select All) or (Ctrl + A) or (Click the upper left-hand button).
  5. If you already closed the Styles and Formatting tool, open it back up (F11) and double click the even that you just created. The entire page should be a light gray now.
  6. Last, create a conditional statement. Make sure the entire sheet is selected again. Choose Format → Conditonal Formatting…
  7. Enter the following into the box: Formula is: MOD(ROW();2) Cell Style odd
  8. Click OK, and your sheet should alternate even rows as gray, and odd rows as white.

Mounting LVM2 with Knoppix

To mount drives with LVM under Knoppix 5.1.1.

Scan and make the volume groups active.

# vgscan
# vgchange -a y

Check the logical volume groups

# lvs
LV   VG   Attr   LSize Origin Snap%  Move Log Copy%
home vg   -wi-ao 10.00G

Mount the volume group

#mkdir /mnt/tmp
# mount /dev/vg/home /mnt/tmp
# ls /mnt/tmp

Converting FLV to MPEG

Do you use a video downloader plugin called VideoDownloader for Firefox? If so, and you’re always downloading videos from Google and YouTube, you’ll notice you get these .flv extensions which you can’t open in a media player under Linux. Flash Video File is the file extension you get, but I know for me, they won’t open. Well thanks to hardwarehank, it’s so easy to do under Linux it’s stupid.

Download your video file as an .flv, and then go this website for the full details.

409.ralree.info

Basically, all you have to do is install ffmpeg if you don’t have it already. For me, it’s already installed, but my CentOS 4 system just has an ffmpeg RPM installed from a third party repo. Once you get that installed you’re good to go. I don’t think you have to actually install it if you already have mplayer installed…I believe it’s a package dependency. Anyways, on the the converting.

# ffmpeg -i myvideo.flv -s 320x240 myvideo.mpg

You get a bunch of output, and that’s it. Sweet, huh. You can specify any size you want. Now, I’m not advocating ripping off copyrighted content! I’m just explaining how.