filesite
2 years ago
2 changed files with 42 additions and 6 deletions
@ -0,0 +1,40 @@
@@ -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 |
Loading…
Reference in new issue