wok view linux/stuff/linux-subroot.u @ rev 14760

linux: add boot subroot support (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jun 19 11:55:19 2013 +0200 (2013-06-19)
parents 1472150d52c4
children c6e93d1e6bac
line source
1 Allow to boot on any directories in a filesystem. You will be able to :
2 - have several distributions in one partition
3 - use efficently the disk space between several distributions
4 - deduplicate files across several distributions
5 - test new configurations
6 ...
7 --- linux-3.2.40/Documentation/kernel-parameters.txt
8 +++ linux-3.2.40/Documentation/kernel-parameters.txt
9 @@ -2304,8 +2304,9 @@
11 ro [KNL] Mount root device read-only on boot
13 - root= [KNL] Root filesystem
14 + root= [KNL] Root filesystem and root directory
15 See name_to_dev_t comment in init/do_mounts.c.
16 + Format: <root_filesystem>[:root_directory]
18 rootdelay= [KNL] Delay (in seconds) to pause before attempting to
19 mount the root filesystem
20 --- linux-3.2.40/init/do_mounts.c
21 +++ linux-3.2.40/init/do_mounts.c
22 @@ -28,6 +28,7 @@
23 int root_mountflags = MS_RDONLY | MS_SILENT;
24 static char * __initdata root_device_name;
25 static char __initdata saved_root_name[64];
26 +static char __initdata saved_root_directory[256];
27 static int root_wait;
29 dev_t ROOT_DEV;
30 @@ -255,7 +256,20 @@
32 static int __init root_dev_setup(char *line)
33 {
34 + char *s;
35 +
36 + strcpy(saved_root_directory, ".");
37 strlcpy(saved_root_name, line, sizeof(saved_root_name));
38 + s = strchr(saved_root_name, ':');
39 + if (s) {
40 + *s = '\0';
41 + s = strchr(line, ':');
42 + for (s++; *s == '/'; s++);
43 + if (*s) {
44 + strlcpy(saved_root_directory, s,
45 + sizeof(saved_root_directory));
46 + }
47 + }
48 return 1;
49 }
51 @@ -554,5 +568,5 @@
52 out:
53 devtmpfs_mount("dev");
54 sys_mount(".", "/", NULL, MS_MOVE, NULL);
55 - sys_chroot((const char __user __force *)".");
56 + sys_chroot((const char __user __force *)saved_root_directory);
57 }