Notes
3. Linux installation and package management
Content of the notes (2)
Page 1
Linux Hard Disk Layout
/usr - user binaries are stored when packages are installed.
/home - user's home directory lives where user can store their own files.
/boot - where the boot loader and all the images required for booting live.
/var - where all the variable data like log, etc. lives
/tmp - unique storage area where anyone can write to.
Partitions
Divide storage into multiple pieces
Allows dual booting
separation of files. System on one paritions and backup on some other partition
Data organization. Keeping work and home files in different places
System protection with partitions
create partitions
moount them to directories
We can mount to:
.home
/var
/tmp
/home/nick/blah
You can even mount a partition over a directory already consisting of some files. So, after mounting, the previous existing files of that directory will be hidden and only the ones corresponding to the partition being mounted will be there.
When you un-mount the partition from that directory, the previous files will be back.
Swap partition
This is used when the physical memory or RAM is full. When system needs more memory, then inactive pages in your memory are moved to swap partition to free up more memory to work with.
LVM
Logical volume manager
split disks into pools
create partitions from pools
can grow or shrink partitions
Page 2
Install a boot manager
Boot loader
Boots a linux system
Runs before the operating system
can be configured from the operating system
Common boot loaders - LILO (Linux Loader), GRUB Legacy, GRUB 2
grub probe - lets you probe device information for grub
grub probe --version - provides the version of grub
grub install --version - produces the same output
cd /boot
ls
we can see a few linux kernels, few config files, initrd images and the grub directory here
So,
cd /grub
ls
our main configuration file here is grub.cfg. This can vary from system to system.
So, in grub legacy, it was "menu.lst" and it has also been known as grub.conf"
However most systems have standardized to use grub.cfg
less.cfg
You locate in this file, the code responsible for differnet options like advanced options for linux.
cd /etc/grub.d
ls
these are the scripts used to generate grub.cfg
Now, to deal with the default configuration/options pf GRUB,
edit the /etc/default/grub file
So, update this file accordingly and run the command update-grub
Now, to know what exactly update-grub does, firstly let's find where does the binary for the update-grub command lie
enter
which update-grub
This will output the path to update-grub
then, execute the following command to check out the script behind update-grub
cat /usr/bin/update-grub
Now, reboot and you will see the update
There is one more thing you can do directly from GRUB. So, change the default target/run level directly from grub.
So, when grub is open, enter "e" to enter commnd line mode.
There will open up a script.
Now, go to the line near the bottom starting with "linux" and at the end of that line, enter this
systemd.unit=rescue.target
This would set the default target to rescue target.
Then, press F10 to boot and you'll be booted, as expected, into rescue mode.
Rescue mode is useful if you system fails to load due to some reason. In rescue mode, some basic services are loaded and then, you are just given terminal access. So, then you can login as root and repair your system with command line.
fter the required reparation, you can execute the reboot command or press Ctrl-D to straight away reboot to normal mode.
Had grub not been installed for you and you had the grub config file ready, we would have to install grub to master boot record. So, for that, execute this,
grub install /dev/sda (/dev/sda is your harddisk where grub will be installed)
Information
- Description
- Computer Science Note on 3. Linux installation and package management, created by Yashvardhan Kukreja on 22/06/2020.
- Created by
- Yashvardhan Kukreja · Jun 2020
- Updated
- Jun 24, 2020
- Views
- 0
- Rating