Wiki source code of Ubuntu Linux

Last modified by Sebastian Marsching on 2024/06/17 16:05

Hide last authors
Sebastian Marsching 1.1 1 {{toc/}}
2
Sebastian Marsching 10.1 3 # Moving /var
Sebastian Marsching 1.1 4
Sebastian Marsching 10.1 5 After moving `/var` to a separate partition, Ubuntu will not boot anymore. This is caused by Ubuntu needing the directories `/var/run` and `/var/lock` **before** `/var` is mounted. The solution is simple: Just create `/var/run` and `/var/lock` on the root partition and Ubuntu will boot again.
Sebastian Marsching 1.1 6
Sebastian Marsching 10.1 7 # Installing the Developer Tools
Sebastian Marsching 1.1 8
Sebastian Marsching 10.1 9 The basic developer tools (e.g. C compiler) can be installed by installing the virtual `build-essentials` package.
Sebastian Marsching 1.1 10
Sebastian Marsching 10.1 11 # Switching from MBR to GPT and UEFI Boot
Sebastian Marsching 1.1 12
13 In this scenario, we have a harddisk that is formatted with an MBR and has Windows 7 and Linux installed on it. We want to change this to GPT (and hence to UEFI).
14
15 As far as I can tell, there is no feasible way to convert Windows to GPT and UEFI boot without reinstalling it. In my case this was fine, because major parts of the computer's hardware (mainboard and CPU) had been changed and Windows does not handle these kind of changes well anyway. So here is the step by step process that worked for me:
16
Sebastian Marsching 12.1 17 Be sure to make a backup of your computer's harddisk. As part of this process some data has to be deleted and there also is a chance to lose more data, because something goes wrong.
Sebastian Marsching 11.1 18
Sebastian Marsching 12.1 19 Boot from the Ubuntu 12.04 LTS Desktop CD (64-bit). Make sure to boot in UEFI mode. You can either disable PC-BIOS mode in your computer's boot setting or select the UEFI mode in the computer's boot select menu. How to do this strongly depends on your computer's mainboard.
Sebastian Marsching 11.1 20
Sebastian Marsching 12.1 21 Add the Universe repository to the software sources and install `gdisk`. Probably it is a good idea to make a backup of your harddisk's MBR using `dd`. For the rest of this guide we assume that your disk drive is `/dev/sda`. So run `sudo gdisk /dev/sda`. `gdisk` will automatically [convert your disk from MBR to GPT](http://www.rodsbooks.com/gdisk/mbr2gpt.html), keeping the partitions (if possible). Now you have to delete the Windows "reserved" and system partitions. Typically, these are the first two partitions on the disk. Now exit `gdisk` saving the changes.
Sebastian Marsching 11.1 22
Sebastian Marsching 12.1 23 Shutdown the Ubuntu system and boot from the Windows 7 installation DVD (in UEFI mode). The Windows 7 installer can automatically create the needed partitions in the free area of the disk, that you created by deleting the Windows partitions earlier. It will create three partitions: Two special ones mainly needed for booting and a regular one for the Windows system partition.
Sebastian Marsching 11.1 24
Sebastian Marsching 12.1 25 When the installer rebooted, I got a funny error every time I tried to boot from the harddisk. I got a blue screen with an error code of 0xc0000225. After some time I [figured](http://forums.anandtech.com/showthread.php?t=2260563) [out](http://www.computerbase.de/forum/showthread.php?t=1152436) that this was caused by the second harddisk in the computer being formatted using MBR. After converting this disk to GPT, everything worked smoothly. Windows is supposed to support mixed GPT and MBR disks in the same system, however in some causes it seems to cause trouble.
Sebastian Marsching 11.1 26
Sebastian Marsching 12.1 27 After the Windows installation has finished, we can boot back into Ubuntu using the Ubuntu 12.04 LTS Desktop CD. Again, we have to boot in UEFI mode.
Sebastian Marsching 11.1 28
Sebastian Marsching 12.1 29 We have to change to the target system by mounting all required partitions and chrooting to the target system. How to do this exactly depends on your system layout. In my case, I had the boot partition on /dev/sda4 and all other partitions in LVM. Therefore, I first installed the `lvm2` package, activated the volume group `vg0` with `vgchange -a y vg0` and mounted all required filesystems with the commands
Sebastian Marsching 13.1 30
Sebastian Marsching 12.1 31 ```bash
32 sudo mount /dev/vg0/root /mnt
33 sudo mount /dev/vg0/home /mnt/home
34 sudo mount /dev/sda4 /mnt/boot
35 sudo mkdir /mnt/boot/efi
36 sudo mount /dev/sda1 /mnt/boot/efi
37 sudo mount -o bind /dev /mnt/dev
38 sudo mount -o bind /dev/pts /mnt/dev/pts
39 sudo mount -o bind /proc /mnt/proc
40 sudo mount -o bind /run /mnt/run
41 sudo mount -o bind /sys /mnt/sys
42 ```
Sebastian Marsching 13.1 43
Sebastian Marsching 12.1 44 In this example the system's ESP (this is the partition where the EFI boot-loaders are stored) has been created by the Windows setup as `/dev/sda1`.
Sebastian Marsching 11.1 45
Sebastian Marsching 12.1 46 Now we can change into the target system:
Sebastian Marsching 13.1 47
Sebastian Marsching 12.1 48 ```
49 sudo su -
50 chroot /mnt
51 ```
Sebastian Marsching 11.1 52
Sebastian Marsching 12.1 53 You should make a backup of the GRUB configuration files before proceeding. The relevant files are in `/boot/grub`, `/etc/default/grub` and `/etc/grub.d`.
Sebastian Marsching 11.1 54
Sebastian Marsching 12.1 55 Now you should purge all GRUB packages. You can usually do this by running `aptitude purge "?name(grub-)" "?name(grub2-)"`.
Sebastian Marsching 11.1 56
Sebastian Marsching 12.1 57 Next you should delete all remaining GRUB files (`/boot/grub`, `/etc/default/grub` and `/etc/grub.d`). Then you should create a symbollink in `/boot` that points to the install location of GRUB in the ESP: `ln -s efi/EFI/grub /boot/grub`.
Sebastian Marsching 11.1 58
Sebastian Marsching 12.1 59 After that you can install the EFI version of GRUB: `aptitude install grub-efi`.
Sebastian Marsching 11.1 60
Sebastian Marsching 12.1 61 In the target system, we have to edit `/etc/fstab` and add an entry for the ESP. You can find out the UUID of the partition by running `grub-probe --target=fs_uuid /boot/efi`. Then add a line like
Sebastian Marsching 13.1 62
Sebastian Marsching 12.1 63 ```
64 UUID=<UUID> /boot/efi vfat defaults 0 1
65 ```
Sebastian Marsching 13.1 66
Sebastian Marsching 12.1 67 to your /etc/fstab (of course you have to replace `<UUID>` by the UUID printed by `grub-probe`.
Sebastian Marsching 11.1 68
Sebastian Marsching 12.1 69 Now we install GRUB with `grub-install --boot-directory=/boot/efi/EFI --bootloader-id=grub --no-floppy --recheck` (I got this from [another guide](http://thinkpad-forum.de/threads/123262-EFI-Grub2-Multiboot-HowTo)).
Sebastian Marsching 11.1 70
Sebastian Marsching 12.1 71 You might have to edit `/etc/default/grub` to suit your needs. I disabled the OS prober (because it does not detect the UEFI Windows loader anyway but found some old systems on my second harddisk) by adding `GRUB_DISABLE_OS_PROBER="true"`. I also changed `GRUB_HIDDEN_TIMEOUT` to the empty string and `GRUB_HIDDEN_TIMEOUT_QUIET` to `false`. This was needed because the OS prober was disabled and thus GRUB would not show the boot menu by default any longer (the same would happen if OS prober was enabled but it did not find other operating systems).
Sebastian Marsching 11.1 72
Sebastian Marsching 12.1 73 Because memtest86+ was installed on the system, I had to copy the file `20_memtest86+` from the backup of the GRUB configuration files back to `/etc/grub.d`.
Sebastian Marsching 11.1 74
Sebastian Marsching 12.1 75 In order to be able to boot Windows 7 from GRUB (using the boot menu of the EFI BIOS is inconvenient), I added an extra entry to `/etc/grub.d/40_custom` (as describe in the [Ubuntu Community Wiki](https://help.ubuntu.com/community/UEFIBooting#Chainloading_Windows_x86_64_UEFI-GPT)):
Sebastian Marsching 13.1 76
Sebastian Marsching 12.1 77 ```
78 menuentry "Windows 7 (UEFI)" {
79 search -fs-uuid --no-floppy --set=root <UUID>
80 chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
81 }
82 ```
Sebastian Marsching 13.1 83
Sebastian Marsching 12.1 84 In this example `<UUID>` again has to be replaced by the UUID of the ESP.
Sebastian Marsching 11.1 85
Sebastian Marsching 12.1 86 In order to generate the GRUB configuration file, `update-grub` needs to be run.
Sebastian Marsching 11.1 87
Sebastian Marsching 12.1 88 Finally, GRUB has to be registered in the EFI settings. This can be done by running `efibootmgr --create --gpt --disk /dev/sda --part 1 --write-signature --label "GRUB" --loader "\\EFI\\grub\\grub.efi"`.
Sebastian Marsching 11.1 89
Sebastian Marsching 12.1 90 After finishing these steps, you can leave the target system and unmount all partitions. Finally, reboot the computer and select GRUB from the computer's boot menu. Now you should see the normal GRUB screen, where you can select to boot Linux or Windows.
Sebastian Marsching 5.1 91
Sebastian Marsching 10.1 92 # Configuring the Vino VNC server on Ubuntu Desktop
Sebastian Marsching 5.1 93
Sebastian Marsching 10.1 94 ## Allowing access from localhost only
Sebastian Marsching 5.1 95
Sebastian Marsching 10.1 96 ```bash
Sebastian Marsching 5.1 97 gsettings set org.gnome.Vino network-interface lo
Sebastian Marsching 10.1 98 ```
Sebastian Marsching 5.1 99
100 This is perfect if there is only a single user on the machine because this way, a SSH tunnel can provide sufficient access restrictions.
101
Sebastian Marsching 10.1 102 ## Fixing problems with some VNC clients
Sebastian Marsching 5.1 103
Sebastian Marsching 10.1 104 Since Ubuntu 14.04 LTS, some (older) clients cannot connect. This seems to be caused by the use of TLS in the VNC server. This feature can be disabled (see [bug #1290666](https://bugs.launchpad.net/ubuntu/+source/vino/+bug/1290666)):
Sebastian Marsching 5.1 105
Sebastian Marsching 10.1 106 ```bash
Sebastian Marsching 5.1 107 gsettings set org.gnome.Vino require-encryption false
Sebastian Marsching 10.1 108 ```
Sebastian Marsching 5.1 109
Sebastian Marsching 10.1 110 ## Find packages that have been removed but not purged
Sebastian Marsching 5.1 111
Sebastian Marsching 10.1 112 ```bash
Sebastian Marsching 5.1 113 aptitude search "?config-files"
Sebastian Marsching 10.1 114 ```
Sebastian Marsching 13.1 115
Sebastian Marsching 14.1 116 # Troubleshooting
Sebastian Marsching 13.1 117
Sebastian Marsching 14.1 118 ## Graphics server not starting after Upgrade to Ubuntu 22.04
119
Sebastian Marsching 13.1 120 If the graphics server (X11 / Wayland) is not starting on a system with a NVIDIA graphics card (in particular an older one – in my case it was a GeForce 210), this might be caused by the switch from the proprietary NVIDIA driver to Nouveau, without some files of the proprietary NVIDIA driver having been removed correctly.
121
122 Support for the old 340 version of the NVIDIA driver ended a while ago, so this version of the driver has been removed from Ubuntu 22.04. However, if this driver used to be install in Ubuntu 20.04 before the upgrade, it might still be installed after the upgrade and thus the configuration file `/etc/modprobe.d/nvidia-340_hybrid.conf` might still exist. This file will keep the open-source Nouveau driver from being loaded. This can typically be fixed by running `apt-get purge nvidia-340`.