linux-vserver / util-vserver

http://linux-vserver.org/
GNU General Public License v2.0
15 stars 14 forks source link

Fix ignore_lostfound logic: #7

Closed clopez closed 10 years ago

clopez commented 10 years ago
dhozac commented 10 years ago

That is the point. It should fail whenever $2 is not set. What problem are you actually trying to fix?

clopez commented 10 years ago

The problem is that current code don't ignores lost+found when $2 is not set.

# Create empty dir with a lost+found dir
mkdir -p /tmp/emptydir/lost+found
# Source the funciton isDirectoryEmpty
. scripts/functions
# Check it
isDirectoryEmpty /tmp/emptydir
echo $?
1

With this patch it returns true

isDirectoryEmpty /tmp/emptydir
echo $?
0

And this function is called without setting $2 at least once.

./scripts/vserver-build.functions:141:  test ! -e "$i" || isDirectoryEmpty "$i" || {

Building an vserver with the debootstrap method on a ext2/ext3/ext4 LVM volume recently formatted fails without this patch

dhozac commented 10 years ago

This is intentional. It should work exactly as it works right now. What command are you running that doesn't work? Building guests on a new filesystem works fine here.

clopez commented 10 years ago

For example: If the new filesystem has a lost+found directory (ext2/3/4) vserver debootstrap aborts when --force is used.

$ mkdir /var/lib/vservers/testserver
$ lvcreate -L 4G -n vs-testserver vg
$ mkfs.ext4 /dev/vg/vs-testserver
$ mount /dev/vg/vs-testserver /var/lib/vservers/testserver
$ vserver --silent testserver build -m debootstrap --interface eth0:192.168.10.110/24 --hostname testserver --force -- -d testing -m http://ftp.debian.org/debian -- --arch amd64
mv: cannot move `/etc/vservers/.defaults/vdirbase/testserver' to `/etc/vservers/.defaults/vdirbase/testserver.~1395230681~': Device or resource busy
dhozac commented 10 years ago

--force does not make sense for a mount point. It will not be able to move it. Simplest solution is to just not use --force, and just use delete first if you're looking to recreate a guest.