diff options
Diffstat (limited to 'usr')
-rw-r--r-- | usr/Kconfig | 101 | ||||
-rw-r--r-- | usr/Makefile | 36 | ||||
-rw-r--r-- | usr/initramfs_data.S | 2 | ||||
-rw-r--r-- | usr/initramfs_data.bz2.S | 29 | ||||
-rw-r--r-- | usr/initramfs_data.gz.S | 29 | ||||
-rw-r--r-- | usr/initramfs_data.lzma.S | 29 |
6 files changed, 213 insertions, 13 deletions
diff --git a/usr/Kconfig b/usr/Kconfig index 86cecb59dd07..588c588791e2 100644 --- a/usr/Kconfig +++ b/usr/Kconfig | |||
@@ -44,3 +44,104 @@ config INITRAMFS_ROOT_GID | |||
44 | owned by group root in the initial ramdisk image. | 44 | owned by group root in the initial ramdisk image. |
45 | 45 | ||
46 | If you are not sure, leave it set to "0". | 46 | If you are not sure, leave it set to "0". |
47 | |||
48 | config RD_GZIP | ||
49 | bool "Support initial ramdisks compressed using gzip" if EMBEDDED | ||
50 | default y | ||
51 | depends on BLK_DEV_INITRD | ||
52 | select DECOMPRESS_GZIP | ||
53 | help | ||
54 | Support loading of a gzip encoded initial ramdisk or cpio buffer. | ||
55 | If unsure, say Y. | ||
56 | |||
57 | config RD_BZIP2 | ||
58 | bool "Support initial ramdisks compressed using bzip2" if EMBEDDED | ||
59 | default !EMBEDDED | ||
60 | depends on BLK_DEV_INITRD | ||
61 | select DECOMPRESS_BZIP2 | ||
62 | help | ||
63 | Support loading of a bzip2 encoded initial ramdisk or cpio buffer | ||
64 | If unsure, say N. | ||
65 | |||
66 | config RD_LZMA | ||
67 | bool "Support initial ramdisks compressed using LZMA" if EMBEDDED | ||
68 | default !EMBEDDED | ||
69 | depends on BLK_DEV_INITRD | ||
70 | select DECOMPRESS_LZMA | ||
71 | help | ||
72 | Support loading of a LZMA encoded initial ramdisk or cpio buffer | ||
73 | If unsure, say N. | ||
74 | |||
75 | if INITRAMFS_SOURCE!="" | ||
76 | |||
77 | choice | ||
78 | prompt "Built-in initramfs compression mode" | ||
79 | help | ||
80 | This option decides by which algorithm the builtin initramfs | ||
81 | will be compressed. Several compression algorithms are | ||
82 | available, which differ in efficiency, compression and | ||
83 | decompression speed. Compression speed is only relevant | ||
84 | when building a kernel. Decompression speed is relevant at | ||
85 | each boot. | ||
86 | |||
87 | If you have any problems with bzip2 or LZMA compressed | ||
88 | initramfs, mail me (Alain Knaff) <alain@knaff.lu>. | ||
89 | |||
90 | High compression options are mostly useful for users who are | ||
91 | low on RAM, since it reduces the memory consumption during | ||
92 | boot. | ||
93 | |||
94 | If in doubt, select 'gzip' | ||
95 | |||
96 | config INITRAMFS_COMPRESSION_NONE | ||
97 | bool "None" | ||
98 | help | ||
99 | Do not compress the built-in initramfs at all. This may | ||
100 | sound wasteful in space, but, you should be aware that the | ||
101 | built-in initramfs will be compressed at a later stage | ||
102 | anyways along with the rest of the kernel, on those | ||
103 | architectures that support this. | ||
104 | However, not compressing the initramfs may lead to slightly | ||
105 | higher memory consumption during a short time at boot, while | ||
106 | both the cpio image and the unpacked filesystem image will | ||
107 | be present in memory simultaneously | ||
108 | |||
109 | config INITRAMFS_COMPRESSION_GZIP | ||
110 | bool "Gzip" | ||
111 | depends on RD_GZIP | ||
112 | help | ||
113 | The old and tried gzip compression. Its compression ratio is | ||
114 | the poorest among the 3 choices; however its speed (both | ||
115 | compression and decompression) is the fastest. | ||
116 | |||
117 | config INITRAMFS_COMPRESSION_BZIP2 | ||
118 | bool "Bzip2" | ||
119 | depends on RD_BZIP2 | ||
120 | help | ||
121 | Its compression ratio and speed is intermediate. | ||
122 | Decompression speed is slowest among the three. The initramfs | ||
123 | size is about 10% smaller with bzip2, in comparison to gzip. | ||
124 | Bzip2 uses a large amount of memory. For modern kernels you | ||
125 | will need at least 8MB RAM or more for booting. | ||
126 | |||
127 | config INITRAMFS_COMPRESSION_LZMA | ||
128 | bool "LZMA" | ||
129 | depends on RD_LZMA | ||
130 | help | ||
131 | The most recent compression algorithm. | ||
132 | Its ratio is best, decompression speed is between the other | ||
133 | two. Compression is slowest. The initramfs size is about 33% | ||
134 | smaller with LZMA in comparison to gzip. | ||
135 | |||
136 | endchoice | ||
137 | |||
138 | endif | ||
139 | |||
140 | if INITRAMFS_SOURCE="" | ||
141 | # The builtin initramfs is so small so we don't want to bug the user... | ||
142 | |||
143 | config INITRAMFS_COMPRESSION_NONE | ||
144 | bool | ||
145 | default y | ||
146 | |||
147 | endif | ||
diff --git a/usr/Makefile b/usr/Makefile index 201f27f8cbaf..b84894b3929d 100644 --- a/usr/Makefile +++ b/usr/Makefile | |||
@@ -6,13 +6,25 @@ klibcdirs:; | |||
6 | PHONY += klibcdirs | 6 | PHONY += klibcdirs |
7 | 7 | ||
8 | 8 | ||
9 | # No compression | ||
10 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_NONE) = | ||
11 | |||
12 | # Gzip, but no bzip2 | ||
13 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz | ||
14 | |||
15 | # Bzip2 | ||
16 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2 | ||
17 | |||
18 | # Lzma | ||
19 | suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma | ||
20 | |||
9 | # Generate builtin.o based on initramfs_data.o | 21 | # Generate builtin.o based on initramfs_data.o |
10 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o | 22 | obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o |
11 | 23 | ||
12 | # initramfs_data.o contains the initramfs_data.cpio.gz image. | 24 | # initramfs_data.o contains the compressed initramfs_data.cpio image. |
13 | # The image is included using .incbin, a dependency which is not | 25 | # The image is included using .incbin, a dependency which is not |
14 | # tracked automatically. | 26 | # tracked automatically. |
15 | $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE | 27 | $(obj)/initramfs_data$(suffix_y).o: $(obj)/initramfs_data.cpio$(suffix_y) FORCE |
16 | 28 | ||
17 | ##### | 29 | ##### |
18 | # Generate the initramfs cpio archive | 30 | # Generate the initramfs cpio archive |
@@ -25,28 +37,28 @@ ramfs-args := \ | |||
25 | $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ | 37 | $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \ |
26 | $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) | 38 | $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID)) |
27 | 39 | ||
28 | # .initramfs_data.cpio.gz.d is used to identify all files included | 40 | # .initramfs_data.cpio.d is used to identify all files included |
29 | # in initramfs and to detect if any files are added/removed. | 41 | # in initramfs and to detect if any files are added/removed. |
30 | # Removed files are identified by directory timestamp being updated | 42 | # Removed files are identified by directory timestamp being updated |
31 | # The dependency list is generated by gen_initramfs.sh -l | 43 | # The dependency list is generated by gen_initramfs.sh -l |
32 | ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),) | 44 | ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),) |
33 | include $(obj)/.initramfs_data.cpio.gz.d | 45 | include $(obj)/.initramfs_data.cpio.d |
34 | endif | 46 | endif |
35 | 47 | ||
36 | quiet_cmd_initfs = GEN $@ | 48 | quiet_cmd_initfs = GEN $@ |
37 | cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) | 49 | cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) |
38 | 50 | ||
39 | targets := initramfs_data.cpio.gz | 51 | targets := initramfs_data.cpio.gz initramfs_data.cpio.bz2 initramfs_data.cpio.lzma initramfs_data.cpio |
40 | # do not try to update files included in initramfs | 52 | # do not try to update files included in initramfs |
41 | $(deps_initramfs): ; | 53 | $(deps_initramfs): ; |
42 | 54 | ||
43 | $(deps_initramfs): klibcdirs | 55 | $(deps_initramfs): klibcdirs |
44 | # We rebuild initramfs_data.cpio.gz if: | 56 | # We rebuild initramfs_data.cpio if: |
45 | # 1) Any included file is newer then initramfs_data.cpio.gz | 57 | # 1) Any included file is newer then initramfs_data.cpio |
46 | # 2) There are changes in which files are included (added or deleted) | 58 | # 2) There are changes in which files are included (added or deleted) |
47 | # 3) If gen_init_cpio are newer than initramfs_data.cpio.gz | 59 | # 3) If gen_init_cpio are newer than initramfs_data.cpio |
48 | # 4) arguments to gen_initramfs.sh changes | 60 | # 4) arguments to gen_initramfs.sh changes |
49 | $(obj)/initramfs_data.cpio.gz: $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs | 61 | $(obj)/initramfs_data.cpio$(suffix_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs |
50 | $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.gz.d | 62 | $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/.initramfs_data.cpio.d |
51 | $(call if_changed,initfs) | 63 | $(call if_changed,initfs) |
52 | 64 | ||
diff --git a/usr/initramfs_data.S b/usr/initramfs_data.S index c2e1ad424f4a..7c6973d8d829 100644 --- a/usr/initramfs_data.S +++ b/usr/initramfs_data.S | |||
@@ -26,5 +26,5 @@ SECTIONS | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | .section .init.ramfs,"a" | 28 | .section .init.ramfs,"a" |
29 | .incbin "usr/initramfs_data.cpio.gz" | 29 | .incbin "usr/initramfs_data.cpio" |
30 | 30 | ||
diff --git a/usr/initramfs_data.bz2.S b/usr/initramfs_data.bz2.S new file mode 100644 index 000000000000..bc54d090365c --- /dev/null +++ b/usr/initramfs_data.bz2.S | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | initramfs_data includes the compressed binary that is the | ||
3 | filesystem used for early user space. | ||
4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
5 | released on 2001-07-14) dit not support .incbin. | ||
6 | If you are forced to use older binutils than that then the | ||
7 | following trick can be applied to create the resulting binary: | ||
8 | |||
9 | |||
10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
13 | |||
14 | initramfs_data.scr looks like this: | ||
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | |||
20 | The above example is for i386 - the parameters vary from architectures. | ||
21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
23 | |||
24 | Using .incbin has the advantage over ld that the correct flags are set | ||
25 | in the ELF header, as required by certain architectures. | ||
26 | */ | ||
27 | |||
28 | .section .init.ramfs,"a" | ||
29 | .incbin "usr/initramfs_data.cpio.bz2" | ||
diff --git a/usr/initramfs_data.gz.S b/usr/initramfs_data.gz.S new file mode 100644 index 000000000000..890c8dd1d6bd --- /dev/null +++ b/usr/initramfs_data.gz.S | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | initramfs_data includes the compressed binary that is the | ||
3 | filesystem used for early user space. | ||
4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
5 | released on 2001-07-14) dit not support .incbin. | ||
6 | If you are forced to use older binutils than that then the | ||
7 | following trick can be applied to create the resulting binary: | ||
8 | |||
9 | |||
10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
13 | |||
14 | initramfs_data.scr looks like this: | ||
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | |||
20 | The above example is for i386 - the parameters vary from architectures. | ||
21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
23 | |||
24 | Using .incbin has the advantage over ld that the correct flags are set | ||
25 | in the ELF header, as required by certain architectures. | ||
26 | */ | ||
27 | |||
28 | .section .init.ramfs,"a" | ||
29 | .incbin "usr/initramfs_data.cpio.gz" | ||
diff --git a/usr/initramfs_data.lzma.S b/usr/initramfs_data.lzma.S new file mode 100644 index 000000000000..e11469e48562 --- /dev/null +++ b/usr/initramfs_data.lzma.S | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | initramfs_data includes the compressed binary that is the | ||
3 | filesystem used for early user space. | ||
4 | Note: Older versions of "as" (prior to binutils 2.11.90.0.23 | ||
5 | released on 2001-07-14) dit not support .incbin. | ||
6 | If you are forced to use older binutils than that then the | ||
7 | following trick can be applied to create the resulting binary: | ||
8 | |||
9 | |||
10 | ld -m elf_i386 --format binary --oformat elf32-i386 -r \ | ||
11 | -T initramfs_data.scr initramfs_data.cpio.gz -o initramfs_data.o | ||
12 | ld -m elf_i386 -r -o built-in.o initramfs_data.o | ||
13 | |||
14 | initramfs_data.scr looks like this: | ||
15 | SECTIONS | ||
16 | { | ||
17 | .init.ramfs : { *(.data) } | ||
18 | } | ||
19 | |||
20 | The above example is for i386 - the parameters vary from architectures. | ||
21 | Eventually look up LDFLAGS_BLOB in an older version of the | ||
22 | arch/$(ARCH)/Makefile to see the flags used before .incbin was introduced. | ||
23 | |||
24 | Using .incbin has the advantage over ld that the correct flags are set | ||
25 | in the ELF header, as required by certain architectures. | ||
26 | */ | ||
27 | |||
28 | .section .init.ramfs,"a" | ||
29 | .incbin "usr/initramfs_data.cpio.lzma" | ||