Written by michal
on
on
Create fake loop device on Fedora
First question – what is the purpose? Such fake loop device can be used as pv in lvm in case we want to play around and don’t want to add a new disk.
- Prepare a binary file with dd e.g. /srv/swift-disk.bin
- Create a script in e.g: /usr/lib/systemd/scripts and ensure that it is executable:
do_loop()
{
losetup /dev/loop0 /srv/swift-disk.bin
}
do_loop
- Create a service in: /usr/lib/systemd/system
[Unit]
Description=Setup loop devices for swift
DefaultDependencies=false
ConditionFileIsExecutable=/usr/lib/systemd/scripts/swift-loop
Before=local-fs.target
After=systemd-udev-settle.service
#Require=systemd-udev-settle.service
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/scripts/swift-loop
TimeoutSec=60
RemainAfterExit=yes
[Install]
WantedBy=local-fs.target
Also=systemd-udev-settle.service
- Enable and start a service
systemctl enable swift-loop.service
systemctl start swift-loop.service