Administration

Windows-like Behavior in Fedora

Fedora did a thing I hated in Windows. It collected enough system files to flood my root partition over the years of usage.

[root@hp ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                 15G   14G  403M  98% /
udev                  996M  316K  996M   1% /dev
tmpfs                1004M  1.5M 1003M   1% /dev/shm
/dev/sda2              15G   14G  403M  98% /
/dev/sda1             485M  166M  294M  37% /boot
/dev/mapper/luks-6e55a54f-c3c6-45d9-99d3-a6d8015b2baa
                       97G   16G   76G  18% /home
/dev/sda6             117G  105G  5.9G  95% /home/t1/media

Top space consumers are:

[root@hp ~]# du -sh /*
156M    /boot
370M    /lib
7.3G    /usr
5.3G    /var
[root@hp ~]#  du -sh /usr/*
550M    /usr/bin
1.2G    /usr/lib
1.9G    /usr/lib64
3.4G    /usr/share
[root@hp ~]# du -sh /var/*
3.9G    /var/cache
890M    /var/lib
407M    /var/spool
[root@hp ~]# du -sh /var/cache/*
1.1G    /var/cache/abrt-di
2.8G    /var/cache/yum

A workaround:

[root@hp ~]# rm -rf /var/spool/abrt/*
[root@hp ~]# rm -rf /var/cache/abrt-di/usr/lib/debug/.build-id/*
[root@hp ~]# rm -rf /var/cache/yum/*
[root@hp ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
rootfs                 15G  9.3G  4.5G  68% /

Enough for preupgrade now!

Linux random passwords generation

This post is more a note to myself than a message I want to deliver to me struggling readers. There are two utilities for generating random passwords and one hack-around.

pwgen

Generates MANY passwords simultaneously. Very handy if somebody is behind your back watching you.

[root@hp ~]# pwgen
OVo4jiev Cohkah0r Iesev0ec thefuz0F asho6Zai em3tok5I Quoogh2k leeRuhi1
Eica7gie aew1ieTh Ukeewie3 Tee3aesa zasiCie7 iey9Ugho Eex5phae aip2ohHe
uL8AGee2 bux8rohX Aiv1voo2 AeS5thie uli1Shai aeWee0ai sha6aeV2 ni2Oong4
ahji7AiW rei0za9A uK1eih8a phoo4Aih taiGh0ab uod2ho8I tooX9coh jeeC5pie
ohxiCh7u oluif8Co OhTieC7e Phuro0sh eeca7Atu yee3Aeve Iwi1nige aiyu3Ein
AiCee0ba eC5Saehi voa2Aina ge4eiWee che8EeD2 Ait5ohth aQuahp4o oosou2Si
wa3aitiZ fah2oGhu do8oor5A Ied9Erob Caizei5a meeFai6b roh8WooW Lah8ieph
Eixoh6zi Cee8eidi eeChah6I eMohrij7 Zeisu0ha oech6Ae9 cioreT6p ee2Ohsha
Uu6yae5V zohShea8 Eizubo9r Reek2eiv Aak0veb7 phei3Ife onaeh7Oo jaiMopi9
Phohm9vi Ai3EeYie aequeeN8 eCiug9ei keiRee6I Aikei9wo tugh5Pae yie4maTu
eiH5Jei4 aeChia4I ahs3seeS eeg6Pa7M pei8Jooy ih1phiDu jee1ai4U uuY6eRai
wee5si4I ui2AhSoa Shee9EeB ahV4oof9 cei3pheZ iB5daw3u saegh4Lo Waroo1ah
aeth1Loo ohReesh4 Saidae7o meB7tha6 Eetae9Oh meiyiR5e AeTooc3c Bu0ou0se
Ahree5Of eiwuJie9 Cuogh7ae eekeeB8V ruu0Yoqu angie1Ki Oang3eeb Oobe9jiP
Loo3Oova yieNee0n moo2aiSh aem6ooD3 Paehoh2w xee6Ooph acahph2A kooGu5Ie
hag2Buon chah4Bii xaequ4In Ooy9Lohk oophoh4N Oo5Roh4a Phe8choo xa2Thoo4
XahBoo4j eeHah2ai Quaico6D Lauh0eiF Eiv9ga9c ih9pooPh aedeLaS3 ohleiGo2
aPh7wivi le4Xah9d lahl4Hei shu2Kuch OhfeDi7z Aengaej7 Phie4oom eige6Fae
Xaesh2Ju iN7Coh3S The8Ij4z kae0OGhi Shei6ohp RooReim6 Pheih3Ai Aikah8sh
taiph4Ei kaoRoh1f om0moh3S uaphee7E lab4Xu9k kahh3saZ ain8Zeic Uu1fohvo

apg

Generates few random passwords.

[root@hp ~]# apg
johebud6
VuwejThig1
TegtuIdNi
FlabEpNeec
bytjeewk
voyHatadd5

Unix hacker’s way.

This way is considered to be insecure, but Jesus! Who would know you have used this freaking way!

for ((n=0;n<10;n++)); do dd if=/dev/urandom count=1 2> /dev/null | base64 | sed -ne 2p | cut -c-8; done

Fast appending files to tar archive is impossible.

Eventually, tar is very slow for appending files to the existing tarball. I’m particularly talking about following options:

-r – append files to the end of an archive
-u – only append files newer than copy in archive

Logically thinking, for -u to work, it should accomplish linear search through the archive. Than bigger the archive, than slower the search. Moreover, if you’ll try to append in the loop, it will accomplish search as many times as many iterations you loop has. I would advice to use in the most exceptional case ONLY. Try avoiding

# -u. slow inefficient approach of taring multiple files
for file in $(ls -A)
do
    tar -uf tarball.tar $file;		#traverses all archive to append the file.
done

You’d think that -r option usage forces tar application to append files to the end of the archive, getting the position of the archive’s end from archive’s index. It doesn’t. Tar format is designed in a way that it has no index.

# -r approach is also slow and inefficient
for file in $(ls -A)
do
    tar -rf tarball.tar $file;		#traverses all archive to append the file.
done

However, TAR supports several formats for its archive. But they are not well-documented. I had a brief overview of them, and looks like
–format=gnu is the most recent and featured one. And It still has no index. I no longer understand why tar is even used. Despite of that, below is a workaround, allowing for packing unlimited amounts of files right instant. I recommend to never use append function with tar format. Instead, get to know what are you going to archive, prepare necessary files, and archive them all.

# faster approach for taring multiple files. No appending
ls -A >> list.txt
tar -cT list.txt -f backup.tar

Windows and Linux System Time Shift Fix

Recently, I had to install Vista on my laptop. After installation I found that system time in Linux and in Windows had 3 hours difference. So every time I was rebooting into another OS, my system time was set on another value. To track time, I am always using clock in the tray. So changing clock value after each restart was really annoying.

Windows does not change sytem clock value, it changes output on system tray’s clock value according timezone difference only. Vista did not change any value on system clock. It was showing whatever value was left after Linux. Linux was not changing any clock value also. So problem was in time representation in both operating systems.

Occasionally, Linux can represent clock value in UTC, as well as in local time format. In my case, Linux was interpreting value as UTC, and converting it to local time. But windows was reading UTC value of clock, remaining after Linux, thinking that it is a local time, adding timezone difference, and viola! I was getting my three hours difference. Apparently, Vista can not understand that clock is UTC. So I just changed clock representation in Linux.

# clock --localtime

Installing Windows XP After Fedora 9

Disclaimer.
This text describes, how I installed Windows XP after Fedora 9. This is not a how-to. That is more a description of my experience in solving this problem. If you are going to try the same using this text, I am not responsible for any of your actions. Be extremely careful, when you are working with partitions. You may easily loose all your data.

Tools Needed.
You will need a Windows Installation CD and your Linux disto-cd ( dvd ). Also you may need some Linux liveCD – in my case I had to use Mandriva 2008 Spring One LiveCD.

Actions.
Cleaning up my PC last time, I removed slow Mandriva and decided to switch back to Fedora. Also, I had in mind that soon I will have to start my final year project, which is going to be Windows-based. So, I left unpartitioned space on my HD to install Windows there later on. A week ago I found a piece of free time which I used to complete my PC maintenance. When I was asked to choose a partition for Windows, it appeared, that Windows installer could not create partition in unpartitioned space of my HD. It said, that it “Setup unable to create a partition – partition table is full”. I was surprised a lot, and I had to explore from another direction. Obviously, partition had to be created in Linux, to give a chance to dummy Windows installer to copy its proprietary files somewhere. I booted up my Linux back and started the show.
At first, I needed to know, which exact layout does my hard drive have.

Read More »