From 311522d3b3d695404f017b8dccd81c89092d4bb0 Mon Sep 17 00:00:00 2001 From: filesite Date: Tue, 15 Nov 2022 22:52:52 +0800 Subject: [PATCH] smbpwd script update --- bin/create_virtual_disk.sh | 40 ++++++++++++++++++++++++++++++++++++++ bin/smbpwd.sh | 8 ++------ 2 files changed, 42 insertions(+), 6 deletions(-) create mode 100755 bin/create_virtual_disk.sh diff --git a/bin/create_virtual_disk.sh b/bin/create_virtual_disk.sh new file mode 100755 index 0000000..f342f9f --- /dev/null +++ b/bin/create_virtual_disk.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +# 查看正在使用的循环分区 +losetup -a + +# 修改系统配置,增加循环分区数量 +/etc/modprobe.conf +# 添加:options loop max_loop=20 +# 让它生效 +modprobe -v loop + +# 查看所有循环分区 +ls -l /dev | grep loop + +# 创建新的循环分区 +mknod -m 0660 /dev/loopX b 7 X + +# 修改所有权 +chown root:disk /dev/loopX + +# 创建指定大小的镜像文件 +dd if=/dev/zero of=/user_disks/username.img bs=1MB count=1024 + +# 格式化镜像文件 +mkfs.ext4 /user_disks/username.img + +# 初始化镜像 +losetup /dev/loopX /user_disks/username.img + +# 创建挂载目录 +mkdir /mnt/disk_username + +# 挂载用户镜像 +mount /dev/loopX /mnt/disk_username + +# 卸载循环分区 +#umount /dev/loopX + +# 删除循环分区 +#losetup -d /dev/loopX \ No newline at end of file diff --git a/bin/smbpwd.sh b/bin/smbpwd.sh index 8edb0d7..6e9c31b 100755 --- a/bin/smbpwd.sh +++ b/bin/smbpwd.sh @@ -1,11 +1,7 @@ #!/bin/sh -username=$1 -password=$2 - -if [ -z $username ]; then - user='filesite' -fi +password=$1 +username='filesite' if [ -z $password ]; then user='88888888'