mirror of
https://github.com/torvalds/linux.git
synced 2026-03-07 23:04:33 +01:00
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>
This commit is contained in:
parent
7f3b336685
commit
c350a65b56
6 changed files with 22 additions and 114 deletions
|
|
@ -4442,8 +4442,10 @@ Kernel parameters
|
|||
Note that this argument takes precedence over
|
||||
the CONFIG_RCU_NOCB_CPU_DEFAULT_ALL option.
|
||||
|
||||
noinitrd [RAM] Tells the kernel not to load any configured
|
||||
initial RAM disk.
|
||||
noinitrd [Deprecated,RAM] Tells the kernel not to load any configured
|
||||
initial RAM disk. Currently this parameter applies to
|
||||
initrd only, not to initramfs. But it applies to both
|
||||
in EFI mode.
|
||||
|
||||
nointremap [X86-64,Intel-IOMMU,EARLY] Do not enable interrupt
|
||||
remapping.
|
||||
|
|
@ -5456,7 +5458,7 @@ Kernel parameters
|
|||
ramdisk_size= [RAM] Sizes of RAM disks in kilobytes
|
||||
See Documentation/admin-guide/blockdev/ramdisk.rst.
|
||||
|
||||
ramdisk_start= [RAM] RAM disk image start address
|
||||
ramdisk_start= [Deprecated,RAM] RAM disk image start address
|
||||
|
||||
random.trust_cpu=off
|
||||
[KNL,EARLY] Disable trusting the use of the CPU's
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
#ifndef __LINUX_INITRD_H
|
||||
#define __LINUX_INITRD_H
|
||||
|
||||
#define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
|
||||
|
||||
/* starting block # of image */
|
||||
extern int rd_image_start;
|
||||
|
||||
|
|
|
|||
|
|
@ -477,13 +477,11 @@ void __init prepare_namespace(void)
|
|||
if (saved_root_name[0])
|
||||
ROOT_DEV = parse_root_device(saved_root_name);
|
||||
|
||||
if (initrd_load(saved_root_name))
|
||||
goto out;
|
||||
initrd_load();
|
||||
|
||||
if (root_wait)
|
||||
wait_for_root(saved_root_name);
|
||||
mount_root(saved_root_name);
|
||||
out:
|
||||
devtmpfs_mount();
|
||||
init_mount(".", "/", NULL, MS_MOVE, NULL);
|
||||
init_chroot(".");
|
||||
|
|
|
|||
|
|
@ -23,25 +23,15 @@ static inline __init int create_dev(char *name, dev_t dev)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_RAM
|
||||
|
||||
int __init rd_load_disk(int n);
|
||||
int __init rd_load_image(char *from);
|
||||
|
||||
int __init rd_load_image(void);
|
||||
#else
|
||||
|
||||
static inline int rd_load_disk(int n) { return 0; }
|
||||
static inline int rd_load_image(char *from) { return 0; }
|
||||
|
||||
static inline int rd_load_image(void) { return 0; }
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_INITRD
|
||||
bool __init initrd_load(char *root_device_name);
|
||||
void __init initrd_load(void);
|
||||
#else
|
||||
static inline bool initrd_load(char *root_device_name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void initrd_load(void) { }
|
||||
#endif
|
||||
|
||||
/* Ensure that async file closing finished to prevent spurious errors. */
|
||||
|
|
|
|||
|
|
@ -2,13 +2,7 @@
|
|||
#include <linux/unistd.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/minix_fs.h>
|
||||
#include <linux/romfs_fs.h>
|
||||
#include <linux/initrd.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/kmod.h>
|
||||
#include <uapi/linux/mount.h>
|
||||
|
||||
#include "do_mounts.h"
|
||||
|
||||
|
|
@ -41,6 +35,7 @@ late_initcall(kernel_do_mounts_initrd_sysctls_init);
|
|||
|
||||
static int __init no_initrd(char *str)
|
||||
{
|
||||
pr_warn("noinitrd option is deprecated and will be removed soon\n");
|
||||
mount_initrd = 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -70,85 +65,19 @@ static int __init early_initrd(char *p)
|
|||
}
|
||||
early_param("initrd", early_initrd);
|
||||
|
||||
static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)
|
||||
{
|
||||
ksys_unshare(CLONE_FS | CLONE_FILES);
|
||||
console_on_rootfs();
|
||||
/* move initrd over / and chdir/chroot in initrd root */
|
||||
init_chdir("/root");
|
||||
init_mount(".", "/", NULL, MS_MOVE, NULL);
|
||||
init_chroot(".");
|
||||
ksys_setsid();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __init handle_initrd(char *root_device_name)
|
||||
{
|
||||
struct subprocess_info *info;
|
||||
static char *argv[] = { "linuxrc", NULL, };
|
||||
extern char *envp_init[];
|
||||
int error;
|
||||
|
||||
pr_warn("using deprecated initrd support, will be removed soon.\n");
|
||||
|
||||
real_root_dev = new_encode_dev(ROOT_DEV);
|
||||
create_dev("/dev/root.old", Root_RAM0);
|
||||
/* mount initrd on rootfs' /root */
|
||||
mount_root_generic("/dev/root.old", root_device_name,
|
||||
root_mountflags & ~MS_RDONLY);
|
||||
init_mkdir("/old", 0700);
|
||||
init_chdir("/old");
|
||||
|
||||
info = call_usermodehelper_setup("/linuxrc", argv, envp_init,
|
||||
GFP_KERNEL, init_linuxrc, NULL, NULL);
|
||||
if (!info)
|
||||
return;
|
||||
call_usermodehelper_exec(info, UMH_WAIT_PROC|UMH_FREEZABLE);
|
||||
|
||||
/* move initrd to rootfs' /old */
|
||||
init_mount("..", ".", NULL, MS_MOVE, NULL);
|
||||
/* switch root and cwd back to / of rootfs */
|
||||
init_chroot("..");
|
||||
|
||||
if (new_decode_dev(real_root_dev) == Root_RAM0) {
|
||||
init_chdir("/old");
|
||||
return;
|
||||
}
|
||||
|
||||
init_chdir("/");
|
||||
ROOT_DEV = new_decode_dev(real_root_dev);
|
||||
mount_root(root_device_name);
|
||||
|
||||
printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
|
||||
error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
|
||||
if (!error)
|
||||
printk("okay\n");
|
||||
else {
|
||||
if (error == -ENOENT)
|
||||
printk("/initrd does not exist. Ignored.\n");
|
||||
else
|
||||
printk("failed\n");
|
||||
printk(KERN_NOTICE "Unmounting old root\n");
|
||||
init_umount("/old", MNT_DETACH);
|
||||
}
|
||||
}
|
||||
|
||||
bool __init initrd_load(char *root_device_name)
|
||||
void __init initrd_load(void)
|
||||
{
|
||||
if (mount_initrd) {
|
||||
create_dev("/dev/ram", Root_RAM0);
|
||||
/*
|
||||
* Load the initrd data into /dev/ram0. Execute it as initrd
|
||||
* unless /dev/ram0 is supposed to be our actual root device,
|
||||
* in that case the ram disk is just set up here, and gets
|
||||
* mounted in the normal path.
|
||||
* Load the initrd data into /dev/ram0.
|
||||
*/
|
||||
if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
|
||||
init_unlink("/initrd.image");
|
||||
handle_initrd(root_device_name);
|
||||
return true;
|
||||
if (rd_load_image()) {
|
||||
pr_warn("using deprecated initrd support, will be removed in January 2027; "
|
||||
"use initramfs instead or (as a last resort) /sys/firmware/initrd; "
|
||||
"see section \"Workaround\" in "
|
||||
"https://lore.kernel.org/lkml/20251010094047.3111495-1-safinaskar@gmail.com\n");
|
||||
}
|
||||
}
|
||||
init_unlink("/initrd.image");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ int __initdata rd_image_start; /* starting block # of image */
|
|||
|
||||
static int __init ramdisk_start_setup(char *str)
|
||||
{
|
||||
pr_warn("ramdisk_start= option is deprecated and will be removed soon\n");
|
||||
return kstrtoint(str, 0, &rd_image_start) == 0;
|
||||
}
|
||||
__setup("ramdisk_start=", ramdisk_start_setup);
|
||||
|
|
@ -176,7 +177,7 @@ static unsigned long nr_blocks(struct file *file)
|
|||
return i_size_read(inode) >> 10;
|
||||
}
|
||||
|
||||
int __init rd_load_image(char *from)
|
||||
int __init rd_load_image(void)
|
||||
{
|
||||
int res = 0;
|
||||
unsigned long rd_blocks, devblocks, nr_disks;
|
||||
|
|
@ -190,7 +191,7 @@ int __init rd_load_image(char *from)
|
|||
if (IS_ERR(out_file))
|
||||
goto out;
|
||||
|
||||
in_file = filp_open(from, O_RDONLY, 0);
|
||||
in_file = filp_open("/initrd.image", O_RDONLY, 0);
|
||||
if (IS_ERR(in_file))
|
||||
goto noclose_input;
|
||||
|
||||
|
|
@ -219,10 +220,7 @@ int __init rd_load_image(char *from)
|
|||
/*
|
||||
* OK, time to copy in the data
|
||||
*/
|
||||
if (strcmp(from, "/initrd.image") == 0)
|
||||
devblocks = nblocks;
|
||||
else
|
||||
devblocks = nr_blocks(in_file);
|
||||
devblocks = nblocks;
|
||||
|
||||
if (devblocks == 0) {
|
||||
printk(KERN_ERR "RAMDISK: could not determine device size\n");
|
||||
|
|
@ -266,13 +264,6 @@ out:
|
|||
return res;
|
||||
}
|
||||
|
||||
int __init rd_load_disk(int n)
|
||||
{
|
||||
create_dev("/dev/root", ROOT_DEV);
|
||||
create_dev("/dev/ram", MKDEV(RAMDISK_MAJOR, n));
|
||||
return rd_load_image("/dev/root");
|
||||
}
|
||||
|
||||
static int exit_code;
|
||||
static int decompress_error;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue