Source code of filesite.io.
https://filesite.io
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
762 B
40 lines
762 B
#!/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 |