Thursday, August 25, 2011

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.



No comments:

Post a Comment