My Blog

Recording Technology and Life

Increasing the disk size in your VM settings (VMware/VirtualBox) is only half the battle. The OS won’t automatically use that extra space until you manually update the partition table and the filesystem.

Here is a quick guide on how I expanded my /dev/sda2 partition from 30GB to 40GB without losing any data.

The Problem

After increasing the virtual disk to 40GB, running lsblk showed that the physical disk (sda) was 40GB, but the primary partition (sda2) was still stuck at 30GB.

1
2
3
# Output snippet
sda 8:0 0 40G 0 disk
└─sda2 8:2 0 30G 0 part /

阅读全文 »

Task 1: Modify a Dummy Read-Only File

1. create a dummy file

we can see that if we try to write to this file as a normal user, we will fail, because the file is only readable to normal users.

阅读全文 »

Task 1: Create and Install a Kernel Module

simple_module.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* simple_module.c */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/io.h>

static int __init simple_module_init(void)
{
printk("Helloworld.\n");
return 0;
}
/*
*The cleanup function of the module.
*/
static void __exit simple_module_exit(void)
{
printk(KERN_INFO"Exit.\n");
}
module_init(simple_module_init);
module_exit(simple_module_exit);

阅读全文 »

Exercise 1: Consider the following grammar G, which you have seen in the previous assignment:

1
2
3
4
5
6
7
E -> TX
X -> +E | ε
T -> FY
Y -> T | ε
F -> PZ
Z -> *Z | ε
P -> (E) | a | b

1. Please construct the SLR parsing table for G. Is the grammar SLR(1)?

(Non-Terminal) FIRST Set FOLLOW Set
E {(,a, b} {$, )}
T {(,a, b} {$, ), +}
X {ε, +} {$, )}
F {(,a, b} {$, (,), +, a, b}
Y {ε, (,a, b} {$, ), +}
P {(,a, b} {$, (,), *, +, a, b}
Z {ε, *} {$, (,), +, a, b}
阅读全文 »
0%