Friday, August 26, 2011

Linux Mint 11 "Katya" on VAIO P - VPCP115KG Part 3

Suspend
It does not work at all, comes back with a blank screen, unable to connect to Vaio from other node. Recommend to change the settings in Power Management to avoid any Suspend action.


Hibernate
No issue found.


Volume Keys
All three function keys F2, F3 and F4 work correctly.


Wireless LAN
No issue found.


Camera
No issue found.


3.5G (HSDPA) Data Connection
Able to connect to internet through my Xperia Arc as a gateway (tethering).

HSDPA connection is detected as usb0 interface












Enable USB tethering in Xperia Arc























Bluetooth
Able to transfer file between Vaio and Xperia Arc.

Vaio is paired with Xperia Arc in Bluetooth

















Xperia Arc is paired with Vaio























SD Memory and Memory Stick Duo
Both type of removable media are detected.


Other Information
Kernel version & release: 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011

Statistic when powered by AC adaptor:
Startup time: 36 secs (Login screen appears with Disk I/O LED stops blinking)
Login time: 18 secs (Gnome desktop loading completes with Disk I/O LED stops blinking)
Shutdown time: 6 seconds


Statistic when powered by battery:
Startup time: 42 seconds
Login time: 18 seconds
Shutdown time: 6 seconds




Thursday, August 25, 2011

Linux Mint 11 "Katya" on VAIO P - VPCP115KG Part 2

Backup
I use an USB hard disk cradle to store backup dump files. The hard disk is formatted in ext4 filesystem.
Prerequisite is to install dump utility first:
$ su -
# apt-get install dump


Let's create a snapshot:
# lvcreate -l 563 -s -n lv99.fss /dev/vg00/lv00
Start backing up / filesystem (assume the USB disk is mounted under /media/backup):
# dump 0uf /media/backup/20110822-vpcp115kg-lv00.dmp /dev/vg00/lv99.fss
When it completes, delete the snapshot:
# lvremove -f /dev/vg00/lv99.fss


The / backup takes 6 minutes 42 seconds.

Let's create a backup of /boot partition:
# dump 0uf /media/backup/20110822-vpcp115kg-boot.dmp /dev/sda1


The /boot backup takes 2 seconds.

The first backup we used snapshot, the second backup we did not use, actually we cannot use snapshot because /boot partition is not a logical volume. We use snapshot because we want a solid backup that we can restore it later. Since / filesystem is an active partition (try umount it), using dump might not guaranty a successful restore (the restore might be fine, actually), but the OS might have problem due to file inconsistency. On the other hand, /boot partition is not considered active, you can try umount it after the OS is up. Or umount it before taking backup.


Restore
To restore the / filesystem due to whatever reasons:
- Boot Katya using the boot media (the USB flash drive) with active network connection.


When Katya is ready, connect the backup media (assume it is mounted under /media/backup), then open a gnome-terminal:
$ sudo su -
# apt-get install lvm2 dump
Activate logical volume lv00:
# lvm lvchange -a y /dev/vg00/lv00
Wipe logical volume lv00:
# mkfs.ext4 /dev/vg00/lv00
# mkdir -p /media/lv00
# mount /dev/vg00/lv00 /media/lv00


Start restoring / filesystem:
# cd /media/lv00
# restore rvf /media/backup/20110822-vpcp115kg-lv00.dmp
When the restore completes (it takes about 10 minutes):
# sync
# rm restoresymtable
# cd /
# umount /media/lv00
Run a filesystem check against logical volume lv00:
# fsck /dev/vg00/lv00


Ignore this step if it is required to restore /boot filesystem, otherwise just issue the following two commands and stop.
# umount /media/backup
# init 6

Retrieve the UUID of /dev/sda1:
# blkid | grep '/dev/sda1'
/dev/sda1: UUID="e80248bf-2417-4d66-a104-b8dce0e34c71" TYPE="ext4"
To restore the /boot filesystem:
# mkfs.ext4 /dev/sda1
# mkdir -p /media/sda1
# mount /dev/sda1 /media/sda1
Start restoring /boot filesystem:
# cd /media/sda1
# restore rvf /media/backup/20110822-vpcp115kg-boot.dmp
When the restore completes (it takes about 20 seconds):
# sync
# rm restoresymtable
# cd /
# umount /media/sda1

Disconnect the USB backup media:
# umount /media/backup
Since /dev/sda1 was wiped previously, need to re-install GRUB2:
# mount /dev/vg00/lv00 /media
# mount /dev/sda1 /media/boot
# grub-install --root-directory=/media /dev/sda --force
# sync

Assign the old UUID to /dev/sda1:
# tune2fs /dev/sda1 -U e80248bf-2417-4d66-a104-b8dce0e34c71

Umount restored filesystems
# umount /media/boot
# umount /media
Run a filesystem check against /dev/sda1:
# fsck /dev/sda1
Deactivate logical volume lv00:
# lvm lvchange -a n /dev/vg00/lv00
# init 6


If you re-install GRUB2 previously, run the following command after reboot:
# update-grub

The OS is back to the previous stage of the last backup.


Intel EMGD (GMA500 driver)
There are four commands to enter (for more information, please refer to the instructions found in Ubuntu wiki "Poulsbo" 2.1):
# add-apt-repository ppa:gma500/emgd
# apt-get update
# apt-get install xorg-emgd emgd-dkms emgd-xorg-conf
# emgd-xorg-conf


Don't reboot yet, copy the configuration from this page and save it as /usr/share/X11/xorg.conf.d/10-emgd.conf, then go ahead to reboot:
# init 6


Once it is rebooted, Compiz can be activated!


Brightness Function Keys Fix
Install emgdbl package:
# apt-get install emgdbl


Edit the following line in /etc/default/grub (added settings are highlighted in blue):
GRUB_CMDLINE_LINUX="acpi_osi=Linux acpi_backlight=video mem=1920mb"


Append the following line in /etc/modprobe.d/blacklist.conf:
blacklist poulsbo

Append the following line in /etc/initramfs-tools/modules:
emgdbl


Generate a new initramfs image:
# cd /boot
# cp -p initrd.img-2.6.38-11-generic initrd.img-2.6.38-11-generic.20110825
# mkinitramfs -o initrd.img-2.6.38-11-generic

# init 6

After reboot, the F5 & F6 keys are resumed.


Other Little Hacks
Disable tty2 - tty6 by editing /etc/init/tty[2-6].conf:
Comment the following line:
#start on runlevel [23]


Disable the following services from Startup Applications Preference in Control Panel:
- Bluetooth Manager
- Dropbox
- GNOME Login Sound
- GSettings Data Conversion
- mintWelcome
- Personal File Sharing
- PulseAudio Sound System KDE Routing Policy
- Visual Assistance
- Zeltgelst Datahub


In Keyboard Shortcuts, assign Launch web browser action to the "WEB" key. Once it is assigned, the default browser will be launched when you press the "WEB" key in Gnome.




Linux Mint 11 "Katya" on VAIO P - VPCP115KG Part 1

Hardware Specification
VAIO P - VPCP115KG


Boot Media
Use Startup Disk Creator from another Linux node to make a bootable USB flash drive. A 1GB USB flash drive is good enough. The disc image is linuxmint11-gnome-dvd-32bit.iso.

In case the flash drive boots with error message "vesamenu.c32 not a com32r image", run the following commands from the node (replace the text highlighted in red colour accordingly):

# cp -r /usr/lib/syslinux/vesamenu.c32 /media/20AD-F9B9/syslinux/
# syslinux /dev/sdc1



Partitioning #1
This laptop comes with one 64GB SSD and 2GB memory.
Partition Size Remark
/dev/vg00/lv00 9000MB / partition in LV
/dev/sda1 100MB /boot partition
/dev/vg00/lv01 1024MB swap partition
/dev/vg00/ev00 16GB encrypted 16GB partition in LV
/dev/vg00/lv02 8070 LE /data partition in LV
free space
563 PE free space for snapshot

LV - Logical Volume
LE - Logical Extents
PE - Physical Extents


Once Katya is booted from the flash drive with network available, run the following commands to install lvm:
$ sudo su -
# apt-get install lvm2


Create a 100MB /boot partition:
# fdisk /dev/sda (n; p; 1; <default>; +100M)
Use rest of the disk for LVM (continue from the previous command):
(n; p; 2; <default>; <default>; w)

Create physical volume:
# lvm pvcreate /dev/sda2
Create volume group vg00:
# lvm vgcreate vg00 /dev/sda2
Create logical volume group lv00, i.e. / partition:
# lvm lvcreate -n lv00 -L 9000 vg00
Create logical volume group lv01, i.e. swap partition:
# lvm lvcreate -n lv01 -L 1024 vg00
Create ext4 filesystem:
# mkfs.ext4 /dev/sda1
# mkfs.ext4 /dev/vg00/lv00
Create a swap area:
# mkswap /dev/vg00/lv01


When Katya is installed, will continue to add the encrypted partition and /data partition.


Installation
Launch Install Linux Mint icon from the desktop, follow the instructions and assign /, /boot and swap partition appropriately. When the installation finishes, click 'Continue testing' button.

Open a gnome-terminal and install lvm2 before reboot:
$ sudo su -
# mkdir /mnt/lv00
# mount /dev/vg00/lv00 /mnt/lv00
# mount /dev/sda1 /mnt/lv00/boot
# chroot /mnt/lv00
# mount -t proc proc /proc
# mount -t sysfs sysfs /sys
# apt install lvm2
# sync
# exit
# umount /mnt/lv00
# init 6

Once the node is rebooted, Katya is ready, login and launch Update Manager, when all updated packages are installed, reboot the node and prepare to create the other two volumes.



LUKS Volume
Create an encrypted LV:
$ su -
# lvm lvcreate -n ev00 -L 16G vg00
Next command takes 8 to 9 hours to finish:
# dd if=/dev/urandom of=/dev/vg00/ev00
Create a passphrase using cryptsetup, follow instructions from the command:
# cryptsetup --verify-passphrase --key-size 256 luksFormat /dev/vg00/ev00
Open the LUKS volume:
# cryptsetup luksOpen /dev/vg00/ev00 ev00
Create ext4 filesystem:
# mkfs.ext4 /dev/mapper/ev00

Up to this point, the encrypted volume ev00 is created, going forward to access the volume (let's say, under /media/ev00), run the following commands:
# cryptsetup luksOpen /dev/vg00/ev00 ev00
# mount -o acl,noatime /dev/mapper/ev00 /media/ev00
The parameter acl gives us more control over traditional u:g:o ownership. acl package needs to be installed explicitly:
# apt-get install acl
To use ACL, issue the following command (replace the username field highlighted in blue colour):
# setfacl -R -m u:ninja:rwx /media/ev00
The parameter noatime can speed up the read/write disk access with an acceptable trade-off - Access timestamps are not updated when a file is read. In other words, it extends the lifespan of your SSD.



Partitioning #2
Create /data volume, and why is it 8070 LE?
The reason to use LVM is to facilitate snapshot of any active partition, i.e. / partition. In order to have a solid / partition snapshot, one quarter (20% to 25%, more precisely) of free space equals to the size of / partition is required. When we created logical volume lv00, a 9GB volume was allocated, its LE is 2250:
# lvm lvdisplay /dev/vg00/lv00 | grep 'LE'
  Current LE             2250


Therefore 563 LE (2250 / 4 = 562.5) has to be reserved for snapshot (PE and LE are interchangeable). To figure out how much free PE is available from volume group vg00, we can run the following command:
# lvm vgdisplay /dev/vg00 | grep -e 'Free'
  Free  PE / Size       8633 / 33.72 GiB


8377 - 563 = 7814, that is how the value gets calculated. Let's create /data volume:
# lvm lvcreate -name lv02 -l 8070 vg00
# mkfs.ext4 /dev/vg00/lv02
# mkdir /data


To start using /data volume:
# mount -o acl,noatime /dev/vg00/lv02 /data
Apply ACL:
# setfacl -R -m u:ninja:rwx /data


Add the new created volume in /etc/fstab and apply other parameters (all changes are highlighted in blue colour):
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system>       <mount point> <type> <options>                 <dump>  <pass>
proc                  /proc         proc   nodev,noexec,nosuid       0       0
/dev/mapper/vg00-lv00 /             ext4   errors=remount-ro,noatime 0       1
/dev/sda1             /boot         ext4   defaults,noatime          0       2
/dev/mapper/vg00-lv02 /data         ext4   defaults,noatime,acl      0       2
/dev/mapper/vg00-lv01 none          swap   sw                        0       0
tmpfs                 /tmp          tmpfs  mode=1777                 0       0


Please note a tmpfs is also created and mounted under /tmp.

Next, reboot the system.