aboutsummaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
Diffstat (limited to 'usr')
-rw-r--r--usr/Kconfig89
-rw-r--r--usr/Makefile36
-rw-r--r--usr/initramfs_data.S2
-rw-r--r--usr/initramfs_data.bz2.S29
-rw-r--r--usr/initramfs_data.gz.S29
-rw-r--r--usr/initramfs_data.lzma.S29
6 files changed, 201 insertions, 13 deletions
diff --git a/usr/Kconfig b/usr/Kconfig
index 86cecb59dd07..43a3a0fe8f29 100644
--- a/usr/Kconfig
+++ b/usr/Kconfig
@@ -44,3 +44,92 @@ 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
48config RD_GZIP
49 bool "Initial ramdisk compressed using gzip"
50 default y
51 depends on BLK_DEV_INITRD=y
52 select DECOMPRESS_GZIP
53 help
54 Support loading of a gzip encoded initial ramdisk or cpio buffer.
55 If unsure, say Y.
56
57config RD_BZIP2
58 bool "Initial ramdisk compressed using bzip2"
59 default n
60 depends on BLK_DEV_INITRD=y
61 select DECOMPRESS_BZIP2
62 help
63 Support loading of a bzip2 encoded initial ramdisk or cpio buffer
64 If unsure, say N.
65
66config RD_LZMA
67 bool "Initial ramdisk compressed using lzma"
68 default n
69 depends on BLK_DEV_INITRD=y
70 select DECOMPRESS_LZMA
71 help
72 Support loading of a lzma encoded initial ramdisk or cpio buffer
73 If unsure, say N.
74
75choice
76 prompt "Built-in initramfs compression mode"
77 help
78 This setting is only meaningful if the INITRAMFS_SOURCE is
79 set. It decides by which algorithm the INITRAMFS_SOURCE will
80 be compressed.
81 Several compression algorithms are available, which differ
82 in efficiency, compression and decompression speed.
83 Compression speed is only relevant when building a kernel.
84 Decompression speed is relevant at each boot.
85
86 If you have any problems with bzip2 or lzma compressed
87 initramfs, mail me (Alain Knaff) <alain@knaff.lu>.
88
89 High compression options are mostly useful for users who
90 are low on disk space (embedded systems), but for whom ram
91 size matters less.
92
93 If in doubt, select 'gzip'
94
95config INITRAMFS_COMPRESSION_NONE
96 bool "None"
97 help
98 Do not compress the built-in initramfs at all. This may
99 sound wasteful in space, but, you should be aware that the
100 built-in initramfs will be compressed at a later stage
101 anyways along with the rest of the kernel, on those
102 architectures that support this.
103 However, not compressing the initramfs may lead to slightly
104 higher memory consumption during a short time at boot, while
105 both the cpio image and the unpacked filesystem image will
106 be present in memory simultaneously
107
108config INITRAMFS_COMPRESSION_GZIP
109 bool "Gzip"
110 depends on RD_GZIP
111 help
112 The old and tried gzip compression. Its compression ratio is
113 the poorest among the 3 choices; however its speed (both
114 compression and decompression) is the fastest.
115
116config INITRAMFS_COMPRESSION_BZIP2
117 bool "Bzip2"
118 depends on RD_BZIP2
119 help
120 Its compression ratio and speed is intermediate.
121 Decompression speed is slowest among the three. The initramfs
122 size is about 10% smaller with bzip2, in comparison to gzip.
123 Bzip2 uses a large amount of memory. For modern kernels you
124 will need at least 8MB RAM or more for booting.
125
126config INITRAMFS_COMPRESSION_LZMA
127 bool "LZMA"
128 depends on RD_LZMA
129 help
130 The most recent compression algorithm.
131 Its ratio is best, decompression speed is between the other
132 two. Compression is slowest. The initramfs size is about 33%
133 smaller with LZMA in comparison to gzip.
134
135endchoice
diff --git a/usr/Makefile b/usr/Makefile
index 201f27f8cbaf..b84894b3929d 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -6,13 +6,25 @@ klibcdirs:;
6PHONY += klibcdirs 6PHONY += klibcdirs
7 7
8 8
9# No compression
10suffix_$(CONFIG_INITRAMFS_COMPRESSION_NONE) =
11
12# Gzip, but no bzip2
13suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz
14
15# Bzip2
16suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2
17
18# Lzma
19suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
20
9# Generate builtin.o based on initramfs_data.o 21# Generate builtin.o based on initramfs_data.o
10obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o 22obj-$(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
32ifneq ($(wildcard $(obj)/.initramfs_data.cpio.gz.d),) 44ifneq ($(wildcard $(obj)/.initramfs_data.cpio.d),)
33 include $(obj)/.initramfs_data.cpio.gz.d 45 include $(obj)/.initramfs_data.cpio.d
34endif 46endif
35 47
36quiet_cmd_initfs = GEN $@ 48quiet_cmd_initfs = GEN $@
37 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input) 49 cmd_initfs = $(initramfs) -o $@ $(ramfs-args) $(ramfs-input)
38 50
39targets := initramfs_data.cpio.gz 51targets := 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:
15SECTIONS
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:
15SECTIONS
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:
15SECTIONS
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"