Montag, 27. Februar 2012

Shrinking a partition

Cropped my old linux installation to make some space:
sudo resize2fs -p /dev/sda5 8G # new size is 8G
sudo sfdisk -d /dev/sda # print current partition info
sudo fdisk /dev/sda followed by command 'p' shows the sector size of your disk. You will need it for calculating the new size multiples of sectors. Make sure it is at least 8G big.
sudo sfdisk /dev/sda -N5 -uS --no-reread # change partition info of partition 5
# you are queried for start sector and size - the only two of which are manditory

You wonder why I have chosen sfdisk instead of cfdisk or fdisk? The reason is both other tools did not allow me to enter the same start-sector like it was initially after deleting and adding the fifth partition. I also used sfdisk in the past because it allowed to create partitions via shell scripts.

Recovering grub2 in fedora16

I finally managed to kill my grub2 bootloader living in mbr. After messing around with cfdisk on currently mounted swap partitions. Not a wise step, but anyway here are some simple steps how I recovered:

Boot using live install usb-stick/cd
Press Tab to edit boot promt
Replace root=FeforaCD... with root=/dev/sda6 where 6 is the parition number where you root filesystem lives.
Open a terminal and enter:
sudo /sbin/grub2-install /dev/sda
This installs grub into mbr of disk /dev/sda (first scsi emulated disk - in my case a Samsung SSD)

Freitag, 24. Februar 2012

Improving battery live on Dell Vostro V133 running Fedora 16 x86_64

Improving battery live on Dell Vostro V133 running Fedora 16 x86_64:

Just a few simple steps are required:

First turn off all unneeded processes:

$ sudo systemctl disable iscsi.service
$ sudo systemctl disable iscsid.service
$ sudo systemctl disable lldpad.service
$ sudo systemctl disable fcoe.service
$ sudo systemctl disable livesys-late.service
$ sudo systemctl disable livesys.service
$ sudo systemctl disable lvm2-monitor.service
$ sudo systemctl disable mdmonitor-takeover.service
$ sudo systemctl disable cryptsetup.service

Then instruct the linux kernel to turn on various power saving features:

$ cat /etc/rc.d/rc.local
#!/bin/sh
echo 2 > /sys/devices/system/cpu/sched_smt_power_savings
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
echo 0 > /proc/sys/kernel/nmi_watchdog
echo 5 > /proc/sys/vm/laptop_mode
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
echo min_power > /sys/class/scsi_host/host2/link_power_management_policy
echo min_power > /sys/class/scsi_host/host3/link_power_management_policy
echo min_power > /sys/class/scsi_host/host4/link_power_management_policy
echo min_power > /sys/class/scsi_host/host5/link_power_management_policy
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done
for i in /sys/bus/usb/devices/*/power/level; do echo auto > $i; done
amixer set Capture mute nocap
hciconfig hci0 down

$ ls -l /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 880 Feb 24 03:09 /etc/rc.d/rc.local

Some powersaving features are configured via linux bootargs, if the corresponding features are compiled into the kernel:

$ cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Fedora"
GRUB_DEFAULT=saved
GRUB_CMDLINE_LINUX="usbcore.autosuspend=1 pcie_aspm=force i915.i915_enable_rc6=1 rd.md=0 rd.lvm=0 rd.dm=0 quiet SYSFONT=latarcyrheb-sun16 rhgb rd.luks=0  KEYTABLE=de-latin1-nodeadkeys LANG=en_US.UTF-8"

Then recreate grub config to contain those bootargs

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

# remove all entries which are not needed:
$ gnome-session-properties 

And restart to let all configurations take affect.