Archlinux: PACMAN Uygulamasini Hizlandirmak
From Lapis Wiki
Bu makale IPUCU bölümü serisinin bir parçasıdır
|
| Ses • Çekirdek • Terminal/Kabuk |
| Dosya İşlemleri• Tarayıcılar • Diğer |
Konu başlıkları |
Giriş
Asağıdaki yöntemler ile archlinux altında pacman uygulamasının daha hızlı çalısmasını sağlayabilirsiniz. Şimdi pacman'in internetten paketleri indirirken aria2 ,snarf veya wget kullanmasını sağlayacagız.Eğer daha önceden birini kullanıyorsanız onu devre dışı bırakmalısınız.Bunun için diğerinin başına diyez(#) koymanız yeterlidir.
Örneğin:
#XferCommand = /usr/bin/hedehödö -s ...
Aria2 ile hızlandırmak
1- Aria2 paketini sistemimize kuralım.
pacman -Sy aria2
2- /etc/pacman.conf dosyasını düzenleyelim.
XferCommand = /usr/bin/aria2c -s 2 -m 2 -o %o %u
Artık pacman dosyaları indirirken aria2'yi kullanacak.Aria2 bir paketi 2 ayrı depodan çekecek.Bu sayede gözle görülür bir hızlanma göreceksiniz...
Snarf ile hızlandırmak
1- İlk önce en güncel paketleri kullanmasını söyleyin:
pacman -Syu
2- Sonra snarf paketini kurun:
pacman -S snarf
3- Ve en son olarak, /etc/pacman.conf dosyasının içindeki [option] altına asağıdaki satırı ekleyin:
XferCommand = /usr/bin/snarf -N %u
Ve artik pacman indirme işlemlerini snarf üzerinden yapacaktir.
Wget ile hızlandırmak
Burda ise pacman'in internetten paketleri indirirken wget kullanmasını sağlayacağız:
1- İlk önce pacman'in son versiyonunun kurulu olup olmadığından emin olmak için aşağıdaki komutu verelim.
pacman -Syu
2- Wget'in kurulu olduğundan da emin olalım.
pacman -S wget
3- /etc/pacman.conf dosyasını düzenleyelim.Aşağıda yazılı satırı eklemeniz gerekiyor ama zaten dosyanın içinde başında # işareti ile var.Varsa başındaki # işaretini silin.Yoksa aşağıdaki satırı ekleyin.
XferCommand = /usr/bin/wget -c --passive-ftp -c %u
Artık pacman dosyaları indirirken wget'i kullanacak...
Pacman-cage ile hızlandırmak
pacman-cage isimli bir betik ile pacman'i hızlandırmak.
1- Bunu yapmak için aşağıdaki betiği pacman-cage isimli dosya olarak kaydedip çalıştırma ( +x ) hakkını veriyoruz.
| Dosya: /usr/bin/pacman-cage |
#!/bin/bash
#
# pacman-cage
#
# Copyright (c) 2002-2006 by Andrew Rose <rose.andrew@gmail.com>
# I used Judds pacman-optimise as a framework.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
myver='2.9.8'
dbroot="/var/lib/pacman"
pacmandb="/var/lib/pacman.db"
usage() {
echo "pacman-cage $myver"
echo "usage: $0 [pacman_db_root]"
echo
echo "pacman-cage creates a loopbacked filesystem in a contigious file."
echo "This will give better response times when using pacman"
echo
}
die() {
echo "pacman-cage: $*" >&2
exit 1
}
die_r() {
rm -f /tmp/pacman.lck
die $*
}
if [ "$1" != "" ]; then
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
dbroot=$1
fi
if [ "`id -u`" != 0 ]; then
die "You must be root to cage the database"
fi
# make sure pacman isn't running
if [ -f /tmp/pacman.lck ]; then
die "Pacman lockfile was found. Cannot run while pacman is running."
fi
# make sure pacman.db hasnt already been made
if [ -f $pacmandb ]; then
die "$pacmandb already exists!."
fi
if [ ! -d $dbroot ]; then
die "$dbroot does not exist or is not a directory"
fi
# don't let pacman run while we do this
touch /tmp/pacman.lck
# step 1: sum the old db
echo "==> md5sum'ing the old database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old
echo "==> creating pacman.db loopback file..."
dd if=/dev/zero of=$pacmandb bs=1M count=150 > /dev/null 2>&1
echo "==> creating ext2 -O dir_index -b 1024 -m 0 on $pacmandb..."
yes | mkfs.ext2 -O dir_index -b 1024 -m 0 $pacmandb > /dev/null 2>&1
echo "==> creating temporary mount point /mnt/tmp-pacman.."
mkdir /mnt/tmp-pacman
echo "==> mounting pacman.db to temporary mount point..."
mount -o loop $pacmandb /mnt/tmp-pacman
echo "==> copying pacman database to temporary mount point..."
cp -a /var/lib/pacman/. /mnt/tmp-pacman
echo "==> unmounting temporary mount point..."
umount /mnt/tmp-pacman
echo "==> removing temporary mount point..."
rmdir /mnt/tmp-pacman
echo "==> moving old /var/lib/pacman to /var/lib/pacman.bak..."
mv /var/lib/pacman /var/lib/pacman.bak
echo "==> createing new pacman db mount point @ $dbroot..."
mkdir $dbroot
echo "==> Mounting new pacman db..."
mount -o loop $pacmandb $dbroot
echo "==> md5sum'ing the new database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new
echo "==> checking integrity..."
diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
if [ $? -ne 0 ]; then
# failed, move the old one back into place
umount $dbroot
rm $pacmandb
mv $dbroot.bak $dbroot
die_r "integrity check FAILED, reverting to old database"
fi
echo "==> Updating /etc/fstab to reflect changes..."
echo "$pacmandb $dbroot ext2 loop,defaults 0 0" >> /etc/fstab
rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new
echo
echo "Finished. Your pacman database has been caged!. May the speedy pacman be with you."
echo
exit 0
|
2- /var/lib/pacman dizininin büyüklüğü hakkında bilgi ediniyoruz
#du -sh /var/lib/pacman
3- pacman-cage dosyasının 80. satırında count=150 deki değeri 2.maddedeki öğrendiğimiz değere göre yazabiliriz.Buradaki 150 MB , /var/lib/pacman dizini için ne kadar yer atanacağını belirtiyor.Eğer değiştirmezseniz ön tanımlı olarak 150 mB atıyor.
son olarak pacman-cage komutunu veriyoruz
[root@arch signorelli]# pacman-cage ==> md5sum'ing the old database... ==> creating pacman.db loopback file... ==> creating ext2 -O dir_index -b 1024 -m 0 on /var/lib/pacman.db... ==> creating temporary mount point /mnt/tmp-pacman.. ==> mounting pacman.db to temporary mount point... ==> copying pacman database to temporary mount point... ==> unmounting temporary mount point... ==> removing temporary mount point... ==> moving old /var/lib/pacman to /var/lib/pacman.bak... ==> createing new pacman db mount point @ /var/lib/pacman... ==> Mounting new pacman db... ==> md5sum'ing the new database... ==> checking integrity... ==> Updating /etc/fstab to reflect changes... Finished. Your pacman database has been caged!. May the speedy pacman be with you. [root@arch signorelli]#
Bu kadar konfigürasyon tamamlandı..Dikkat ettiyseniz /etc/fstab dosyasına /var/lib/pacman.db /var/lib/pacman ext2 loop,defaults 0 0 ilgili bölümü yazıyor.Evet Şimdi hız testi sonuçlarını görelim.
pacman-cage den önce
$ time pacman -Ss pacman
real 0m0.783s user 0m0.404s sys 0m0.380s
pacman-cage ayarlandıktan sonra
$ time pacman -Ss pacman
real 0m0.592s user 0m0.280s sys 0m0.340s
- Eğer ben pacman-cage uygulamasını sevmedim ,iptal etmek istiyorum diyorsanız aşağıdaki, pacman-uncage betiğini kaydediyor (çalışma hakkını verip +x ) uyguluyorsunuz
| Dosya: /usr/bin/pacman-uncage |
#!/bin/bash
#
# pacman-uncage
#
# Copyright (c) 2002-2006 by Andrew Rose <rose.andrew@gmail.com>
# I used Judds pacman-optimise as a framework.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
myver='2.9.8'
dbroot="/var/lib/pacman"
tmproot="/var/lib/pacman.new"
pacmandb="/var/lib/pacman.db"
usage() {
echo "pacman-uncage $myver"
echo "usage: $0 [pacman_db_root]"
echo
echo "pacman-uncage returns your pacman db to the generic style."
echo
}
die() {
echo "pacman-uncage: $*" >&2
exit 1
}
die_r() {
rm -f /tmp/pacman.lck
die $*
}
if [ "$1" != "" ]; then
if [ "$1" = "-h" -o "$1" = "--help" ]; then
usage
exit 0
fi
dbroot=$1
fi
if [ "`id -u`" != 0 ]; then
die "You must be root to uncage the database"
fi
# make sure pacman isn't running
if [ -f /tmp/pacman.lck ]; then
die "Pacman lockfile was found. Cannot run while pacman is running."
fi
if [ ! -d $dbroot ]; then
die "$dbroot does not exist or is not a directory"
fi
# don't let pacman run while we do this
touch /tmp/pacman.lck
# step 1: sum the old db
echo "==> md5sum'ing the old database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.old
echo "==> copying pacman.db contents back, note: the time needed to get a brew is now."
mkdir $tmproot
cp -a $dbroot/. $tmproot
echo "==> unmounting old dbroot and moving new one in"
umount $dbroot
rmdir $dbroot
mv $tmproot $dbroot
echo "==> md5sum'ing the new database..."
find $dbroot -type f | sort | xargs md5sum >/tmp/pacsums.new
echo "==> checking integrity..."
diff /tmp/pacsums.old /tmp/pacsums.new >/dev/null 2>&1
if [ $? -ne 0 ]; then
# failed, move the old one back into place
rm -rf $dbroot
mkdir $dbroot
mount -a
die_r "integrity check FAILED, reverting to old database"
fi
echo "==> Removing old pacman.db"
rm $pacmandb
rm -f /tmp/pacman.lck /tmp/pacsums.old /tmp/pacsums.new
echo
echo "Finished. Your pacman database has been uncaged!. Welcome home."
echo "You will need to remove the old mount line from your /etc/fstab"
echo
exit 0
|
Ardından /etc/fstab dosyasındaki /var/lib/pacman.db /var/lib/pacman ext2 loop,defaults 0 0 satırını siliyorsunuz ve pacman-cage'ten kurtulmuş oluyorsunuz
Bağlantılar
- aria2-anasayfa
- aria2 Lapis Forum İncelemesi
- Pacman Optimization - Part 2
- Arch-Wiki(Faster_Pacman_Downloads)
- Arch-Wiki (Boost_Pacman)
Konu ile ilgili fikirlerinizi paylaşmak için; Lapis Wiki Başlığı

