Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

initrd: remove deprecated code path (linuxrc)

Remove linuxrc initrd code path, which was deprecated in 2020.

Initramfs and (non-initial) RAM disks (i. e. brd) still work.

Both built-in and bootloader-supplied initramfs still work.

Non-linuxrc initrd code path (i. e. using /dev/ram as final root
filesystem) still works, but I put deprecation message into it.

Also I deprecate command line parameters "noinitrd" and "ramdisk_start=".

Signed-off-by: Askar Safin <safinaskar@gmail.com>
Link: https://patch.msgid.link/20251119222407.3333257-3-safinaskar@gmail.com
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Askar Safin and committed by
Christian Brauner
c350a65b 7f3b3366

+22 -114
+5 -3
Documentation/admin-guide/kernel-parameters.txt
··· 4442 4442 Note that this argument takes precedence over 4443 4443 the CONFIG_RCU_NOCB_CPU_DEFAULT_ALL option. 4444 4444 4445 - noinitrd [RAM] Tells the kernel not to load any configured 4446 - initial RAM disk. 4445 + noinitrd [Deprecated,RAM] Tells the kernel not to load any configured 4446 + initial RAM disk. Currently this parameter applies to 4447 + initrd only, not to initramfs. But it applies to both 4448 + in EFI mode. 4447 4449 4448 4450 nointremap [X86-64,Intel-IOMMU,EARLY] Do not enable interrupt 4449 4451 remapping. ··· 5458 5456 ramdisk_size= [RAM] Sizes of RAM disks in kilobytes 5459 5457 See Documentation/admin-guide/blockdev/ramdisk.rst. 5460 5458 5461 - ramdisk_start= [RAM] RAM disk image start address 5459 + ramdisk_start= [Deprecated,RAM] RAM disk image start address 5462 5460 5463 5461 random.trust_cpu=off 5464 5462 [KNL,EARLY] Disable trusting the use of the CPU's
-2
include/linux/initrd.h
··· 3 3 #ifndef __LINUX_INITRD_H 4 4 #define __LINUX_INITRD_H 5 5 6 - #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */ 7 - 8 6 /* starting block # of image */ 9 7 extern int rd_image_start; 10 8
+1 -3
init/do_mounts.c
··· 477 477 if (saved_root_name[0]) 478 478 ROOT_DEV = parse_root_device(saved_root_name); 479 479 480 - if (initrd_load(saved_root_name)) 481 - goto out; 480 + initrd_load(); 482 481 483 482 if (root_wait) 484 483 wait_for_root(saved_root_name); 485 484 mount_root(saved_root_name); 486 - out: 487 485 devtmpfs_mount(); 488 486 init_mount(".", "/", NULL, MS_MOVE, NULL); 489 487 init_chroot(".");
+4 -14
init/do_mounts.h
··· 23 23 } 24 24 25 25 #ifdef CONFIG_BLK_DEV_RAM 26 - 27 - int __init rd_load_disk(int n); 28 - int __init rd_load_image(char *from); 29 - 26 + int __init rd_load_image(void); 30 27 #else 31 - 32 - static inline int rd_load_disk(int n) { return 0; } 33 - static inline int rd_load_image(char *from) { return 0; } 34 - 28 + static inline int rd_load_image(void) { return 0; } 35 29 #endif 36 30 37 31 #ifdef CONFIG_BLK_DEV_INITRD 38 - bool __init initrd_load(char *root_device_name); 32 + void __init initrd_load(void); 39 33 #else 40 - static inline bool initrd_load(char *root_device_name) 41 - { 42 - return false; 43 - } 44 - 34 + static inline void initrd_load(void) { } 45 35 #endif 46 36 47 37 /* Ensure that async file closing finished to prevent spurious errors. */
+8 -79
init/do_mounts_initrd.c
··· 2 2 #include <linux/unistd.h> 3 3 #include <linux/kernel.h> 4 4 #include <linux/fs.h> 5 - #include <linux/minix_fs.h> 6 - #include <linux/romfs_fs.h> 7 5 #include <linux/initrd.h> 8 - #include <linux/sched.h> 9 - #include <linux/freezer.h> 10 - #include <linux/kmod.h> 11 - #include <uapi/linux/mount.h> 12 6 13 7 #include "do_mounts.h" 14 8 ··· 35 41 36 42 static int __init no_initrd(char *str) 37 43 { 44 + pr_warn("noinitrd option is deprecated and will be removed soon\n"); 38 45 mount_initrd = 0; 39 46 return 1; 40 47 } ··· 65 70 } 66 71 early_param("initrd", early_initrd); 67 72 68 - static int __init init_linuxrc(struct subprocess_info *info, struct cred *new) 69 - { 70 - ksys_unshare(CLONE_FS | CLONE_FILES); 71 - console_on_rootfs(); 72 - /* move initrd over / and chdir/chroot in initrd root */ 73 - init_chdir("/root"); 74 - init_mount(".", "/", NULL, MS_MOVE, NULL); 75 - init_chroot("."); 76 - ksys_setsid(); 77 - return 0; 78 - } 79 - 80 - static void __init handle_initrd(char *root_device_name) 81 - { 82 - struct subprocess_info *info; 83 - static char *argv[] = { "linuxrc", NULL, }; 84 - extern char *envp_init[]; 85 - int error; 86 - 87 - pr_warn("using deprecated initrd support, will be removed soon.\n"); 88 - 89 - real_root_dev = new_encode_dev(ROOT_DEV); 90 - create_dev("/dev/root.old", Root_RAM0); 91 - /* mount initrd on rootfs' /root */ 92 - mount_root_generic("/dev/root.old", root_device_name, 93 - root_mountflags & ~MS_RDONLY); 94 - init_mkdir("/old", 0700); 95 - init_chdir("/old"); 96 - 97 - info = call_usermodehelper_setup("/linuxrc", argv, envp_init, 98 - GFP_KERNEL, init_linuxrc, NULL, NULL); 99 - if (!info) 100 - return; 101 - call_usermodehelper_exec(info, UMH_WAIT_PROC|UMH_FREEZABLE); 102 - 103 - /* move initrd to rootfs' /old */ 104 - init_mount("..", ".", NULL, MS_MOVE, NULL); 105 - /* switch root and cwd back to / of rootfs */ 106 - init_chroot(".."); 107 - 108 - if (new_decode_dev(real_root_dev) == Root_RAM0) { 109 - init_chdir("/old"); 110 - return; 111 - } 112 - 113 - init_chdir("/"); 114 - ROOT_DEV = new_decode_dev(real_root_dev); 115 - mount_root(root_device_name); 116 - 117 - printk(KERN_NOTICE "Trying to move old root to /initrd ... "); 118 - error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL); 119 - if (!error) 120 - printk("okay\n"); 121 - else { 122 - if (error == -ENOENT) 123 - printk("/initrd does not exist. Ignored.\n"); 124 - else 125 - printk("failed\n"); 126 - printk(KERN_NOTICE "Unmounting old root\n"); 127 - init_umount("/old", MNT_DETACH); 128 - } 129 - } 130 - 131 - bool __init initrd_load(char *root_device_name) 73 + void __init initrd_load(void) 132 74 { 133 75 if (mount_initrd) { 134 76 create_dev("/dev/ram", Root_RAM0); 135 77 /* 136 - * Load the initrd data into /dev/ram0. Execute it as initrd 137 - * unless /dev/ram0 is supposed to be our actual root device, 138 - * in that case the ram disk is just set up here, and gets 139 - * mounted in the normal path. 78 + * Load the initrd data into /dev/ram0. 140 79 */ 141 - if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { 142 - init_unlink("/initrd.image"); 143 - handle_initrd(root_device_name); 144 - return true; 80 + if (rd_load_image()) { 81 + pr_warn("using deprecated initrd support, will be removed in January 2027; " 82 + "use initramfs instead or (as a last resort) /sys/firmware/initrd; " 83 + "see section \"Workaround\" in " 84 + "https://lore.kernel.org/lkml/20251010094047.3111495-1-safinaskar@gmail.com\n"); 145 85 } 146 86 } 147 87 init_unlink("/initrd.image"); 148 - return false; 149 88 }
+4 -13
init/do_mounts_rd.c
··· 22 22 23 23 static int __init ramdisk_start_setup(char *str) 24 24 { 25 + pr_warn("ramdisk_start= option is deprecated and will be removed soon\n"); 25 26 return kstrtoint(str, 0, &rd_image_start) == 0; 26 27 } 27 28 __setup("ramdisk_start=", ramdisk_start_setup); ··· 177 176 return i_size_read(inode) >> 10; 178 177 } 179 178 180 - int __init rd_load_image(char *from) 179 + int __init rd_load_image(void) 181 180 { 182 181 int res = 0; 183 182 unsigned long rd_blocks, devblocks, nr_disks; ··· 191 190 if (IS_ERR(out_file)) 192 191 goto out; 193 192 194 - in_file = filp_open(from, O_RDONLY, 0); 193 + in_file = filp_open("/initrd.image", O_RDONLY, 0); 195 194 if (IS_ERR(in_file)) 196 195 goto noclose_input; 197 196 ··· 220 219 /* 221 220 * OK, time to copy in the data 222 221 */ 223 - if (strcmp(from, "/initrd.image") == 0) 224 - devblocks = nblocks; 225 - else 226 - devblocks = nr_blocks(in_file); 222 + devblocks = nblocks; 227 223 228 224 if (devblocks == 0) { 229 225 printk(KERN_ERR "RAMDISK: could not determine device size\n"); ··· 262 264 kfree(buf); 263 265 init_unlink("/dev/ram"); 264 266 return res; 265 - } 266 - 267 - int __init rd_load_disk(int n) 268 - { 269 - create_dev("/dev/root", ROOT_DEV); 270 - create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n)); 271 - return rd_load_image("/dev/root"); 272 267 } 273 268 274 269 static int exit_code;