https://wiki.archlinux.org/api.php?action=feedcontributions&user=AoeAoe&feedformat=atomArchWiki - User contributions [en]2024-03-29T01:44:08ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Lenovo_IdeaPad_Y580&diff=265215Lenovo IdeaPad Y5802013-07-05T23:09:07Z<p>AoeAoe: Added info about ideapad platform driver interfaces</p>
<hr />
<div>[[Category:Lenovo]]<br />
The Lenovo IdeaPad Y580 started shipping in June 2012. It is a fairly powerful machine, but it has its own compatibility issues. The purpose of this article is to help with setting up Arch Linux on this machine.<br />
<br />
==Installation==<br />
<br />
Install Arch on the machine if you have not done it already. Read [[Installation Guide]] for more information.<br />
<br />
== Ethernet ==<br />
If you cannot get ethernet working, you can get a ethernet connection with the help of the driver alx. This driver is not yet part of the Linux kernel, and that is why your ethernet card is not recognized at first. The links from QCA upstream [https://www.kernel.org/pub/linux/kernel/projects/backports/2013/03/04/compat-drivers-2013-03-04-u.tar.bz2 alx source files] works for current 3.8.x kernels.<br />
This sources is found to work for both AR8161 and AR8162 ethernet devices.<br />
Copy the tarball to a flash drive, boot the live cd, mount the flash drive, cd to the directory with the tarball and use:<br />
<br />
tar -xjvf compat*<br />
cd compat*<br />
./scripts/driver-select alx <br />
make<br />
sudo make install <br />
<br />
After this, load the module (modprobe alx) and you should be able to get ethernet working easily. As a alternative you can install dkms-alx from [https://aur.archlinux.org/packages/dkms-alx/ AUR] and it will recompile the module every reboot after a kernel upgrade.<br />
<br />
The machine comes with Windows and some Lenovo partitions that may be important if you need to recover the Windows install. <br />
<br />
In case you do not need to restore the machine to their original state, you can just delete the existing partition. Other way, backup the partions before erasing them<br />
<br />
Also, this laptop can use UEFI. If you want to use it, you need to a GPT partition (see below).<br />
<br />
==UEFI==<br />
Even thought its easier to switch from UEFI to legacy mode BIOS in this laptop and install Arch Linux on mSATA SSD and without disturbing factory installed windows 8 located on the HDD, this section will guide you to install Arch Linux with UEFI. UEFI is complicated and so proper understanding is advised before you start.<br />
<br />
Read these pages: [http://www.rodsbooks.com/bios2uefi/index.html Rod smith's UEFI guide] [[Unified Extensible Firmware Interface]] and [[GRUB2]].<br />
<br />
Among other things, you need a gpt partition and grub2. <br />
<br />
To install Arch on the SSD drive, you need at least two partitions: one small (100 MB) boot partition, and another partition for /. To partition the drives, you can use cgdisk, which you can get by installing the package gpttools.<br />
<br />
You should also create a third partition (with about 1GB) for EFI. This partition needs to be of EFI system type (code ef00 on gdisk) and it should be formatted as FAT32. If the partition is /dev/sda2, use:<br />
<br />
mkfs.vfat -F32 /dev/sda3 <br />
<br />
After you have your base system up and running, install the grub 2 firmware:<br />
<br />
pacman -S grub2-efi-x86_64<br />
<br />
Mount the system partition at /boot/efi:<br />
<br />
mkdir /boot/efi<br />
mount -t vfat /dev/sda3 /boot/efi<br />
<br />
Install grub2 efi app (grubx64.efi) to /boot/efi/EFI/arch_grub, and its modules to /boot/efi/EFI/grub/x86_64-efi:<br />
<br />
grub-install --directory=/usr/lib/grub/x86_64-efi --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --boot-directory=/boot/efi/EFI --recheck --debug<br />
mkdir -p /boot/efi/EFI/grub/locale<br />
cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/efi/EFI/grub/locale/en.mo<br />
<br />
The grub2 wiki page says to copy the app to other places. This is probably not necessary, but you may want to use:<br />
<br />
mkdir /boot/efi/EFI/tools<br />
cp /boot/efi/EFI/arch_grub/grubx64.efi /boot/efi/shellx64.efi<br />
cp /boot/efi/EFI/arch_grub/grubx64.efi /boot/efi/EFI/shellx64.efi<br />
cp /boot/efi/EFI/arch_grub/grubx64.efi /boot/efi/EFI/tools/shellx64.efi <br />
<br />
Now comes the part where the grub2 page is not very clear. You need to add the system to the UEFI menu (the menu that shows up when you press F12 at boot). To do this, you need an UEFI shell. The Y580 does not come with a shell built in, but you can put one in a flash drive and boot from it. To do this, get a bootable flash drive, create a partition (1GB is enough) and format it as FAT32. Assuming that the partition is /dev/sdc1, type the following:<br />
<br />
mount /dev/sdc1 /media<br />
mkdir -p /media/efi/boot<br />
cd /media/efi/boot<br />
wget https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi<br />
mv Shell.efi bootx64.efi<br />
cd /<br />
umount /media <br />
<br />
The code creates a directory /efi/boot in the flash drive, downloads the shell, copies it to /efi/boot and renames it as bootx64.efi. The shell is downloaded from the link given here: https://wiki.archlinux.org/index.php/Unified_Extensible_Firmware_Interface#UEFI_Shell. Note that you need a 2.0 shell, otherwise you will not be able to add an entry to the menu. <br />
<br />
Note that it is also possible to simply place the UEFI shell in your UEFI system partition if you do not have a flash drive at hand:<br />
wget https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/ShellBinPkg/UefiShell/X64/Shell.efi<br />
mkdir -p /boot/efi/EFI/boot<br />
mv Shell.efi /boot/efi/EFI/boot/bootx64.efi<br />
<br />
This will cause the ideapad UEFI firmware to automatically add a new boot option named "EFI HDD Device" which will by default come first.<br />
<br />
Now reboot, go to the BIOS (press F2), enable UEFI and exit, then press F12 and the flash drive should show up in the menu (you want to choose the UEFI entry). Now you should be in the UEFI shell. There is quite a lot that you can do, but be careful because a mistake can seriously compromise the machine. This guide may be worth looking at: http://software.intel.com/en-us/articles/uefi-shell/<br />
<br />
For now, you just need the command bcfg. To add Arch to the first entry of the menu, use:<br />
<br />
bcfg boot add 0 fs1:\EFI\arch_grub\grubx64.efi "Arch Linux" <br />
<br />
The command assumes that the system partition is installed on the first drive. This partition has the loader (grubx64.efi) and this little program is what loads grub2. If you add Arch to the first entry, you can boot to it without pressing F12. <br />
<br />
To see the menu entries, use:<br />
<br />
bcfg boot dump -v<br />
<br />
To delete, say the 3rd entry:<br />
<br />
bcfg boot rm 3<br />
<br />
Once you are happy with the menu entries, reboot and you should be able to boot into Arch.<br />
<br />
==Dual-Boot With Windows 8==<br />
<br />
To avoid problems with the Arch install, put Windows on the second drive (this means that the second drive should also have a GUID partition table, since Windows 8 only works with one).<br />
<br />
Windows 8 uses UEFI, so you can press F12 to choose between Arch and Windows, or just adjust this at the BIOS. Another option is to use the Windows program EasyBCD and add Arch to the Windows boot loader. In this example, Windows is going to be added to grub2.<br />
<br />
To do this, from Arch, mount the Windows system partition and find its UUID:<br />
<br />
mount /dev/sdb1 /mnt<br />
grub-probe --target=fs_uuid /media/EFI/Microsoft/Boot/bootmgfw.efi <br />
<br />
Take note of the output (something like 1ce5-7f28). Now copy the output of:<br />
<br />
grub-probe --target=hints_string /media/EFI/Microsoft/Boot/bootmgfw.efi<br />
<br />
Then, add something like this to /etc/grub.d/0_custom:<br />
<br />
menuentry "Microsoft Windows 8 x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --no-floppy --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1 1ce5-7f28<br />
chainloader /efi/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
Finally generate the grub2 configuration file (grub.cfg):<br />
<br />
grub-mkconfig -o /boot/efi/EFI/grub/grub.cfg<br />
<br />
Now you should be able to see an entry for Windows 8 on grub2.<br />
<br />
The Y580 has a huge 1TB second drive, making it easy to install other OS. With grub2, you can install other distros, and then run grub-mkconfig to add the new entry. To make this easier, install os-prober so that grub2 can find other OS automatically (it does not work for Windows 8):<br />
<br />
pacman -S os-prober<br />
==DISPLAY==<br />
Since the arrival of 3.7.X series kernel, this machine boots into black screen. You will have to add acpi_backlight=vendor to kernel command line to boot into a visible display. You can alternatively increase the screen brightness during every boot also, since the screen brightness is set to 0 wrongly by the kernel acpi by default.<br />
===NVIDIA Card===<br />
<br />
The Y580 uses NVIDIA's Optimus technology, which is not officially supported on Linux yet. A possible solution is to install Bumblebee (https://wiki.archlinux.org/index.php/Bumblebee) and to access the card with optirun. However, you can still use CUDA, which is good if you use apps like Blender or if you develop CUDA C programs.<br />
<br />
===Nvidia Bumblebee support===<br />
In Linux currently [https://wiki.archlinux.org/index.php/Bumblebee bumblebee ] is the easiest option for a optimus like solution. For this laptop you will need bbswitch, Bumblebee, nvidia from official Arch repos. After installation of these packages you will need to add your user name to bumblebee group.You have to start the bumblebeed service manually. A short guide given here [https://wiki.archlinux.org/index.php/Bumblebee#Bumblebee:_Optimus_for_Linux bumblebee].<br />
<br />
===Driver===<br />
<br />
To compile and run CUDA programs, you need a NVIDIA driver and the cuda-toolkit. Any driver with version 295.59 or higher will work.<br />
{{Note|The only exception being the 302.17}}<br />
<br />
As of 10/24/2012, the newest driver is 304.60. To install it, you need a modified version of the package nvidia-utils from extra. The easiest way to do this is to install the package nvidia-utils-custom from the AUR: https://aur.archlinux.org/packages.php?ID=60991. <br />
<br />
Alternatively, you can use ABS and patch the package yourself. If you are not familiar with the process, read the wiki: https://wiki.archlinux.org/index.php/Arch_Build_System. The exact way to rebuild a package depends on your own preferences, one way is to download the source code (in this case, the driver, obtained here: ftp://download.nvidia.com/XFree86/Linux-x86_64/304.60/NVIDIA-Linux-x86_64-304.60-no-compat32.run), copy it to the build directory, edit the PKGBUILD, and then run makepkg. <br />
<br />
Edit the PKGBUILD of nvidia-utils. You may need to change the pkgver, the source item, and the md5sum. The most important thing is that nvidia-utils conflicts with libgl, but if you uninstall libgl, Gnome only starts in fallback mode (not sure about other DE). Because of this, you need to modify the PKGBUILD, so that it either does not install certain libraries (libglx.so, libGL.so) or that it installs them in another location. With the PKGBUILD below, those libraries are not installed (note the commented lines for the GLX extension module, and the empty 'conflicts' line).<br />
<br />
===nvidia-utils PKGBUILD===<br />
{{bc|<nowiki><br />
# $Id$<br />
# Maintainer: Thomas Baechler <thomas@archlinux.org><br />
# Contributor: James Rayner <iphitus@gmail.com><br />
pkgbase=nvidia-utils<br />
pkgname=('nvidia-utils' 'opencl-nvidia')<br />
pkgver=304.60<br />
pkgrel=1<br />
arch=('i686' 'x86_64')<br />
url="http://www.nvidia.com/"<br />
license=('custom')<br />
options=('!strip')<br />
<br />
if [ "$CARCH" = "i686" ]; then<br />
_arch='x86'<br />
_pkg="NVIDIA-Linux-${_arch}-${pkgver}"<br />
source=("ftp://download.nvidia.com/XFree86/Linux-${_arch}/${pkgver}/${_pkg}.run")<br />
md5sums=('42b9887076b2ebcf1af5ee13bc332ccb')<br />
elif [ "$CARCH" = "x86_64" ]; then<br />
_arch='x86_64'<br />
_pkg="NVIDIA-Linux-${_arch}-${pkgver}-no-compat32"<br />
source=("ftp://download.nvidia.com/XFree86/Linux-${_arch}/${pkgver}/${_pkg}.run")<br />
md5sums=('7248399a125808e3bbc9c66da99a098d')<br />
fi<br />
<br />
create_links() {<br />
# create soname links<br />
while read -d '' _lib; do<br />
_soname="$(dirname "${_lib}")/$(readelf -d "${_lib}" | sed -nr 's/.*Library soname: \[(.*)\].*/\1/p')"<br />
[[ -e "${_soname}" ]] || ln -s "$(basename "${_lib}")" "${_soname}"<br />
[[ -e "${_soname/.[0-9]*/}" ]] || ln -s "$(basename "${_soname}")" "${_soname/.[0-9]*/}"<br />
done < <(find "${pkgdir}" -type f -name '*.so*' -print0)<br />
}<br />
<br />
build() {<br />
cd "${srcdir}"<br />
sh "${_pkg}.run" --extract-only<br />
}<br />
<br />
package_opencl-nvidia() {<br />
pkgdesc="OpenCL implemention for NVIDIA"<br />
depends=('libcl' 'zlib')<br />
optdepends=('opencl-headers: headers necessary for OpenCL development')<br />
cd "${srcdir}/${_pkg}"<br />
<br />
# OpenCL<br />
install -D -m644 nvidia.icd "${pkgdir}/etc/OpenCL/vendors/nvidia.icd"<br />
install -D -m755 "libnvidia-compiler.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-compiler.so.${pkgver}"<br />
install -D -m755 "libnvidia-opencl.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-opencl.so.${pkgver}"<br />
<br />
create_links<br />
}<br />
<br />
package_nvidia-utils() {<br />
pkgdesc="NVIDIA drivers utilities and libraries."<br />
depends=('xorg-server' 'libxvmc')<br />
optdepends=('gtk2: nvidia-settings' 'pkg-config: nvidia-xconfig'<br />
'opencl-nvidia: OpenCL support')<br />
conflicts=('')<br />
provides=('libgl')<br />
cd "${srcdir}/${_pkg}"<br />
<br />
# X driver<br />
install -D -m755 nvidia_drv.so "${pkgdir}/usr/lib/xorg/modules/drivers/nvidia_drv.so"<br />
# GLX extension module for X<br />
#install -D -m755 "libglx.so.${pkgver}" "${pkgdir}/usr/lib/xorg/modules/extensions/libglx.so.${pkgver}"<br />
#ln -s "libglx.so.${pkgver}" "${pkgdir}/usr/lib/xorg/modules/extensions/libglx.so" # X does not find glx otherwise<br />
# OpenGL library<br />
#install -D -m755 "libGL.so.${pkgver}" "${pkgdir}/usr/lib/libGL.so.${pkgver}"<br />
# OpenGL core library<br />
install -D -m755 "libnvidia-glcore.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-glcore.so.${pkgver}"<br />
# XvMC<br />
install -D -m644 libXvMCNVIDIA.a "${pkgdir}/usr/lib/libXvMCNVIDIA.a"<br />
install -D -m755 "libXvMCNVIDIA.so.${pkgver}" "${pkgdir}/usr/lib/libXvMCNVIDIA.so.${pkgver}"<br />
# VDPAU<br />
install -D -m755 "libvdpau_nvidia.so.${pkgver}" "${pkgdir}/usr/lib/vdpau/libvdpau_nvidia.so.${pkgver}"<br />
# nvidia-tls library<br />
install -D -m755 "tls/libnvidia-tls.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-tls.so.${pkgver}"<br />
install -D -m755 "libnvidia-cfg.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-cfg.so.${pkgver}"<br />
<br />
install -D -m755 "libnvidia-ml.so.${pkgver}" "${pkgdir}/usr/lib/libnvidia-ml.so.${pkgver}"<br />
# CUDA<br />
install -D -m755 "libcuda.so.${pkgver}" "${pkgdir}/usr/lib/libcuda.so.${pkgver}"<br />
install -D -m755 "libnvcuvid.so.${pkgver}" "${pkgdir}/usr/lib/libnvcuvid.so.${pkgver}"<br />
<br />
# nvidia-xconfig<br />
install -D -m755 nvidia-xconfig "${pkgdir}/usr/bin/nvidia-xconfig"<br />
install -D -m644 nvidia-xconfig.1.gz "${pkgdir}/usr/share/man/man1/nvidia-xconfig.1.gz"<br />
# nvidia-settings<br />
install -D -m755 nvidia-settings "${pkgdir}/usr/bin/nvidia-settings"<br />
install -D -m644 nvidia-settings.1.gz "${pkgdir}/usr/share/man/man1/nvidia-settings.1.gz"<br />
install -D -m644 nvidia-settings.desktop "${pkgdir}/usr/share/applications/nvidia-settings.desktop"<br />
install -D -m644 nvidia-settings.png "${pkgdir}/usr/share/pixmaps/nvidia-settings.png"<br />
sed -e 's:__UTILS_PATH__:/usr/bin:' -e 's:__PIXMAP_PATH__:/usr/share/pixmaps:' -i "${pkgdir}/usr/share/applications/nvidia-settings.desktop"<br />
# nvidia-bug-report<br />
install -D -m755 nvidia-bug-report.sh "${pkgdir}/usr/bin/nvidia-bug-report.sh"<br />
# nvidia-smi<br />
install -D -m755 nvidia-smi "${pkgdir}/usr/bin/nvidia-smi"<br />
install -D -m644 nvidia-smi.1.gz "${pkgdir}/usr/share/man/man1/nvidia-smi.1.gz"<br />
<br />
install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/nvidia/LICENSE"<br />
ln -s nvidia "${pkgdir}/usr/share/licenses/nvidia-utils"<br />
install -D -m644 README.txt "${pkgdir}/usr/share/doc/nvidia/README"<br />
install -D -m644 NVIDIA_Changelog "${pkgdir}/usr/share/doc/nvidia/NVIDIA_Changelog"<br />
ln -s nvidia "${pkgdir}/usr/share/doc/nvidia-utils"<br />
<br />
create_links<br />
}<br />
<br />
</nowiki>}}<br />
<br />
It is not necessary to patch other packages. If you want, you can also install nvidia-custom (https://aur.archlinux.org/packages.php?ID=60981) and opencl-nvidia-custom (https://aur.archlinux.org/packages.php?ID=61443) from the AUR, but they are not much different from the official ones (nvidia and opencl-nvidia from extra).<br />
<br />
If you rebuild nvidia-utils yourself, you may want to add it to the IgnorePkg line of your /etc/pacman.conf, so that the next system update does not break your system.<br />
<br />
===CUDA Toolkit===<br />
<br />
Install the package from community (https://www.archlinux.org/packages/community/x86_64/cuda/).<br />
<br />
===Configurations===<br />
<br />
Since Linux 3.9, the acpi-handle-hack module is no longer necessary for the Nvidia video adapter to get recognized. Depending on your system, just loading the nvidia module may be enough, but it may be necessary to create devices for CUDA. One way to accomplish this is to add the following to your /etc/rc.local:<br />
<br />
{{bc|<nowiki><br />
/sbin/modprobe nvidia<br />
<br />
if [ "$?" -eq 0 ]; then<br />
<br />
# Count the number of NVIDIA controllers found.<br />
<br />
N3D=`lspci | grep -i NVIDIA | grep "3D controller" | wc -l`<br />
<br />
NVGA=`lspci | grep -i NVIDIA | grep "VGA compatible controller" | wc -l`<br />
<br />
N=`expr $N3D + $NVGA - 1`<br />
<br />
for i in `seq 0 $N`; do<br />
mknod -m 666 /dev/nvidia$i c 195 $i<br />
done<br />
<br />
mknod -m 666 /dev/nvidiactl c 195 255<br />
else<br />
exit 1<br />
fi<br />
</nowiki>}}<br />
<br />
If you are using systemd, you can get the /etc/rc.local loaded at boot by adding a new service. Create the following file:<br />
<br />
{{bc|1=<br />
#/etc/systemd/system/rc-local.service<br />
<br />
[Unit]<br />
Description=/etc/rc.local Compatibility<br />
<br />
[Service]<br />
Type=oneshot<br />
ExecStart=/etc/rc.local<br />
TimeoutSec=0<br />
StandardInput=tty<br />
RemainAfterExit=yes<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
Then make this service load at boot with:<br />
<br />
systemctl enable rc-local.service<br />
<br />
===Testing it===<br />
The cuda package includes both the cuda-toolkit and sdk. Before testing it, reboot and it should be working. To compile and run deviceQuery from the sdk:<br />
<br />
cd /opt/cuda/samples/1_Utilities/deviceQuery<br />
make<br />
./deviceQuery<br />
<br />
Alternatively, you can compile your own code and run it. To compile, say hello.cu, use:<br />
<br />
nvcc hello.cu<br />
<br />
Now you can run the executable:<br />
<br />
./a.out<br />
<br />
If this works without errors, you are all set!<br />
<br />
== Fan control ==<br />
Recent kernels support ideapad platform features, such as <b>fan mode</b> and <b> webcam powerstate </b>. You can access these via <i>/sys</i> interface:<br />
<br />
/sys/devices/platform/ideapad<br />
<br />
fan currently supports 4 modes:<br />
<br />
{| border="1"<br />
! Mode !! Value<br />
|-<br />
| Silent || 0<br />
|-<br />
| Default || 1<br />
|-<br />
| Dustclean || 2<br />
|-<br />
| Effective cooling || 4<br />
|}<br />
<br />
# echo 0 > /sys/devices/platform/ideapad/fan_mode<br />
<br />
Note: root privilegues are needed, either use sudo or userspace tool ideapad-tools from https://github.com/tpruzina/ideapad-tools [requires compiler to build the tool].<br />
Consider adding 'ideapad-client --fan quiet' to your startup.</div>AoeAoe