mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-22 04:46:50 +00:00
btrfs-progs: rescue: add create-control-device subcommand
Add a new subcommand 'btrfs rescue create-control-device' that creates /dev/btrfs-control. This is helpful on systems that may not have `mknod` installed and the device node is missing for some reason. Issue: #223 Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> [ update docs ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5c9a753ba0
commit
c11874ae81
@ -920,16 +920,28 @@ filesystem module:
|
||||
for a given filesystem
|
||||
* get the supported features (can be also found under '/sys/fs/btrfs/features')
|
||||
|
||||
The device is usually created by a system device node manager (eg. udev), but
|
||||
can be created manually:
|
||||
The device is created when btrfs is initialized, either as a module or a
|
||||
built-in functionality and makes sense only in connection with that. Running
|
||||
eg. mkfs without the module loaded will not register the device and will
|
||||
probably warn about that.
|
||||
|
||||
In rare cases when the module is loaded but the device is not present (most
|
||||
likely accidentally deleted), it's possible to recreate it by
|
||||
|
||||
--------------------
|
||||
# mknod --mode=600 /dev/btrfs-control c 10 234
|
||||
--------------------
|
||||
|
||||
or (since 5.11) by a convenience command
|
||||
|
||||
--------------------
|
||||
# btrfs rescue create-control-device
|
||||
--------------------
|
||||
|
||||
The control device is not strictly required but the device scanning will not
|
||||
work and a workaround would need to be used to mount a multi-device filesystem.
|
||||
The mount option 'device' can trigger the device scanning during mount.
|
||||
The mount option 'device' can trigger the device scanning during mount, see
|
||||
also *btrfs device scan*.
|
||||
|
||||
|
||||
FILESYSTEM WITH MULTIPLE PROFILES
|
||||
|
@ -28,7 +28,7 @@ _btrfs()
|
||||
commands_balance='start pause cancel resume status'
|
||||
commands_device='scan add delete remove ready stats usage'
|
||||
commands_scrub='start cancel resume status'
|
||||
commands_rescue='chunk-recover super-recover zero-log'
|
||||
commands_rescue='chunk-recover super-recover zero-log create-control-device'
|
||||
commands_inspect_internal='inode-resolve logical-resolve subvolid-resolve rootid min-dev-size dump-tree dump-super tree-stats'
|
||||
commands_property='get set list'
|
||||
commands_quota='enable disable rescan'
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "kerncompat.h"
|
||||
|
||||
#include <sys/sysmacros.h>
|
||||
#include <getopt.h>
|
||||
#include "kernel-shared/ctree.h"
|
||||
#include "kernel-shared/volumes.h"
|
||||
@ -264,6 +265,34 @@ out:
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(rescue_fix_device_size, "fix-device-size");
|
||||
|
||||
static const char * const cmd_rescue_create_control_device_usage[] = {
|
||||
"btrfs rescue create-control-device",
|
||||
"Create /dev/btrfs-control (see 'CONTROL DEVICE' in btrfs(5))",
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_rescue_create_control_device(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
dev_t device;
|
||||
int ret;
|
||||
|
||||
if (check_argc_exact(argc, 1))
|
||||
return 1;
|
||||
|
||||
device = makedev(10, 234);
|
||||
|
||||
ret = mknod("/dev/btrfs-control", S_IFCHR | S_IRUSR | S_IWUSR, device);
|
||||
if (ret) {
|
||||
error("could not create /dev/btrfs-control: %m");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(rescue_create_control_device, "create-control-device");
|
||||
|
||||
static const char rescue_cmd_group_info[] =
|
||||
"toolbox for specific rescue operations";
|
||||
|
||||
@ -273,6 +302,7 @@ static const struct cmd_group rescue_cmd_group = {
|
||||
&cmd_struct_rescue_super_recover,
|
||||
&cmd_struct_rescue_zero_log,
|
||||
&cmd_struct_rescue_fix_device_size,
|
||||
&cmd_struct_rescue_create_control_device,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user