Sunday, September 18, 2011

Verify TRIM support on Linux

Wasted my time today puzzling why the trim support of my ssd does not work, or I thought it wasn't but was working alright. When you google "linux trim verify" the link below and most people link to the site below. Apparently the tests is not fully correct. Most of the time it works for others, but not me. Maybe it has to do that I formatted my ext4 w/ -E stripe-width=128
Anyway this is a better test I found, but I can't seem to see the link anymore. Using my bash history for reference.
dd if=/dev/urandom of=tmpfile bs=1M count=10 && sync
hdparm --fibmap tmpfile
hdparm --read-sector [address between begin_LBA and end_LBA of previous command] # expecting random numbers here
rm tmpfile && sync && sleep 120
hdparm --read-sector [address between begin_LBA and end_LBA of previous command] # expecting zeroes
The real key is the sector address is somewhere in between and NOT the start sector, as its possible the trim command will not set things to zeroes if files overlap. As it had happened to me 9 out of 10 tries using the test below I get random numbers still. The test above I get zeroes consistently.

Manual setup of UEFI, GPT and GRUB2

I recently got a Crucial m4.  I then have to transfer my existing HDD on it.  Its easier to do a clean install of Oneiric and it would pretty much do UEFI + GPT + GRUB2 for you.  However if you want to manually transfer everything I did the following steps:

  • Boot on Oneiric live CD or another boot this that will boot in UEFI mode. Its important that boot is on UEFI mode and not BIOS mode
  • Go to a shell and install gdisk as we want to partition the SSD w/ GPT and not MBR. fdisk only supports MBR
    apt-get install gdisk
  • Partition a EFI system partition.  This would hold grub2 files later and other boot loaders if needed.  I partitioned mine on sda1 as type EF00 (EFI System) w/ the size of 200mb.  Yes a bit bigger than what is needed however most people recommend 200mb as some boot loaders needs a bigger space.
  • Format the partitions.  The EFI System partition is formatted as vfat, as per EFI spec.
    mkfs.vat /dev/sda1
    mkswap /dev/sda2
    mkfs.ext4 -E stripe-width=128 /dev/sda3
    mkfs.ext4 -E stripe-width=128 /dev/sda4
    I put in a stripe width of 128 k as there are some recommendation this is optimal for SSD. However test suggest that your mileage may vary.
  • Mount and create the dirs on EFI system partition
    mkdir /boot/efi
    mount /dev/sda1 /boot/efi
    mkdir -p /boot/efi/efi
  • Install grub efi
    apt-get install grub-efi-amd64
  • Setup grub on the EFI system partition
    modprobe dm-mod
    grub-install --boot-directory=/boot/efi/efi --bootloader-id=GRUB2 --no-floppy --recheck
    cp /usr/share/grub/unicode.pf2 /boot/efi/efi/grub/
    cp /boot/grub/grub.cfg /boot/efi/efi/grub/grub.cfg
    I copied my old grub.cfg and update the UUID to point to the new SSD
  • Setup the EFI boot entry
    modprobe efivars
    efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "GRUB2" --loader "\\EFI\\grub\\grub.efi"
    GRUB2 is the entry that would appear on the EFI bootloader.
The following resource helped me a lot

I am still working out on the graphics output,  This would only give you a text based grub.

Saturday, January 8, 2011

HP 6910p 3G on linux

I got the 3G hs2300 on the 6910p running before, but it was a long time ago. I would need internet access again on the road. I detached the battery and put in the sim card to test. It seems modem can't be detected. Doesn't appear on lsusb, not much clue on dmesg, I verified that its turned on bios, started to look around forums, tried various modprobe, was going to start using usb-modeswitch.

I then decided to reboot to Windows after several years of not going there. HP wireless assistant tells that its disabled as that the gsm sim is accessible and suggest to close or put the battery back. I put the battery back, HP wireless assistant changes status to still disabled but now suggest to fix via Device Manager. No luck, Device Manager can't find drivers, etc. So did not want to spend it running on Windows and maybe putting the battery back is enough to get it running on Linux again.

Reboot to linux, network manager picks it up. Nothing to setup aside from APN, etc. No driver install, etc. Just put the battery back. Hopefully this post saves someone a few hours diagnosing the problem. Just put the battery back and linux should see the hs2300 3G modem.