Laptop - Fix partly broken computer - Limit broken display, use broken disk, scan memory etc


Problem: Partly broken LCD display

If there are visible areas of the display where you could  fit a desktop area, then using Linux you may limit your desktop into this area.

Limiting the display size should be very easy to do in Linux but I found out it is not.

However,  I came up with this for Ubuntu 14.10 which limits a damaged 1366x768 LCD to 912x768:

#!/bin/bash
/usr/bin/xrandr --fb 912x768 --output LVDS --mode 1366x768 --panning 912x768

Where LVDS is the name of the display. To find this out I ran xrandr without arguments.

I put the code above into a file that I then added to startup applications in Ubuntu.

This limited the window area but not the desktop, so the tray controls and the clock of Unity were still out in the damaged area to the right.

Then I came up with the stuff below, mixed together from various sources online. This consists of the following files:

/var/scripts/limitscreen - a script that uses modelines to set the resolution.
/etc/acpi/lid.sh - a script that runs when the lid is opened or closed (which causes the corrected resolution to reset)
/etc/acpi/events/lm_lid - specifies what acpid should run when the lid opens or closes

You may need to add more ACPI events for when coming back from energy-saving mode etc.

Note that when choosing a desired resolution the values should be a multiple of 16. 
So in my case when I had a 1366 broken display with a working area of 930 I found that 912 was good, as 912 / 16 = 57,0.

Below is the the contents of the files.

/var/scripts/limitscreen:

#!/bin/bash

# to make the resolution.

# NOTE: run cvt xresolution yresolution refreshrate to get modeline, for example: cvt 912 768 60

# remove Modeline at the beginning, add the rest here after newmode:
xrandr -d :0 --output LVDS --newmode brokenlcd 56.50  912 960 1048 1184  768 771 781 798 -hsync +vsync

# add the mode
xrandr -d :0 --addmode LVDS brokenlcd

# first set this resolution
xrandr -d :0 --fb 912x768 --output LVDS --panning 912x768 --mode brokenlcd

# then set this resolution - note the real resolution in mode !
xrandr -d :0 --fb 912x768 --output LVDS --mode 1366x768

/etc/acpi/lid.sh:
#!/bin/bash

# this runs when the lid opens or closes
# put your logged in username here
YOURUSERNAME="user";

# check if we are opening the lid
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
    # run the resolution changer
    su $YOURUSERNAME /var/scripts/limitscreen

    # to log the event:
    # su $YOURUSERNAME /var/scripts/limitscreen >> /tmp/lid_log 2>&1
fi

/etc/acpi/events/lm_lid:

event=button/lid.*
action=/etc/acpi/lid.sh %e


Problem: Completely broken display

If the display is so broken that you cannot see what you are doing, then you may connect an external display using a port such as VGA, DVI, HDMI or even S-Video.


Problem: Keyboard has keys that are loose

If the keys are there but they are loose so they may get away, then you may try to reattach them in the first place. 
If that does not work, then use blu-tack (häftmassa in swedish) to make them stick. 
Use only a small amount of some millimeters as you want them to spring back when they are pushed.


Problem: Keyboard has lost keys

If there are anything behind left to push, then you may recreate the keys using some plastic leftovers.
Caps of spray cans cutted out to a matching size and then attached using blu-tack proved to work.


Problem: Keyboard is totally broken

Connect an external keyboard using USB or PS/2.


Problem: Memory has damages

First scan the memory using Memtest86 or Memtest86+.

If the memory is not completely broken then in Linux you may ommit the broken parts of the memory using kernel parameters.

http://ubuntuforums.org/showthread.php?t=1342957

This also works in Windows but only by limiting the size of the memory, not ommitting areas - anything behind the broken area will be unusable.


Problem: Disk has damaged sectors

You can scan the disk and skip the broken sectors and use the rest of the disk like a disk without damages.

Warning, this method may destroy data on the disk.

Split up the disk into partitions to scan using GParted on a live USB. 
You do not need to create file systems, just make sure they get names usable by the command badblocks.

For a disk of 200 GB, make some areas of 25 GB for example. 
You may then have 8 partitions named /dev/sda0 to /dev/sda7 in Linux.

They may not be prefixed sd, it can be hd or something else:

| 25 GB (sda0) | 25 GB (sda1) | 25 GB (sda2) | 25 GB (sda3) | 25 GB (sda4) | 25 GB (sda5) | 25 GB (sda6) | 25 GB (sda7) |

Open a terminal and work your way through the partitions with badblocks:

badblocks -vvv /dev/sdX

Replace X with the partition numbers from GParted. Take note which parts of the disk that are good and those that are not.

Then with this information, make partitions that span over the broken areas and maybe format them and label them as broken1, broken2, broken3 and so on.

| 100 GB (sda..) BROKEN | 25 GB (sda4) | 25 GB (sda5) | 50 GB (sda...) BROKEN |

Then create partitions in the good areas where you like to put your data. You may also delete the the partitions covering the broken areas, although it can be good to keep them for reference:

| 100 GB empty space | 50 GB (sda1 NTFS) | 50 GB empty space |

Then install the OS into the specified partitions. You may guide the installer so the files are placed in the correct partitions.

For Ubuntu for example you may tell where to put the root (/) and the swap partitions - it may be wise to make an extended partition for Linux OS:es and then make the root and swap partition inside that because of this.



Previously updated 2015-06-12 00:02:55.

This is a personal note. Last updated: 2019-07-16 01:45:33.



GitHub

My

GitLab

My

LinkedIn

My

Klebe.se

Don't forget to pay my friend a visit too. Joakim